Nothing
#' Internal function to build APIs
#'
#' This function does a couple of things. Trivially, it looks up
#' base URLs from an internal tibble (`node_config`), itself imported from
#' a csv (`./data-raw/node_config.csv`). Entries in that tibble can contain
#' `glue`-like syntax for infilling new data, passed using `...`.
#'
#' Note that this function is unusual in having a `quiet` arg instead of
#' calling `verbose` via `pour`. This is so the developer can suppress messages
#' independently of user preferences, since this function is often called
#' internally.
#' @noRd
#' @keywords internal
url_lookup <- function(type,
...,
quiet = FALSE,
error_call = rlang::caller_env()){
dots <- list(...)
current_atlas <- potions::pour("atlas", "region")
# get requested url
if(missing(type)){
type <- dots$type
}
url_string <- node_config |>
dplyr::filter(.data$type == {{type}} &
.data$atlas == {{current_atlas}}) |>
dplyr::pull(url)
# parse as needed
if(length(url_string) > 0){
if(length(dots) > 0){
glue::glue_data(dots, url_string) |>
as.character() |>
utils::URLencode()
}else{
url_string |>
utils::URLencode()
}
}else{
if(quiet){
return(NULL)
}else{
c("No API is available for type `{type}`",
i = "Selected atlas: {current_atlas}",
i = "Use `show_all_apis()` to list valid API calls") |>
cli::cli_abort(call = error_call)
}
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.