Skip to content

Commit

Permalink
Resolved the search result response problem. Can reverse easily in th…
Browse files Browse the repository at this point in the history
…e future.
  • Loading branch information
Daniel Greenfeld committed Mar 13, 2015
1 parent 9bbec11 commit 62f349f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 12 additions & 2 deletions eventbrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,24 @@ class Eventbrite(AccessMethodsMixin):

allowed_methods = ['post', 'get', 'delete']
eventbrite_api_url = EVENTBRITE_API_URL
content_type_specified = True

def __init__(self, oauth_token):
self.oauth_token = oauth_token

@property
def headers(self):
return {
headers = {
"Authorization": "Bearer {0}".format(self.oauth_token),
"content-type": "application/json",
"User-Agent": "eventbrite-python-sdk {version} ({system})".format(
version=__version__,
system=platform(),
)
}
# Resolves the search result response problem
if self.content_type_specified:
headers["content-type"] = "application/json"
return headers

def api(self, method, path, data, expansions=()):
method = method.strip().lower()
Expand Down Expand Up @@ -185,6 +189,10 @@ def post_event(self, data):

return self.post("/events/", data=data)

def event_search(self, **data):
# Resolves the search result response problem
self.content_type_specified = False
return self.get("/events/search/", data=data)

def webhook_to_object(self, webhook):
"""
Expand All @@ -208,3 +216,5 @@ def webhook_to_object(self, webhook):
payload = self.get(webhook['api_url'])

return payload


11 changes: 11 additions & 0 deletions tests/integration/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def test_post_event(self):
# Just for access to see the event, not full authentication
self.assertEqual(event['password'], "test")

@unittest.skipIf(condition=skip_user_id_tests, reason='Needs a USER_ID')
@unittest.skipIf(condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
def test_search_events(self):
data = {
'location.latitude':'40.4313684',
'start_date.keyword':'today',
'location.longitude':'-79.9805005',
'location.within':'10km'
}
events = self.eventbrite.event_search(**data)
self.assertLess(events['pagination'][u'object_count'], 1000)

if __name__ == '__main__':
unittest.main()

0 comments on commit 62f349f

Please sign in to comment.