Global

Members

(constant) req

Source:

(constant) req

Source:

(constant) superagent

module request

Source:

Methods

createContact(name, language, urns, groups, fields) → {Promise}

Create a RapidPro contact

Source:
Parameters:
Name Type Description
name string

Name of RapidPro contact

language string

An ISO6392 language code string

urns array

Array of URNs you want associated with the contact e.g ["tel:+250788123123", "twitter:ben", "facebook:123456789098"]

groups array

Array of rapidpro contact groups to add a user to

fields object

other fields to add to the rapidpro contact

Returns:
Type:
Promise
  • Promise holding a http response object that should have the newly created contact in its body

deleteContact(messengerId, groups, url) → {Promise}

Implement soft user deletion by removing them from the current group and moving them to another group.

Source:
Parameters:
Name Type Description
messengerId Integer

Messenger PSID

groups Array

array of UUIDs of group(s) to move the contact to

url string

set the RapiPro URL. Mainly for testing

Returns:
Type:
Promise
  • Promise holding a http response object that should be of status code 204

getContact(user) → {promise}

GET a rapidpro contact. when a urn is used the response object has the following structure {... results: [contactObject]} when a uuid is used the result is just the contact object

Source:
Parameters:
Name Type Description
user object

{urn, uuid} a urn or uuid used to GET the user, uuid takes precendence

Returns:
Type:
promise
  • Promise holding a http response object that should have a created contact in its body

getGroup(uuid) → {promise}

Get a specific group based on its UUID in RapidPro

Source:
Parameters:
Name Type Description
uuid string

uuid identifying the RapidPro group

Returns:
Type:
promise
  • Promise holding a http response object that should have a RapidPro a group in the body

request(method, url, payload) → {promise}

General http request function that sets content typt and the auth token for RapidPro

Source:
Parameters:
Name Type Description
method string

HTTP request e.g GET, POST, DELETE, PUT

url string

Full url (including query string if needed)

payload object

The data to send to RapidPro (optional)

Returns:
Type:
promise
  • Promise holding a HTTP response object

updateContact(user, payload) → {Promise}

Update a rapidpro contact. When passing a urn RapidPro will create a new contact if there is no contact with that URN.

Source:
Parameters:
Name Type Description
user object

{urn, uuid} object holding either a urn or uuid used to identify the user, uuid takes precendence.

payload object

contact data to update.

Returns:
Type:
Promise
  • Promise holding a http response object that should have the newly updated contact in its body