|
|
|
@ -50,13 +50,15 @@ class APIv2( object ):
|
|
|
|
|
new_query.update( query )
|
|
|
|
|
|
|
|
|
|
if 'expand' in new_query:
|
|
|
|
|
if new_query[ 'expand' ]:
|
|
|
|
|
new_query[ 'expand' ] = [ ",".join( new_query[ 'expand' ] ) ]
|
|
|
|
|
else:
|
|
|
|
|
del new_query[ 'expand' ]
|
|
|
|
|
|
|
|
|
|
return urlqueryparse.set_query_fields( url, new_query )
|
|
|
|
|
new_url = urlqueryparse.set_query_fields( url, new_query )
|
|
|
|
|
return new_url
|
|
|
|
|
|
|
|
|
|
def make_request( self, url, data, method, _countdown = 5 ):
|
|
|
|
|
url = self.normalize_url( url )
|
|
|
|
|
|
|
|
|
|
method = { 'POST': requests.post,
|
|
|
|
|
'PATCH': requests.patch,
|
|
|
|
|
'GET': requests.get,
|
|
|
|
@ -82,13 +84,17 @@ class APIv2( object ):
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError( request.text )
|
|
|
|
|
|
|
|
|
|
def get_one( self, url, no_d = False ):
|
|
|
|
|
def get_one( self, url, no_d = False, query = None ):
|
|
|
|
|
url = self.normalize_url( url, no_d = no_d, query = query )
|
|
|
|
|
return self.make_request( url, None, 'GET' )
|
|
|
|
|
|
|
|
|
|
def get_many( self, url, count = 10, no_d = False ):
|
|
|
|
|
next = None
|
|
|
|
|
url = self.normalize_url( url, no_d = no_d, query = { 'count': [ count ] } )
|
|
|
|
|
def get_many( self, url, count = 10, no_d = False, query = None ):
|
|
|
|
|
if query is None:
|
|
|
|
|
query = {}
|
|
|
|
|
query[ 'count' ] = [ count ]
|
|
|
|
|
url = self.normalize_url( url, no_d = no_d, query = query )
|
|
|
|
|
|
|
|
|
|
next = None
|
|
|
|
|
while True:
|
|
|
|
|
result = self.make_request( url, None, 'GET' )
|
|
|
|
|
if 'results' in result:
|
|
|
|
|