forked from infusionsoft/Official-API-Python-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
78 lines (66 loc) · 3.5 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from infusionsoft.library import Infusionsoft
infusionsoft = Infusionsoft('Infusionsoft Account Name', 'API Key Goes Here')
# Example 1: Add Contact
#----------------------------------------------------------------------------------------
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '[email protected]'}
print infusionsoft.ContactService('add', contact)
# Example 2: Merge two duplicate contacts
#----------------------------------------------------------------------------------------
contactId = 56
duplicateContactId = 57
print infusionsoft.ContactService('merge', contactId, duplicateContactId)
# Example 3: Query a contact using data service
#----------------------------------------------------------------------------------------
table = 'Contact'
returnFields = ['Id', 'FirstName']
query = {'FirstName' : 'John'}
limit = 10
page = 0
print infusionsoft.DataService('query', table, limit, page, query, returnFields)
# Example 4: Return a products inventory using product service
#----------------------------------------------------------------------------------------
productId = 1
print infusionsoft.ProductService('getInventory', productId)
# Example 5: Charge an invoice using the invoice service
#----------------------------------------------------------------------------------------
invoiceId = 16
notes = 'API Upsell Payment'
creditCardId = 2
merchantAccountId = 1
bypassCommissions = False
print infusionsoft.InvoiceService('chargeInvoice', invoiceId, notes, creditCardId, merchantAccountId, bypassCommissions)
# Example 6: Send an email using the email service
#----------------------------------------------------------------------------------------
contactList = [123, 456, 789]
fromAddress = '[email protected]'
toAddress = '~Contact.Email~'
ccAddress = ''
bccAddress = ''
contentType = 'Text'
subject = 'This is just a test email, relax!'
htmlBody = ''
textBody = 'This is the contant for the email'
print infusionsoft.APIEmailService('sendEmail', contactList, fromAddress, toAddress, ccAddress, bccAddress, contentType, subject, htmlBody, textBody)
# Example 7: Get all report columns using the search service
#----------------------------------------------------------------------------------------
savedSearchId = 3
userId = 1
print infusionsoft.SearchService('getAllReportColumns', savedSearchId, userId)
# Example 8: Get all shipping options with the shipping service
#----------------------------------------------------------------------------------------
print infusionsoft.ShippingService('getAllShippingOptions')
# Example 9: Get affiliate payouts info using filter with the affiliate service
#----------------------------------------------------------------------------------------
from datetime import datetime
affiliateId = 2
filterStartDate = datetime(2012, 10, 18)
filterEndDate = datetime(2012, 10, 23)
print infusionsoft.APIAffiliateService('affPayouts', affiliateId, filterStartDate, filterEndDate)
# Example 10: Get the download URL of a particular file
#----------------------------------------------------------------------------------------
fileId = 23
print infusionsoft.FileService('getDownloadUrl', fileId)
# Example 11: Using the library server method to access the API : Create a contact
#----------------------------------------------------------------------------------------
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '[email protected]'}
print infusionsoft.server().ContactService.add(infusionsoft.key, contact)