-
Notifications
You must be signed in to change notification settings - Fork 42
/
latchuser.py
61 lines (48 loc) · 2.26 KB
/
latchuser.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'''
This library offers an API to use LatchAuth in a python environment.
Copyright (C) 2013 Eleven Paths
This library is free software you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
from latchauth import LatchAuth
class LatchUser(LatchAuth):
def __init__(self, user_id, secret_key):
'''
Create an instance of the class with the User ID and secret obtained from Eleven Paths
@param $user_id
@param $secret_key
'''
super(LatchUser, self).__init__(user_id, secret_key)
def get_subscription(self):
return self._http("GET", self.API_SUBSCRIPTION_URL)
def create_application(self, name, two_factor, lock_on_request, contact_phone, contact_email):
params = {
'name': name,
'two_factor': two_factor,
'lock_on_request': lock_on_request,
'contactPhone': contact_phone,
'contactEmail': contact_email
}
return self._http("PUT", self.API_APPLICATION_URL, None, params)
def remove_application(self, application_id):
return self._http("DELETE", self.API_APPLICATION_URL + "/" + application_id)
def get_applications(self):
return self._http("GET", self.API_APPLICATION_URL)
def update_application(self, application_id, name, two_factor, lock_on_request, contact_phone, contact_email):
params = {
'name': name,
'two_factor': two_factor,
'lock_on_request': lock_on_request,
'contactPhone': contact_phone,
'email': contact_email
}
return self._http("POST", self.API_APPLICATION_URL + "/" + application_id, None, params)