Skip to content

Create a contact in rapid pro #133

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

Merged
merged 2 commits into from
Apr 26, 2022
Merged
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
21 changes: 21 additions & 0 deletions rapid_pro_tools/rapid_pro_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,27 @@ def create_group(self, name):
"""
return self._retry_on_rate_exceed(lambda: self.rapid_pro.create_group(name=name))


def create_contact(self, name=None, language=None, urns=None, contact_fields=None, groups=None):
"""
Creates a new contact in a rapid_pro workspace.

:param name: the full name of the contact
:type name: str | None
:param language: the contact language iso code, e.g. "eng"
:type language: str | None
:param urns: list of URN strings, e.g ['telegram:123456']
:type urns: list | None
:param contact_fields: contact fields to set or update
:type contact_fields: dict of contact_field key -> value | None
:param list groups: list of group objects, UUIDs or names
:type groups: list | None
:return: the new contact
:rtype: temba_client.v2.types.Contact
"""
return self._retry_on_rate_exceed(lambda: self.rapid_pro.create_contact(name=name, language=language, urns=urns,
fields=contact_fields, groups=groups))

@classmethod
def _retry_on_rate_exceed(cls, request):
"""
Expand Down