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 tickets endpoint #96

Open maelle opened 4 years ago

maelle commented 4 years ago

Get all tickets

R script template

#' WIP - Get all tickets (raw and tidy)
#'
#' @description Get all tickets from a portal, up to 100 per request. from the [Get all tickets endpoint](https://developers.hubspot.com/docs/methods/tickets/get-all-tickets).
#' @details Required scope(s) for the OAuth token: tickets.
#' @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  offset ADD TO A TEMPLATE Used to get the next set of results. Check the value of hasMore in the response to see if there are more tickets to get. If hasMore is true, you use the returned offset value in the &offset= parameter of the next request to get the next set of records.
#' @template  ticket_properties ADD TO A TEMPLATE By default, only the ID and a few other system fields are returned for the tickets. You can include ticket properties in the response by requesting them in the URL. This parameter can be included multiple times to request multiple properties. See the example for more details.
#' @template  ticket_properties_with_history ADD TO A TEMPLATE This parameter behaves exactly like the properties parameter above, with the exception that properties included with this parameter also return the full version history for the property.
#' @return A list (`hs_tickets_raw()`)
#' @rdname tickets
#' @export
#' @examples
#' \donttest{
#' hs_tickets_raw(o_auth_access_token_or_api_key, offset, ticket_properties, ticket_properties_with_history)
#' }
hs_tickets_raw <- function(o_auth_access_token_or_api_key, offset, ticket_properties, ticket_properties_with_history) {
  path <- "GET  /crm-objects/v1/objects/tickets/paged"
}
# tidiers -----------------------------------------------------------------
#' @rdname tickets
#' @template tickets
#' @template view
#' @return A tibble with associated entities (`hs_tickets_tidy()`)
#' @export
hs_tickets_tidy <- function(tickets = hs_tickets_raw(),
                           view = "lalalala") {
  # view <- match.arg(view, c('lalalala'))

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

test template

vcr::use_cassette("hs_tickets_raw", {

  test_that("hs_tickets_raw works", {

    expect_is(hs_tickets_raw(), "list")

  })

})
maelle commented 4 years ago

Not sure where the ticket properties would come from (Hubspot knowledge maybe... there is apparently no ticket properties endpoint like the contact properties endpoint).

cspenn commented 4 years ago

It's in beta, apparently.

https://developers.hubspot.com/docs-beta/crm/tickets