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 marketing emails endpoint #95

Open maelle opened 4 years ago

maelle commented 4 years ago

Get all marketing emails

R script template

#' WIP - Get all marketing emails (raw and tidy)
#'
#' @description Get all marketing emails for a HubSpot account. from the [Get all marketing emails endpoint](https://developers.hubspot.com/docs/methods/cms_email/get-all-marketing-emails).
#' @details Required scope(s) for the OAuth token: content.
#' @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 in the response. Defaults to 10
#' @template  offset ADD TO A TEMPLATE Used to get the next page of results. Use the limit of the previous request as the offset to get the next set of results.
#' @template  order_by ADD TO A TEMPLATE Return the emails ordered by a particular field value. Use a negative value to sort in descending order (e.g. orderBy=-created).
#' @return A list (`hs_marketing_emails_raw()`)
#' @rdname marketing-emails
#' @export
#' @examples
#' \donttest{
#' hs_marketing_emails_raw(o_auth_access_token_or_api_key, limit, offset, order_by)
#' }
hs_marketing_emails_raw <- function(o_auth_access_token_or_api_key, limit, offset, order_by) {
  path <- "GET /marketing-emails/v1/emails"
}
# tidiers -----------------------------------------------------------------
#' @rdname marketing-emails
#' @template marketing_emails
#' @template view
#' @return A tibble with associated entities (`hs_marketing_emails_tidy()`)
#' @export
hs_marketing_emails_tidy <- function(marketing_emails = hs_marketing_emails_raw(),
                                    view = "lalalala") {
  # view <- match.arg(view, c('lalalala'))

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

test template

vcr::use_cassette("hs_marketing_emails_raw", {

  test_that("hs_marketing_emails_raw works", {

    expect_is(hs_marketing_emails_raw(), "list")

  })

})