Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination support #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions eventbrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_user(self, user_id=None):
return self.get('/users/{0}/'.format(user_id))
return self.get('/users/me/')

def get_user_orders(self, user_id=None, changed_since=None):
def get_user_orders(self, user_id=None, changed_since=None, page=None):
"""
Returns a paginated response of orders, under the key orders, of all
orders the user has placed (i.e. where the user was the person buying
Expand All @@ -116,6 +116,8 @@ def get_user_orders(self, user_id=None, changed_since=None):
to get current user.
:param datetime changed_since: (optional) Only return attendees changed
on or after the time given
:param int page: (optional) Since the response is paginated then this
allows you to specify which page to fetch.

.. note:: A datetime represented as a string in ISO8601 combined date
and time format, always in UTC.
Expand All @@ -128,20 +130,33 @@ def get_user_orders(self, user_id=None, changed_since=None):
data = {}
if changed_since:
data['changed_since'] = changed_since
if page:
data['page'] = page
return self.get(url, data=data)

def get_event_attendees(self, event_id, status=None, changed_since=None):
def get_event_attendees(self, event_id, status=None, changed_since=None, page=None):
"""
Returns a paginated response with a key of attendees, containing a
list of attendee.

GET /events/:id/attendees/

:param status: (optional)
:param datetime changed_since: (optional) Only return attendees changed
on or after the time given
:param int page: (optional) Since the response is paginated then this
allows you to specify which page to fetch.

.. note:: A datetime represented as a string in ISO8601 combined date
and time format, always in UTC.
"""
data = {}
if status: # TODO - check the types of valid status
data['status'] = status
if changed_since:
data['changed_since'] = changed_since
if page:
data['page'] = page
return self.get("/events/{0}/attendees/".format(event_id), data=data)

def get_event_attendee_by_id(self, event_id, attendee_id):
Expand All @@ -150,28 +165,40 @@ def get_event_attendee_by_id(self, event_id, attendee_id):
"""
return self.get("/events/{0}/attendees/{1}/".format(event_id, attendee_id))

def get_event_ticket_classes(self, event_id):
def get_event_ticket_classes(self, event_id, page=None):
"""
Returns a paginated response with a key of ticket_classes, containing
a list of ticket_class.

GET /events/:id/ticket_classes/

:param int page: (optional) Since the response is paginated then this
allows you to specify which page to fetch.
"""
return self.get("/events/{0}/ticket_classes/".format(event_id))
data = {}
if page:
data['page'] = page
return self.get("/events/{0}/ticket_classes/".format(event_id), data=data)

def get_event_ticket_class_by_id(self, event_id, ticket_class_id):
"""
GET /events/:id/ticket_classes/:id/
"""
return self.get("/events/{0}/ticket_classes/{1}/".format(event_id, ticket_class_id))

def get_event_discounts(self, event_id):
def get_event_discounts(self, event_id, page=None):
"""
Returns a paginated response with a key of discounts, containing a list of discount.

GET /events/:id/discounts/

:param int page: (optional) Since the response is paginated then this
allows you to specify which page to fetch.
"""
return self.get("/events/{0}/discounts/".format(event_id))
data = {}
if page:
data['page'] = page
return self.get("/events/{0}/discounts/".format(event_id), data=data)

def post_event_discount(
self, event_id,
Expand Down