-
Notifications
You must be signed in to change notification settings - Fork 0
/
MECAPA_API.R
33 lines (31 loc) · 1.11 KB
/
MECAPA_API.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#' Retrieve data from the capacity market public registry
#'
#' @param ressource name of the ressource to call in the API. Choices are
#' describe in API documentation on the website
#' <http://www.data.rte-france.com>
#' @param sandbox logical. `TRUE` to call the sandbox URL for testing
#' @param refresh lofical. `TRUE` to allow refresh.
#'
#' @family API-calls
#'
#' @export
RegistreAPI <- function(ressource = NULL, sandbox = T, refresh = T){
registre_path <- "certified_capacities_registry/v1"
if (sandbox) registre_path <- file.path(registre_path, "sandbox")
if (is.null(ressource)) {
if (!interactive()) {
stop("ressource is missing", call. = F)
} else {
cat("which ressource do you want to access in the API \"", dirname(registre_path),"\"?", sep = "")
choices <- c(
"ncc_greater_equal_100_mw",
"ncc_less_100_mw"
)
nb <- utils::menu(choices)
if (nb == 0) stop("No ressource selected.", call. = F)
ressource <- choices[nb]
}
}
ressource_path <- file.path(registre_path, ressource)
call_api(ressource_path = ressource_path, refresh = refresh)
}