Skip to content

Commit

Permalink
Custom .multi for legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
ldecicco-USGS committed Nov 25, 2024
1 parent 29ecfcb commit 9ce4776
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
15 changes: 8 additions & 7 deletions R/constructNWISURL.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ constructWQPURL <- function(siteNumbers,

if(legacy){
baseURL <- httr2::request(pkg.env[["Result"]])
siteNumbers <- paste(siteNumbers, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = siteNumbers)
siteid = siteNumbers,
.multi = function(x) paste0(x, collapse = ";"))
baseURL <- httr2::req_url_query(baseURL,
count = "no")
} else {
Expand All @@ -324,13 +324,14 @@ constructWQPURL <- function(siteNumbers,
}

if(legacy & !allPCode){
if (multiplePcodes) {
parameterCd <- paste(parameterCd, collapse = ";")
}
if(pCodeLogic){
baseURL <- httr2::req_url_query(baseURL, pCode = parameterCd)
baseURL <- httr2::req_url_query(baseURL,
pCode = parameterCd,
.multi = function(x) paste0(x, collapse = ";"))
} else {
baseURL <- httr2::req_url_query(baseURL, characteristicName = parameterCd)
baseURL <- httr2::req_url_query(baseURL,
characteristicName = parameterCd,
.multi = function(x) paste0(x, collapse = ";"))
}

} else if(!legacy & !allPCode){
Expand Down
4 changes: 2 additions & 2 deletions R/readWQPdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ readWQPdata <- function(...,
if("siteid" %in% names(values)){
if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}
}
Expand Down
12 changes: 6 additions & 6 deletions R/whatWQPdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ whatWQPsamples <- function(...,
if("siteid" %in% names(values)){
if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}
}
Expand Down Expand Up @@ -103,9 +103,9 @@ whatWQPmetrics <- function(...,
if("siteid" %in% names(values)){
if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}
}
Expand Down Expand Up @@ -203,9 +203,9 @@ whatWQPdata <- function(...,
if("siteid" %in% names(values)){
if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}
}
Expand Down
8 changes: 4 additions & 4 deletions R/whatWQPsites.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ whatWQPsites <- function(..., legacy = TRUE, convertType = TRUE) {
if("siteid" %in% names(values)){
if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}
}
Expand Down Expand Up @@ -162,9 +162,9 @@ readWQPsummary <- function(...) {

if(length(values[["siteid"]]) > 1){
sites <- values[["siteid"]]
sites <- paste0(sites, collapse = ";")
baseURL <- httr2::req_url_query(baseURL,
siteid = sites)
siteid = sites,
.multi = function(x) paste0(x, collapse = ";"))
values <- values[names(values) != "siteid"]
}

Expand Down

0 comments on commit 9ce4776

Please sign in to comment.