Skip to content

Commit

Permalink
#216 support formatter arg in SDMXREST20RequestBuilder,SDMXREST21Requ…
Browse files Browse the repository at this point in the history
…estBuilder
  • Loading branch information
eblondel committed Jan 9, 2025
1 parent b724c69 commit 75b4098
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
21 changes: 12 additions & 9 deletions R/SDMXREST20RequestBuilder-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#' service repository
#' @param accessKey an object of class "character" indicating the name of request parameter for which
#' an authentication or subscription user key/token has to be provided to perform requests
#' @param formatter an object of class "list" giving a formatting function (for each resource) that
#' takes an object of class "SDMXRequestParams" as single argument. Such parameter allows
#' to customize eventual params (e.g. specific data provider rules)
#' @param compliant an object of class "logical" indicating if the web-service
#' is compliant with the SDMX REST web-service specifications
#' @param unsupportedResources an object of class "list" giving eventual unsupported
Expand All @@ -34,20 +37,20 @@
#' repoUrl = "http://www.myorg/repository", compliant = FALSE)
#' @export
#'
SDMXREST20RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, compliant,
SDMXREST20RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL,
formatter = NULL,compliant,
unsupportedResources = list(),
skipProviderId = FALSE, forceProviderId = FALSE,
headers = list()){

#params formatter
formatter = list(
#dataflow
dataflow = function(obj){return(obj)},
#datastructure
datastructure = function(obj){ return(obj)},
#data
data = function(obj){return(obj)}
)
if(is.null(formatter)) formatter = list()
#dataflow
if(is.null(formatter$dataflow)) formatter$dataflow = function(obj){return(obj)}
#datastructure
if(is.null(formatter$datastructure)) formatter$datastructure = function(obj){ return(obj)}
#data
if(is.null(formatter$data)) formatter$data = function(obj){return(obj)}

#resource handler
handler <- list(
Expand Down
21 changes: 12 additions & 9 deletions R/SDMXREST21RequestBuilder-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#' service repository
#' @param accessKey an object of class "character" indicating the name of request parameter for which
#' an authentication or subscription user key/token has to be provided to perform requests
#' @param formatter an object of class "list" giving a formatting function (for each resource) that
#' takes an object of class "SDMXRequestParams" as single argument. Such parameter allows
#' to customize eventual params (e.g. specific data provider rules)
#' @param compliant an object of class "logical" indicating if the web-service
#' is compliant with the SDMX REST web-service specifications
#' @param unsupportedResources an object of class "list" giving eventual unsupported
Expand All @@ -35,20 +38,20 @@
#' compliant = TRUE)
#' @export
#'
SDMXREST21RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, compliant,
SDMXREST21RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL,
formatter = NULL, compliant,
unsupportedResources = list(),
skipProviderId = FALSE, forceProviderId = FALSE,
headers = list()){

#params formatter
formatter = list(
#dataflow
dataflow = function(obj){return(obj)},
#datastructure
datastructure = function(obj){ return(obj)},
#data
data = function(obj){return(obj)}
)
if(is.null(formatter)) formatter = list()
#dataflow
if(is.null(formatter$dataflow)) formatter$dataflow = function(obj){return(obj)}
#datastructure
if(is.null(formatter$datastructure)) formatter$datastructure = function(obj){ return(obj)}
#data
if(is.null(formatter$data)) formatter$data = function(obj){return(obj)}

#resource handler
handler <- list(
Expand Down
4 changes: 4 additions & 0 deletions man/SDMXREST20RequestBuilder.Rd

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

4 changes: 4 additions & 0 deletions man/SDMXREST21RequestBuilder.Rd

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

0 comments on commit 75b4098

Please sign in to comment.