ad_table <- function()

in R/ad_data.R [204:237]


ad_table <- function(results, handle_dates = TRUE, censor_access_token = NULL) {
  res <- results$data %>%
    purrr::map(ad_row) %>%
    purrr::transpose() %>%
    purrr::map(unlist) %>%
    as_tibble()


  if (handle_dates) {
    res <- res %>%
      dplyr::mutate_at(vars(
        .data$ad_creation_time, .data$ad_delivery_start_time,
        .data$ad_delivery_stop_time
      ), list(lubridate::as_date))
  }

  # censor access tokens
  if (is.null(censor_access_token)) {
    censor <- TRUE
  } else {
    censor <- censor_access_token
  }

  any_raw_tokens <- any(detect_access_token(res$ad_snapshot_url))
  if (is.null(censor_access_token) & any_raw_tokens) {
    warning("Automatically censoring ad_snapshot_url to remove access_id.\n  To disable this warning, explicitly specify a value for `censor_access_token`.")
  }

  if (("ad_snapshot_url" %in% names(res)) & censor) {
    res$ad_snapshot_url <- censor_access_token(res$ad_snapshot_url)
  }

  res
}