View source: R/get_user_data.R
get_user_data | R Documentation |
This function retrieves contact data from RapidPro for each user. It is a wrapper function around get_data_from_rapidpro_api
and allows for filtering and formatting of the returned data.
get_user_data(
rapidpro_site = get_rapidpro_site(),
token = get_rapidpro_key(),
call_type = "contacts.json",
filter_variable = "group",
filter_variable_value = "joined",
flatten = FALSE,
date_from = NULL,
date_to = NULL,
format_date = "%Y-%m-%d",
tzone_date = "UTC",
unlist_consent = FALSE
)
rapidpro_site |
A string containing the RapidPro website URL from which to retrieve the data. Use |
token |
A string containing the API token required for authentication. Use |
call_type |
A string specifying the type of data call. The default is |
filter_variable |
A string specifying the variable used to filter the data. The default is |
filter_variable_value |
A string specifying the value of |
flatten |
Logical, default is |
date_from |
A character string representing the start date to filter the data from. The date format should match |
date_to |
A character string representing the end date to filter the data to. The date format should match |
format_date |
A character string specifying the date-time format, as used by |
tzone_date |
A character string specifying the time zone for date conversion. The default is |
unlist_consent |
Logical, default is |
This function builds the API call to retrieve user data from RapidPro, with optional filtering by group and date. The retrieved data can be flattened into a simple data frame, and optional date filters can be applied. If unlist_consent
is set to TRUE
, variables containing "consent" will be unlisted to simplify the structure.
A data frame containing the contact data from RapidPro, filtered and formatted according to the specified parameters.
#\dontrun{
## Set the RapidPro site and API key
#set_rapidpro_site("https://app.rapidpro.io")
#set_rapidpro_key("your_api_key")
#
# # Get data for users in the "joined" group
# user_data <- get_user_data(call_type = "contacts.json", filter_variable = "group", filter_variable_value = "joined")
#
# # Get data for users in the "joined" group, filtering by date range
# user_data <- get_user_data(call_type = "contacts.json", filter_variable = "group", filter_variable_value = "joined", date_from = "2023-01-01", date_to = "2023-12-31")
# }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.