Files
notifications-admin/app/notify_client/events_api_client.py
Chris Hill-Scott fa5e5475e9 Update Python client
Just so that nobody else has to do it.

Implements:
- [x] https://github.com/alphagov/notifications-python-client/pull/29

Which is a breaking change requiring the renaming of method arguments.
2016-09-08 15:55:07 +01:00

22 lines
836 B
Python

from notifications_python_client.base import BaseAPIClient
class EventsApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
self.api_key = app.config['ADMIN_CLIENT_SECRET']
def create_event(self, event_type, event_data):
data = {
'event_type': event_type,
'data': event_data
}
resp = self.post(url='/events', data=data)
return resp['data']