-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhighrise.py
More file actions
43 lines (31 loc) · 953 Bytes
/
highrise.py
File metadata and controls
43 lines (31 loc) · 953 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
31
32
33
34
35
36
37
38
39
40
41
42
43
import requests
HIGHRISE_URL = 'https://{}.highrisehq.com/'
class HighriseAPIError(Exception):
pass
class HighriseAPI(object):
def __init__(self, subdomain, key, app_name=None, email=None):
self.key = key
self.req = requests.Request(
method='GET',
url=HIGHRISE_URL.format(subdomain),
headers={
'User-Agent': self._build_user_agent(app_name, email),
},
auth=(key, ''),
)
@staticmethod
def _build_user_agent(app_name, email):
header = 'Python SDK'
if app_name:
header += ' ' + app_name
if email:
header += ' (' + email + ')'
return header
def request(self, rtype):
pass
def me(self):
self.req.url += 'me.xml'
return requests.Session()\
.send(self.req.prepare())
api = HighriseAPI('<subdomain>', '<api_key>')
api.me()