R/gads_last_request_ids.R

Defines functions gads_customer_id_from_env gads_customer_id_to_env gads_last_request_ids

Documented in gads_customer_id_from_env gads_customer_id_to_env gads_last_request_ids

rgoogleads <- new.env(parent = emptyenv())
rgoogleads$last_request_id <- NULL
rgoogleads$customer_id     <- NULL
invisible(rgoogleads)

#' Get last API request ID for Google Ads API support ticket
#'
#' @return Request ID
#' @export
#'
#' @examples
#' \dontrun{
#' gads_last_request_ids()
#' }
gads_last_request_ids <- function() {
  return(rgoogleads$last_request_id)
}

#' Write customer id for error message
#' @param customer_id Your client customer id
#' @return only set customer id into env
gads_customer_id_to_env <- function(customer_id) {
  customer_id <- str_replace_all(customer_id, "-", "") %>%
                 str_replace('(\\d{3})(\\d{3})(\\d{4})', '\\1-\\2-\\3')

  rgoogleads$customer_id <- customer_id
}

#' Get customer id for error message
#'
#' @return only set customer id into env
#'
gads_customer_id_from_env <- function() {
  return(rgoogleads$customer_id)
}

Try the rgoogleads package in your browser

Any scripts or data that you put into this service are public.

rgoogleads documentation built on June 1, 2022, 1:06 a.m.