From ebb6ae55d070061cd1b5dd03c76e48bc3449331c Mon Sep 17 00:00:00 2001 From: kemihak Date: Thu, 25 Apr 2024 11:04:51 +0200 Subject: [PATCH 1/3] Update DESCRIPTION and NEWS.md files --- DESCRIPTION | 2 +- NEWS.md | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 33f7e461..6224560f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: antaresRead Type: Package Title: Import, Manipulate and Explore the Results of an 'Antares' Simulation -Version: 2.6.1 +Version: 2.6.2 Authors@R: c( person("Tatiana", "Vargas", email = "tatiana.vargas@rte-france.com", role = c("aut", "cre")), person("Jalal-Edine", "ZAWAM", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 4cd70501..2ba2a1fe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,20 @@ > Copyright © 2016 RTE Réseau de transport d’électricité -# antaresRead 2.6.1 (devlopment) +# antaresRead 2.6.2 (development) + +NEW FEATURES : +* `api_get()` add encoding argument to pass to `httr::content()` + +BUGFIXES : + +BREAKING CHANGES : + +DATA : + +PERFORMANCE : + + +# antaresRead 2.6.1 BUGFIXES : From e2f040ecbed66888f52ee09304e074cb0a89cb96 Mon Sep 17 00:00:00 2001 From: kemihak Date: Thu, 25 Apr 2024 11:05:15 +0200 Subject: [PATCH 2/3] Add encoding argument to api_get() --- R/API-methods.R | 11 +++++++---- man/API-methods.Rd | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/R/API-methods.R b/R/API-methods.R index d97e0e98..49319bca 100644 --- a/R/API-methods.R +++ b/R/API-methods.R @@ -6,6 +6,7 @@ #' @param ... Additional arguments passed to API method. #' @param default_endpoint Default endpoint to use. #' @param parse_result `character` options for parameter `as` of function [httr::content()] +#' @param encoding argument to pass as argument to the function [httr::content()] #' @param opts Antares simulation options or a `list` with an `host = ` slot. #' #' @return Response from the API. @@ -24,16 +25,18 @@ #' endpoint = NULL, #' parse_result = NULL) #' -#' # you can force parse options as text +#' # you can force parse options as text and encoding to UTF-8 #' api_get(opts = list(host = "http://0.0.0.0:8080"), #' endpoint = NULL, -#' parse_result = "text") +#' parse_result = "text", +#' encoding = "UTF-8") #' #' } api_get <- function(opts, endpoint, ..., default_endpoint = "v1/studies", - parse_result = NULL) { + parse_result = NULL, + encoding = NULL) { if (inherits(endpoint, "AsIs")) { opts$host <- endpoint endpoint <- NULL @@ -74,7 +77,7 @@ api_get <- function(opts, stop_for_status(result, task = mess_error) }else warn_for_status(result) - content(result, as = parse_result) + content(result, as = parse_result, encoding = encoding) } #' @export diff --git a/man/API-methods.Rd b/man/API-methods.Rd index 0a15a5b8..a7cdb52c 100644 --- a/man/API-methods.Rd +++ b/man/API-methods.Rd @@ -13,7 +13,8 @@ api_get( endpoint, ..., default_endpoint = "v1/studies", - parse_result = NULL + parse_result = NULL, + encoding = NULL ) api_post(opts, endpoint, ..., default_endpoint = "v1/studies") @@ -33,6 +34,8 @@ Can be a full URL (by wrapping ìn \code{\link[=I]{I()}}), in that case \code{de \item{default_endpoint}{Default endpoint to use.} \item{parse_result}{\code{character} options for parameter \code{as} of function \code{\link[httr:content]{httr::content()}}} + +\item{encoding}{\code{character} options for parameter \code{encoding} of function \code{\link[httr:content]{httr::content()}}} } \value{ Response from the API. From 9487038020ce1119c783581d05c9683f3e61755d Mon Sep 17 00:00:00 2001 From: kemihak Date: Thu, 25 Apr 2024 11:10:14 +0200 Subject: [PATCH 3/3] update documentation --- man/API-methods.Rd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/man/API-methods.Rd b/man/API-methods.Rd index a7cdb52c..4a69b2de 100644 --- a/man/API-methods.Rd +++ b/man/API-methods.Rd @@ -35,7 +35,7 @@ Can be a full URL (by wrapping ìn \code{\link[=I]{I()}}), in that case \code{de \item{parse_result}{\code{character} options for parameter \code{as} of function \code{\link[httr:content]{httr::content()}}} -\item{encoding}{\code{character} options for parameter \code{encoding} of function \code{\link[httr:content]{httr::content()}}} +\item{encoding}{argument to pass as argument to the function \code{\link[httr:content]{httr::content()}}} } \value{ Response from the API. @@ -52,10 +52,11 @@ api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, parse_result = NULL) -# you can force parse options as text +# you can force parse options as text and encoding to UTF-8 api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, - parse_result = "text") + parse_result = "text", + encoding = "UTF-8") } }