-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathlibrary.py
More file actions
30 lines (24 loc) · 933 Bytes
/
library.py
File metadata and controls
30 lines (24 loc) · 933 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
28
29
30
try:
from xmlrpc.client import ServerProxy, Error
except ImportError:
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 as 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