From a9427347625419a7310c0119e46e67ffd18f0837 Mon Sep 17 00:00:00 2001 From: Jon Harmon Date: Sun, 10 May 2026 11:11:51 -0500 Subject: [PATCH] Clean up `resp_parse()` and `resp_tidy()` - Use `httr2::resp_request()` - Clean up fall-through. --- DESCRIPTION | 2 +- R/resp_tidy.R | 12 ++---------- tests/testthat/_snaps/resp_tidy.md | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 649515f..7baec68 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ Imports: curl, fs, glue, - httr2 (>= 1.0.0), + httr2 (>= 1.1.0), jsonlite, lifecycle, purrr, diff --git a/R/resp_tidy.R b/R/resp_tidy.R index 13a674c..e193c11 100644 --- a/R/resp_tidy.R +++ b/R/resp_tidy.R @@ -40,9 +40,7 @@ resp_tidy <- function(resps) { #' @export resp_tidy.httr2_response <- function(resps) { - # TODO: Replace this with httr2::resp_request() after - # https://github.com/r-lib/httr2/pull/615 - req <- resps$request + req <- httr2::resp_request(resps) if (length(req$policies$resp_tidy)) { return( rlang::exec( @@ -66,13 +64,7 @@ resp_tidy.list <- function(resps) { class(resps) <- c("nectar_responses", "list") return(resp_tidy(resps)) } - .nectar_abort( - c( - "No method is available to {.fn nectar::resp_tidy} this object.", - i = "You might want to try {.fn nectar::resp_parse} instead." - ), - "unsupported_response_class" - ) + NextMethod() } #' @export diff --git a/tests/testthat/_snaps/resp_tidy.md b/tests/testthat/_snaps/resp_tidy.md index 5566ad1..c6d35c1 100644 --- a/tests/testthat/_snaps/resp_tidy.md +++ b/tests/testthat/_snaps/resp_tidy.md @@ -18,5 +18,5 @@ Error in `resp_tidy()`: ! No method is available to `nectar::resp_tidy()` this object. - i You might want to try `nectar::resp_parse()` instead. + i `nectar::resp_tidy()` expects objects, or lists thereof.