forked from infusionsoft/Official-API-Python-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfusionsoftLibrary.py
More file actions
27 lines (21 loc) · 881 Bytes
/
InfusionsoftLibrary.py
File metadata and controls
27 lines (21 loc) · 881 Bytes
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
from xmlrpclib import ServerProxy, Error
class Infusionsoft:
def __init__(self, name, api_key):
self.client = ServerProxy("https://" + name + ".infusionsoft.com/api/xmlrpc")
self.client.error = Error
self.key = api_key
def __getattr__(self, service):
def function(method, *args):
call = getattr(self.client, service + '.' + method)
try:
return call(self.key, *args)
except self.client.error, v:
return "ERROR", v
return function
def server(self):
return self.client
class InfusionsoftOAuth(Infusionsoft):
def __init__(self, access_token):
self.client = ServerProxy("https://api.infusionsoft.com/crm/xmlrpc/v1?access_token=%s" % access_token)
self.client.error = Error
self.key = access_token