-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* formatting_api_params rewrite * added helpers * removed lifecycle svgs from man directory
- Loading branch information
1 parent
42d9b3c
commit 5bb18bd
Showing
19 changed files
with
570 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' Encode API parameters as a URL | ||
#' | ||
#' "%22" url encoding for double quote (") | ||
#' | ||
#' @param x tibble with two columns: `param` and `args` | ||
#' | ||
#' @param fmt format type, `filter`, `sql`, default is `filter` | ||
#' | ||
#' @returns formatted URL string | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @noRd | ||
format_api_params <- function(x, fmt = "filter") { | ||
|
||
x <- purrr::discard(params, is_null) | ||
|
||
fmt <- match.arg(fmt, c("filter", "sql")) | ||
|
||
x <- switch( | ||
fmt, | ||
filter = paste0( | ||
paste0("filter[", names(x), "]=", x), collapse = "&"), | ||
sql = paste0( | ||
paste0("[WHERE ", names(x), " = %22", x, "%22]" ), collapse = "")) | ||
|
||
x <- gsub(" ", "%20", x) | ||
x <- gsub("[", "%5B", x, fixed = TRUE) | ||
x <- gsub("*", "%2A", x, fixed = TRUE) | ||
x <- gsub("]", "%5D", x, fixed = TRUE) | ||
x <- gsub("<", "%3C", x, fixed = TRUE) | ||
x <- gsub("+", "%2B", x, fixed = TRUE) | ||
|
||
return(x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.