Add photo list filters
This commit is contained in:
parent
76f27a7dbb
commit
e904a629f9
3 changed files with 36 additions and 4 deletions
|
@ -9,14 +9,17 @@ from .api_base import ApiBase
|
|||
|
||||
class ApiPhotos(ApiBase):
|
||||
""" Definitions of /photos/ API endpoints """
|
||||
# TODO: Add options
|
||||
def list(self, **kwds):
|
||||
def list(self, filters=None, **kwds):
|
||||
"""
|
||||
Endpoint: /photos/list.json
|
||||
Endpoint: /photos/[<filters>]/list.json
|
||||
|
||||
Returns a list of Photo objects.
|
||||
The filters parameter can be used to narrow down the list.
|
||||
Eg: filters={"album": <album_id>}
|
||||
"""
|
||||
photos = self._client.get("/photos/list.json", **kwds)["result"]
|
||||
filter_string = self._build_filter_string(filters)
|
||||
photos = self._client.get("/photos/%slist.json" % filter_string,
|
||||
**kwds)["result"]
|
||||
photos = self._result_to_list(photos)
|
||||
return [Photo(self._client, photo) for photo in photos]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue