Contacts API Client¶
-
class
go_http.contacts.
ContactsApiClient
(auth_token, api_url=None, session=None)¶ Client for Vumi Go’s contacts API.
Parameters: - auth_token (str) – An OAuth 2 access token. NOTE: This will be replaced by a proper authentication system at some point.
- api_url (str) – The full URL of the HTTP API. Defaults to
https://go.vumi.org/api/v1/go
. - session (
requests.Session
) – Requests session to use for HTTP requests. Defaults to a new session.
-
contacts
(start_cursor=None)¶ Retrieve all contacts.
This uses the API’s paginated contact download.
Parameters: start_cursor – An optional parameter that declares the cursor to start fetching the contacts from. Returns: An iterator over all contacts.
-
create_contact
(contact_data)¶ Create a contact.
Parameters: contact_data (dict) – Data for new contact.
-
create_group
(group_data)¶ Create a group.
Parameters: group_data (dict) – Data for new group.
-
delete_contact
(contact_key)¶ Delete a contact.
Parameters: contact_key (str) – Key for the contact to delete.
-
delete_group
(group_key)¶ Delete a group.
Parameters: group_key (str) – Key for the group to delete.
-
get_contact
(*args, **kw)¶ Get a contact. May either be called as
.get_contact(contact_key)
to get a contact from its key, or.get_contact(field=value)
, to get the contact from an address fieldfield
having a valuevalue
.- Contact key example:
- contact = api.get_contact(‘abcdef123456’)
- Field/value example:
- contact = api.get_contact(msisdn=’+12345’)
Parameters: - contact_key (str) – Key for the contact to get.
- field (str) –
field
is the address field that is searched on (e.g.msisdn
,twitter_handle
). The value offield
is the value to search for (e.g.+12345
, @foobar`).
-
get_group
(group_key)¶ Get a group
Parameters: group_key (str) – Key for the group to get
-
group_contacts
(group_key, start_cursor=None)¶ Retrieve all group contacts.
This uses the API’s paginated contact download.
Parameters: - group_key (str) – Key for the group to query.
- start_cursor – An optional parameter that declares the cursor to start fetching the contacts from.
Returns: An iterator over all group contacts.
-
update_contact
(contact_key, update_data)¶ Update a contact.
Parameters: - contact_key (str) – Key for the contact to update.
- update_data (dict) – Fields to modify.
-
update_group
(group_key, update_data)¶ Update a group.
Parameters: - group_key (str) – Key for the group to update.
- update_data (str) – Fields to modify.