Skip to content

Commit

Permalink
introduce ... to more functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yannikbuhl committed Jan 2, 2025
1 parent 9736b65 commit 5596bab
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 18 deletions.
3 changes: 3 additions & 0 deletions R/gen_cube.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#' updated after this date.}
#' \item{\code{language}}{Character string. Search terms, returned messages and data
#' descriptions in German (`"de"`) or English (`"en"`)?}
#' \item{\code{...}}{Additional parameters for the API call (see respective API documentation).
#' A valid specification of these will not be checked by the function, so wrongful specification
#' may lead to errors.}
#' }
#'
#' @return A [tibble][tibble::tibble()]. Non-data contents of the data cube object are saved in
Expand Down
10 changes: 8 additions & 2 deletions R/gen_logincheck.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' gen_logincheck
#'
#' @description Function to check if a login is possible for a certain database.
#'
#' @param database Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Only one database can be addressed per function call. Default option is 'genesis'.
#' @param verbose Boolean. In case of success, should a message be printed? Defaults to FALSE.
#' @param ... Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see `vignette("additional_parameter")`.
#'
#' @return Leads to an informative error message if the login check failed and returns FALSE invisibly. Invisibly returns TRUE otherwise.
#' @export
Expand All @@ -12,8 +14,12 @@
#' gen_logincheck("zensus")
#' }
#'
gen_logincheck <- function(database, verbose = FALSE) {
gen_logincheck <- function(database,
verbose = FALSE,
...) {

logincheck_http_error(database, verbose)
logincheck_http_error(database,
verbose,
...)

}
3 changes: 3 additions & 0 deletions R/gen_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#' \item{\code{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.}
#' \item{\code{...}}{Additional parameters for the API call (see respective API documentation).
#' A valid specification of these will not be checked by the function, so wrongful specification
#' may lead to errors.}
#' }
#'
#' @return A [tibble][tibble::tibble()].
Expand Down
19 changes: 11 additions & 8 deletions R/utils_httr2.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,13 @@ return_table_object <- function(response,
#'
#' @param database The user input to 'gen_logincheck'
#' @param verbose Boolean. Should the function message in case of success?
#' @param ... Additional parameters (unchecked)
#'
#' @return Informative error/warning messages + invisibly TRUE/FALSE
#'
logincheck_http_error <- function(database,
verbose) {
verbose,
...) {

#-----------------------------------------------------------------------------

Expand All @@ -439,7 +441,8 @@ logincheck_http_error <- function(database,
#---------------------------------------------------------------------------

response <- gen_api(endpoint = "helloworld/logincheck",
database = database)
database = database,
...)

logincheck_stop_or_warn(response = response,
error = TRUE,
Expand All @@ -452,9 +455,9 @@ logincheck_http_error <- function(database,

databases <- list("genesis", "zensus", "regio")

response_list <- list(response_genesis = gen_api(endpoint = "helloworld/logincheck", database = "genesis"),
response_zensus = gen_api(endpoint = "helloworld/logincheck", database = "zensus"),
response_regio = gen_api(endpoint = "helloworld/logincheck", database = "regio"))
response_list <- list(response_genesis = gen_api(endpoint = "helloworld/logincheck", database = "genesis", ...),
response_zensus = gen_api(endpoint = "helloworld/logincheck", database = "zensus", ...),
response_regio = gen_api(endpoint = "helloworld/logincheck", database = "regio", ...))

purrr::walk2(.x = response_list,
.y = databases,
Expand All @@ -478,7 +481,7 @@ logincheck_http_error <- function(database,

if ("genesis" %in% database) {

logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "genesis"),
logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "genesis", ...),
error = FALSE,
verbose = verbose,
database = "genesis")
Expand All @@ -489,7 +492,7 @@ logincheck_http_error <- function(database,

if ("zensus" %in% database) {

logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "zensus"),
logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "zensus", ...),
error = FALSE,
verbose = verbose,
database = "zensus")
Expand All @@ -500,7 +503,7 @@ logincheck_http_error <- function(database,

if ("regio" %in% database) {

logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "regio"),
logincheck_stop_or_warn(response = gen_api(endpoint = "helloworld/logincheck", database = "regio", ...),
error = FALSE,
verbose = verbose,
database = "regio")
Expand Down
18 changes: 18 additions & 0 deletions man/dot-gen_api_core.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_alternative_terms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_catalogue.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_cube.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion man/gen_list_jobs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/gen_logincheck.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_modified_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_objects2stat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_objects2var.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gen_search_vars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/gen_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gen_val2var.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gen_val2var2stat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gen_var2stat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/logincheck_http_error.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5596bab

Please sign in to comment.