Skip to content

Commit 9a0eb4c

Browse files
authored
Merge pull request #47 from CorrelAid/dev
Dev
2 parents ccc55c5 + bfe2e44 commit 9a0eb4c

File tree

9 files changed

+35
-7
lines changed

9 files changed

+35
-7
lines changed

R/gen_alternative_terms.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ gen_alternative_terms <- function(term = NULL,
2929
database = c("all", "genesis", "zensus", "regio"),
3030
verbose = TRUE,
3131
...) {
32+
3233
caller <- as.character(match.call()[1])
3334

3435
gen_fun <- test_database_function(database,

R/gen_api.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
gen_genesis_api <- function(endpoint,
1919
...) {
2020

21-
url <- "https://www-genesis.destatis.de/genesisWS/rest/2020"
21+
url <- Sys.getenv("RESTATIS_GENESIS_URL")
2222

2323
user_agent <- "https://github.com/CorrelAid/restatis"
2424

@@ -69,7 +69,7 @@ gen_genesis_api <- function(endpoint,
6969
gen_regio_api <- function(endpoint,
7070
...) {
7171

72-
url <- "https://www.regionalstatistik.de/genesisws/rest/2020/"
72+
url <- Sys.getenv("RESTATIS_REGIO_URL")
7373

7474
httr2::request(url) %>%
7575
httr2::req_user_agent("https://github.com/CorrelAid/restatis") %>%
@@ -102,7 +102,7 @@ gen_regio_api <- function(endpoint,
102102
gen_zensus_api <- function(endpoint,
103103
...) {
104104

105-
url <- "https://ergebnisse.zensus2022.de/api/rest/2020"
105+
url <- Sys.getenv("RESTATIS_ZENSUS_URL")
106106

107107
user_agent <- "https://github.com/CorrelAid/restatis"
108108

R/gen_catalogue.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ gen_catalogue <- function(code = NULL,
3636
error.ignore = FALSE,
3737
verbose = TRUE,
3838
...) {
39+
3940
caller <- as.character(match.call()[1])
4041

4142
gen_fun <- test_database_function(database,

R/gen_cube.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ gen_cube_ <- function(name,
7373
classifyingkey3 = NULL,
7474
stand = NULL,
7575
language = Sys.getenv("GENESIS_LANG")) {
76+
7677
area <- match.arg(area)
7778
database <- match.arg(database)
7879

R/gen_find.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ gen_find <- function(term = NULL,
3939
error.ignore = TRUE,
4040
verbose = TRUE,
4141
...) {
42+
4243
caller <- as.character(match.call()[1])
4344

4445
gen_fun <- test_database_function(database,

R/gen_jobs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ gen_list_jobs <- function(database = c("genesis", "regio"),
118118
#' @param database Character string. Indicator if the GENESIS ('genesis') or regionalstatistik.de ('regio') database is called. Only one database can be addressed per function call. Default option is 'genesis'.
119119
#' @param area Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'.
120120
#' @param compress Boolean. Should empty rows and columns be discarded? Default is FALSE.
121-
#' @param language Character string. Defines if the decimal mark and grouping mark of integers should be represented based on the European (e.g.: '100,5', '200.000,5') or American ('100.5', '200,000.5') system. Defaults to 'Sys.getenv("GENESIS_LANG")'.
121+
#' @param language Character string. Defines if the decimal mark and grouping mark of integers should be represented based on the European (e.g.: '100,5', '200.000,5') or American ('100.5', '200,000.5') system. Defaults to 'Sys.getenv("RESTATIS_LANG")'.
122122
#' @param all_character Boolean. Should all variables be imported as 'character' variables? Avoids fuzzy data type conversions if there are leading zeros or other special characters. Defaults to TRUE.
123123
#'
124124
#' @return Returns a data.frame with the table content

R/gen_objects2var.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ gen_objects2var <- function(code = NULL,
3535
error.ignore = FALSE,
3636
verbose = TRUE,
3737
...) {
38+
3839
caller <- as.character(match.call()[1])
3940

4041
gen_fun <- test_database_function(database,

R/utils_httr2.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ resp_check_data <- function(resp) {
223223

224224
if (!(httr2::resp_content_type(resp) %in% c("application/zip", "text/csv", "application/json"))) {
225225

226-
stop("Encountered an invalid response type.",
226+
stop(paste0("Encountered an invalid response type (", httr2::resp_content_type(resp), ")."),
227227
call. = FALSE)
228228

229229
}
230230

231-
return <- httr2::resp_content_type(resp)
231+
return(httr2::resp_content_type(resp))
232232

233233
}
234234

R/zzz.R

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
.onLoad <- function(libname, pkgname) {
22

3+
# Set the functions whose results are to be cached
34
gen_genesis_api <<- memoise::memoise(gen_genesis_api)
45
gen_zensus_api <<- memoise::memoise(gen_zensus_api)
56
gen_regio_api <<- memoise::memoise(gen_regio_api)
67

7-
if (!nzchar(Sys.getenv("GENESIS_LANG"))) Sys.setenv(GENESIS_LANG = "en")
8+
# Set the default language of the package
9+
if (!nzchar(Sys.getenv("GENESIS_LANG"))) Sys.setenv(RESTATIS_LANG = "en")
10+
11+
# Set the default URL for the GENESIS database
12+
if (!nzchar(Sys.getenv("RESTATIS_GENESIS_URL"))) {
13+
14+
Sys.setenv(RESTATIS_GENESIS_URL = "https://www-genesis.destatis.de/genesisWS/rest/2020")
15+
16+
}
17+
18+
# Set the default URL for the www.regionalstatistik.de database
19+
if (!nzchar(Sys.getenv("RESTATIS_REGIO_URL"))) {
20+
21+
Sys.setenv(RESTATIS_REGIO_URL = "https://www.regionalstatistik.de/genesisws/rest/2020/")
22+
23+
}
24+
25+
# Set the default URL for the ZENSUS 2022 database
26+
if (!nzchar(Sys.getenv("RESTATIS_ZENSUS_URL"))) {
27+
28+
Sys.setenv(RESTATIS_ZENSUS_URL = "https://ergebnisse.zensus2022.de/api/rest/2020")
29+
30+
}
831

932
}

0 commit comments

Comments
 (0)