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(.query,
...,
quiet = FALSE,
error_call = rlang::caller_env()){
dots <- list(...)
# get requested url
url_string <- node_config |>
dplyr::filter(.data$type == .query$type &
.data$atlas == .query$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{
# write message
type <- .query$type
atlas <- .query$atlas
# this syntax is cumbersome, but necessary, as cli >3.4.0 doesn't accect
# {.query$type} (no leading dots)
c("No API is available for type `{type}`",
i = "Selected atlas: {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.