From 068902877324ade4ccb3c14532c4e5156337833d Mon Sep 17 00:00:00 2001 From: Jacqueline Buros Date: Thu, 13 Jul 2023 11:07:51 -0400 Subject: [PATCH 1/2] use httpcache --- DESCRIPTION | 3 ++- R/geco_api.R | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 183b976..21c3bff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,8 @@ Imports: table1, reticulate, boot, - cli + cli, + httpcache Suggests: testthat, knitr, diff --git a/R/geco_api.R b/R/geco_api.R index 326f3f9..557d016 100644 --- a/R/geco_api.R +++ b/R/geco_api.R @@ -95,6 +95,7 @@ get_auth <- function() { } #' @import httr +#' @improtFrom httpcache GET POST #' @importFrom RJSONIO fromJSON geco_api <- function(path, ..., method = c('GET', 'POST'), project = NULL, project_version_id = NULL, run_id=NULL, type=NULL, parameter=NULL, filters=NULL, url_query_parameters=NULL) { url <- geco_api_url(path, project = project, project_version_id = project_version_id, run_id=run_id, type=type, parameter=parameter, filters=filters, url_query_parameters=url_query_parameters) @@ -103,9 +104,9 @@ geco_api <- function(path, ..., method = c('GET', 'POST'), project = NULL, proje method <- match.arg(method, several.ok = FALSE) if (method == 'GET') - resp <- try(httr::GET(url, ..., get_auth(), ua)) + resp <- try(httpcache::GET(url, ..., get_auth(), ua)) else if (method == 'POST') - resp <- try(httr::POST(url, ..., ua)) + resp <- try(httpcache::POST(url, ..., ua)) #if (httr::http_type(resp) != "application/json") { # stop("API did not return json", call. = FALSE) #} From 7b44deb0bc92ab8f895045207ca88a04c93d0da3 Mon Sep 17 00:00:00 2001 From: Jacqueline Buros Date: Wed, 16 Aug 2023 17:02:01 -0400 Subject: [PATCH 2/2] fix typo --- R/geco_api.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/geco_api.R b/R/geco_api.R index 557d016..e0633d5 100644 --- a/R/geco_api.R +++ b/R/geco_api.R @@ -95,7 +95,7 @@ get_auth <- function() { } #' @import httr -#' @improtFrom httpcache GET POST +#' @importFrom httpcache GET POST #' @importFrom RJSONIO fromJSON geco_api <- function(path, ..., method = c('GET', 'POST'), project = NULL, project_version_id = NULL, run_id=NULL, type=NULL, parameter=NULL, filters=NULL, url_query_parameters=NULL) { url <- geco_api_url(path, project = project, project_version_id = project_version_id, run_id=run_id, type=type, parameter=parameter, filters=filters, url_query_parameters=url_query_parameters)