Implement a function that takes ids for a database, measures and fields and sends a json request. Here is a snippet on how to do that manually at the moment
# pick a dataset
db_id <- "detouextregsai"
db_schema <- sc_schema_db(db_id)
db_uid <- paste0("str:database:", db_id)
# browse the schema to obtain resource ids
id_arrivals <- db_schema$Facts$Arrivals$Arrivals$id
id_time <- db_schema$`Mandatory fields`$`Season/Tourism Month`$`Season/Tourism Month`$id
# get the response
json_list <- list(database = db_uid, measures = list(id_arrivals), dimensions = list(list(id_time)))
response <- httr::POST(
url = paste0(STATcubeR:::base_url, "/table"),
body = jsonlite::toJSON(json_list, auto_unbox = TRUE),
encode = "raw",
config = httr::add_headers(APIKey = sc_key())
)
# convert to class sc_table
my_table <- STATcubeR:::sc_table_class$new(response)
Implement a function that takes ids for a database, measures and fields and sends a json request. Here is a snippet on how to do that manually at the moment
Transofm this snippet into a function