DoubleYouGTT / hubspot

R package πŸ“¦ for working with Hubspot πŸ‘©β€πŸ’ΌπŸ‘¨β€πŸ’Ό data
https://itsalocke.com/hubspot/
Other
10 stars 8 forks source link

Add support for Get all forms from a portal endpoint #93

Open maelle opened 4 years ago

maelle commented 4 years ago

Get all forms from a portal

R script template

#' WIP - Get all forms from a portal (raw and tidy)
#'
#' @description For a given portal, return all forms that have been created in the portal. from the [Get all forms from a portal endpoint](https://developers.hubspot.com/docs/methods/forms/v2/get_forms).
#' @details Required scope(s) for the OAuth token: none.
#' @template token_path
#' @template apikey
#' @template  o_auth_access_token_or_api_key ADD TO A TEMPLATE Used to authenticate the request. Please see this page for more details about authentication.
#' @template  limit ADD TO A TEMPLATE The number of records to return. Has no default; if ommitted, all forms are returned.
#' @template  offset ADD TO A TEMPLATE Used to page through the results. If there are more records in your portal than the limit= parameter, you will need to include an offset equal to the number of forms you've already requested. For example, if your first request specified limit=10, your next request should include limit=10&offset=10. The request after that should include limit=10&offset=20, and so on and so forth.
#' @template  form_types ADD TO A TEMPLATE By default non-marketing forms are filtered out of this endpoint. To request all forms, use this paramter with the value of ALL (case sensitive)
#' @return A list (`hs_forms_from_a_portal_raw()`)
#' @rdname forms-from-a-portal
#' @export
#' @examples
#' \donttest{
#' hs_forms_from_a_portal_raw(o_auth_access_token_or_api_key, limit, offset, form_types)
#' }
hs_forms_from_a_portal_raw <- function(o_auth_access_token_or_api_key, limit, offset, form_types) {
  path <- " /forms/v2/forms"
}
# tidiers -----------------------------------------------------------------
#' @rdname forms-from-a-portal
#' @template forms_from_a_portal
#' @template view
#' @return A tibble with associated entities (`hs_forms_from_a_portal_tidy()`)
#' @export
hs_forms_from_a_portal_tidy <- function(forms_from_a_portal = hs_forms_from_a_portal_raw(),
                                       view = "lalalala") {
  # view <- match.arg(view, c('lalalala'))

  # switch(view,
  #       'lalalala' = blabla)
}

test template

vcr::use_cassette("hs_forms_from_a_portal_raw", {

  test_that("hs_forms_from_a_portal_raw works", {

    expect_is(hs_forms_from_a_portal_raw(), "list")

  })

})