Skip to content

Commit

Permalink
Add .multi param to req_url_query()
Browse files Browse the repository at this point in the history
  • Loading branch information
asadow committed Dec 6, 2023
1 parent add0a40 commit 4836548
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ name: Style
jobs:
style:
runs-on: ubuntu-latest
permissions:
contents: write
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion R/modify.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ mm_req_params <- function(req, ..., allfields = TRUE) {
check_bool(allfields)
params <- format_params(...)
if (allfields) params <- c(params, "ALLFIELDS" = 1)
httr2::req_url_query(req, !!!params)
httr2::req_url_query(req, !!!params, .multi = "comma")
}
2 changes: 1 addition & 1 deletion R/utils-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ check_params <- function(x, call = rlang::caller_env()) {
))
}

return(x)
return()
}

# Is httr2_request
Expand Down
26 changes: 7 additions & 19 deletions R/utils-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @description
#' `format_params()` formats supplied name-value pairs toward
#' creating a valid Megamation URL.
#' creating a valid and readable Megamation URL.
#' @inheritParams mm_req_params
#' @returns A list of parameter name-value pairs.
#' @keywords internal
Expand All @@ -17,27 +17,15 @@ format_params <- function(...) {
if (rlang::is_empty(params)) {
return(params)
}
params <- check_params(params)

if ("date" %in% names(params)) {
check_params(params)
names(params) <- toupper(names(params))
if ("DATE" %in% names(params)) {
## Do not in-line date o.w. when check_date() errors: "params$date must be"
date <- params$date
date <- params$DATE
check_date(date)
params$date <- format_date(date)
params$DATE <- format_date(date)
}

names(params) <- toupper(names(params))

max_length <- purrr::map_dbl(params, length) |> max()

valid_list <- 1:max_length |>
purrr::map(\(x) purrr::map(params, x)) |>
purrr::flatten() |>
purrr::compact() |>
purrr::map(as.character) |>
purrr::map(I)

valid_list[order(names(valid_list))]
return(params)
}

#' Format date values
Expand Down
2 changes: 1 addition & 1 deletion man/format_params.Rd

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

0 comments on commit 4836548

Please sign in to comment.