BASE_URL <- "https://content.guardianapis.com"
.get_key <- function() {
key <- Sys.getenv("GUARDIAN_API_KEY")
assert_that(nchar(key) > 1, msg = "Missing key, see `guardian_key`")
return(key)
}
.construct_call <- function(calls){
assert_that(!missing(calls), msg = "Missing calls")
structure(calls, class = c(class(calls), "guardianCalls"))
}
.build_calls <- function(..., pages = 1, endpoint = "search") {
parsed_url <- parse_url(BASE_URL)
parsed_url$path <- endpoint
query <- list(..., `api-key` = .get_key())
calls <- seq(pages) %>%
map(function(p){
query$page <- p
parsed_url$query <- query
build_url(parsed_url)
}) %>%
map(function(x){
list(
call = x,
endpoint = endpoint
)
})
.construct_call(calls)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.