Skip to content

Commit

Permalink
rename per_page to size and expose after
Browse files Browse the repository at this point in the history
  • Loading branch information
mustberuss committed Oct 30, 2024
1 parent 21533b4 commit 5d2a244
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 0 additions & 2 deletions R/process-resp.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ get_query_results <- function(prsd_resp) {

#' @noRd
process_resp <- function(resp) {
# prsd_resp <- resp |> httr2::resp_body_json()

prsd_resp <- parse_resp(resp)
request <- get_request(resp)
data <- get_data(prsd_resp)
Expand Down
16 changes: 8 additions & 8 deletions R/search-pv.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ tojson_2 <- function(x, ...) {

#' @noRd
to_arglist <- function(fields, size, sort, after) {
opts = list(size = size)
if(after != "") {
opts$after = after
opts <- list(size = size)
if (!is.null(after)) {
opts$after <- after
}

list(
Expand Down Expand Up @@ -159,13 +159,13 @@ get_default_sort <- function(endpoint) {
#' @param mtchd_subent_only `r lifecycle::badge("deprecated")` This is always
#' FALSE in the new version of the API as non-matched subentities
#' will always be returned.
#' @param page `r lifecycle::badge("deprecated")` The new version of the API does not use
#' @param page `r lifecycle::badge("deprecated")` The new version of the API does not use
#' \code{page} as a parameter for paging, it uses \code{after}.
#' @param per_page `r lifecycle::badge("deprecated")` The API now uses \code{size}
#' @param size The number of records that should be returned per page. This
#' value can be as high as 1,000 (e.g., \code{size = 1000}).
#' @param after Exposes the API's paging parameter for users who want to implement their own
#' custom paging. It cannot be set when \code{all_pages = TRUE} as the R package manipulates it
#' custom paging. It cannot be set when \code{all_pages = TRUE} as the R package manipulates it
#' for users automatically.
#' @param all_pages Do you want to download all possible pages of output? If
#' \code{all_pages = TRUE}, the value of \code{size} is ignored.
Expand All @@ -179,7 +179,7 @@ get_default_sort <- function(endpoint) {
#' Possible values include "GET" or "POST". Use the POST method when
#' your query is very long (say, over 2,000 characters in length).
#' @param error_browser `r lifecycle::badge("deprecated")`
#' @param api_key API key, it defaults to Sys.getenv("PATENTSVIEW_API_KEY"). Request a key
#' @param api_key API key, it defaults to Sys.getenv("PATENTSVIEW_API_KEY"). Request a key
#' \href{https://patentsview.org/apis/keyrequest}{here}.
#' @param ... Curl options passed along to httr2's \code{\link[httr2]{req_options}}
#' when we do GETs or POSTs.
Expand Down Expand Up @@ -251,7 +251,7 @@ search_pv <- function(query,
page,
per_page,
size = 1000,
after = "",
after = NULL,
all_pages = FALSE,
sort = NULL,
method = "GET",
Expand Down Expand Up @@ -391,7 +391,7 @@ retrieve_linked_data <- function(url,
}

if (!is.null(url_peices$query$o)) {
params$opts = jsonlite::fromJSON(sub(".*o=([^&]*).*", "\\1", url))
params$opts <- jsonlite::fromJSON(sub(".*o=([^&]*).*", "\\1", url))
}

query <- if (!is.null(url_peices$query$q)) sub(".*q=([^&]*).*", "\\1", url) else ""
Expand Down
6 changes: 3 additions & 3 deletions R/validate-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ validate_endpoint <- function(endpoint) {
}

#' @noRd
validate_args <- function(api_key, fields, endpoint, method,
validate_args <- function(api_key, fields, endpoint, method,
sort, after, size, all_pages) {
asrt(
!identical(api_key, ""),
Expand Down Expand Up @@ -52,8 +52,8 @@ validate_args <- function(api_key, fields, endpoint, method,
}

asrt(
any(after == "", !all_pages),
"after cannot be set when all_pages = TRUE"
any(is.null(after), !all_pages),
"'after' cannot be set when all_pages = TRUE"
)
}

Expand Down

0 comments on commit 5d2a244

Please sign in to comment.