-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added paging functionality to the user_api (get_user_transactions, ge…
…t_user_friends_list, and others).
- Loading branch information
Showing
12 changed files
with
88 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
class JSONSchema: | ||
|
||
@staticmethod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class Page(list): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.method = None | ||
self.kwargs = {} | ||
self.current_offset = -1 | ||
|
||
def set_method(self, method, kwargs, current_offset=-1): | ||
""" | ||
set the method and kwargs for paging. current_offset is provided for routes that require offset. | ||
:param method: | ||
:param kwargs: | ||
:param current_offset: | ||
:return: | ||
""" | ||
self.method = method | ||
self.kwargs = kwargs | ||
self.current_offset = current_offset | ||
return self | ||
|
||
def get_next_page(self): | ||
""" | ||
Get the next page of data. Returns empty Page if none exists | ||
:return: | ||
""" | ||
if not self.kwargs or not self.method or len(self) == 0: | ||
return self.__init__() | ||
|
||
# use offset or before_id for paging, depending on the route | ||
if self.current_offset > -1: | ||
self.kwargs['offset'] = self.current_offset + len(self) | ||
else: | ||
self.kwargs['before_id'] = self[-1].id | ||
|
||
return self.method(**self.kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters