try:
self.organization_id = self._get_organization_id()
except (KeyError, IndexError, AttributeError) as exc:
print(self.token, exc)
self.organization_id = None
def is_legacy_user(self):
return not bool(self.organization_id)
def _get_organization_id(self):
api_response = get(
self.base_url + 'users/me/organizations/',
headers=self.base_headers()
)
if not api_response.ok:
raise EventbriteAPIException('Getting organization information failed')
return api_response.json()['organizations'][0]['id']
def post_ticket_classes_to_event(self, event_id, **kwargs):
if self.is_legacy_user():
return self.post_ticket_classes_to_event_legacy(self, event_id, **kwargs)
path = '{base_url}events/{event_id}/ticket_classes/'.format(base_url=self.base_url, event_id=event_id)
headers = self.base_headers()
headers.update(kwargs.pop('headers', {}))
params = kwargs.pop('params', {})
return post(
path,
headers=headers,
params=params,
**kwargs
)