mirror of
https://github.com/kennethreitz-archive/python-convore.git
synced 2026-06-05 23:40:18 +00:00
convore.api will make the calls inside of objects.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import requests
|
||||
import json
|
||||
import models
|
||||
|
||||
API_URL = 'https://convore.com/api/'
|
||||
|
||||
def login(username, password):
|
||||
auth = requests.AuthObject(username, password)
|
||||
requests.add_autoauth(API_URL, auth)
|
||||
|
||||
|
||||
class Groups(object):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def __iter__(self):
|
||||
r = requests.get(API_URL + 'groups.json')
|
||||
groups = json.loads(r.content)['groups']
|
||||
|
||||
for group in groups:
|
||||
_group = models.Group()
|
||||
_group.import_from_api(group)
|
||||
yield _group
|
||||
|
||||
def __getitem__(self, key):
|
||||
r = requests.get(API_URL + 'groups/%s.json' % key)
|
||||
group = models.Group()
|
||||
_group = json.loads(r.content)['group']
|
||||
group.import_from_api(_group)
|
||||
|
||||
return _group
|
||||
|
||||
def iterkeys():
|
||||
return []
|
||||
|
||||
def iteritems():
|
||||
return
|
||||
+2
-2
@@ -13,6 +13,7 @@ import json
|
||||
import requests
|
||||
|
||||
import models
|
||||
import api
|
||||
|
||||
|
||||
__title__ = 'convore'
|
||||
@@ -27,8 +28,7 @@ API_URL = 'https://convore.com/api/'
|
||||
|
||||
|
||||
def login(username, password):
|
||||
auth = requests.AuthObject(username, password)
|
||||
requests.add_autoauth(API_URL, auth)
|
||||
api.login(username, password)
|
||||
|
||||
|
||||
def account_verify():
|
||||
|
||||
Reference in New Issue
Block a user