-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.py
More file actions
34 lines (26 loc) · 828 Bytes
/
client.py
File metadata and controls
34 lines (26 loc) · 828 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
import requests
from .message import _Message
from .email import _Email
from .log import _Log
from .store import _Store
class _Interceptor(requests.auth.AuthBase):
def __init__(self, api_key):
self.api_key = api_key
def __call__(self, r):
r.headers['Authorization'] = 'Bearer ' + self.api_key
r.headers['Content-Type'] = 'application/json; charset=utf-8'
return r
class Client():
def __init__(self, account_id, api_key):
self.account_id = account_id
self.api_key = api_key
self.interceptor = _Interceptor(api_key)
def message(self, client_id):
return _Message(self.account_id, self.api_key, client_id)
def email(self):
return _Email(self.interceptor)
def log(self):
log = _Log(self.interceptor)
return log
def store(self):
return _Store(self.interceptor)