Skip to content

Instantly share code, notes, and snippets.

@csgillespie
Created Sep 28, 2017
Embed
What would you like to do?
Testing rtypeform
api = rtypeform::get_api(api_key)
url = paste0("https://api.typeform.com/v1/form/", uid, "?key=", api)
## Form the REST URL & query
url = paste0(url, rtypeform:::get_order_by(NULL))
ua = httr::user_agent("https://github.com/csgillespie/rtypeform")
resp = httr::GET(url, ua)
cont = httr::content(resp, "text")
rtypeform:::check_api_response(resp)
parsed = jsonlite::fromJSON(cont, simplifyVector = FALSE)
## Extract questions
questions = purrr::map_df(parsed$questions, purrr::flatten_df)
## Extract completed
q_keep = purrr::keep(parsed$responses, ~.$completed == 1)
completed = purrr::map_df(q_keep, purrr::flatten_df)
completed = rtypeform:::check_empty(completed, questions)
## Extract non-completed
q_keep = purrr::keep(parsed$responses, ~.$completed == 0)
uncompleted = purrr::map_df(q_keep, purrr::flatten_df)
uncompleted = rtypeform:::check_empty(uncompleted, NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment