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 engagements endpoint #92

Open maelle opened 4 years ago

maelle commented 4 years ago

Get all engagements

R script template

#' WIP - Get all engagements (raw and tidy)
#'
#' @description Get all of the engagements in a portal.  Returns a paginated set of engagements. from the [Get all engagements endpoint](https://developers.hubspot.com/docs/methods/engagements/get-all-engagements).
#' @details Required scope(s) for the OAuth token: contacts.
#' @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. Defaults to 100, has a maximum value of 250.
#' @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 use the offset returned in the first request to get the next set of results.
#' @return A list (`hs_engagements_raw()`)
#' @rdname engagements
#' @export
#' @examples
#' \donttest{
#' hs_engagements_raw(o_auth_access_token_or_api_key, limit, offset)
#' }
hs_engagements_raw <- function(o_auth_access_token_or_api_key, limit, offset) {
  path <- "/engagements/v1/engagements/paged"
}
# tidiers -----------------------------------------------------------------
#' @rdname engagements
#' @template engagements
#' @template view
#' @return A tibble with associated entities (`hs_engagements_tidy()`)
#' @export
hs_engagements_tidy <- function(engagements = hs_engagements_raw(),
                               view = "lalalala") {
  # view <- match.arg(view, c('lalalala'))

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

test template

vcr::use_cassette("hs_engagements_raw", {

  test_that("hs_engagements_raw works", {

    expect_is(hs_engagements_raw(), "list")

  })

})