Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argument encoding in api_get() #246

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
person("Jalal-Edine", "ZAWAM", role = "aut"),
Expand Down
16 changes: 15 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
> Copyright © 2016 RTE Réseau de transport d’électricité

# antaresRead 2.6.1
# 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 :

Expand Down
11 changes: 7 additions & 4 deletions R/API-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions man/API-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading