forked from mozilla/agithub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SalesForce.py
37 lines (31 loc) · 1.17 KB
/
SalesForce.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
from agithub import API, ConnectionProperties, Client
class SalesForce(API):
'''
SalesForce.com REST API
Example taken from
http://www.salesforce.com/us/developer/docs/api_rest/index_Left.htm#CSHID=quickstart_code.htm|StartTopic=Content%2Fquickstart_code.htm|SkinName=webhelp
>>> from SalesForce import SalesForce
>>> sf = SalesForce()
>>> sf.services.data.get()
(200,
[{u'label': u"Winter '11",
u'url': u'/services/data/v20.0',
u'version': u'20.0'},
...
{u'label': u"Spring '14",
u'url': u'/services/data/v30.0',
u'version': u'30.0'}])
SalseForce allows you to request either XML or JSON based on the
URL "file extension," like so
>>> sf.services["data.xml"].get()
(200, '<?xml version="1.0" encoding="UTF-8"?> ....')
NB: XML is not automically decoded or de-serialized. Patch the
Content class to fix this.
'''
def __init__(self, *args, **kwargs):
props = ConnectionProperties(
api_url = 'na1.salesforce.com'
, secure_http = True
)
self.setClient(Client(*args, **kwargs))
self.setConnectionProperties(props)