Skip to content

Commit 75b4098

Browse files
committed
#216 support formatter arg in SDMXREST20RequestBuilder,SDMXREST21RequestBuilder
1 parent b724c69 commit 75b4098

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

R/SDMXREST20RequestBuilder-methods.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#' service repository
1414
#' @param accessKey an object of class "character" indicating the name of request parameter for which
1515
#' an authentication or subscription user key/token has to be provided to perform requests
16+
#' @param formatter an object of class "list" giving a formatting function (for each resource) that
17+
#' takes an object of class "SDMXRequestParams" as single argument. Such parameter allows
18+
#' to customize eventual params (e.g. specific data provider rules)
1619
#' @param compliant an object of class "logical" indicating if the web-service
1720
#' is compliant with the SDMX REST web-service specifications
1821
#' @param unsupportedResources an object of class "list" giving eventual unsupported
@@ -34,20 +37,20 @@
3437
#' repoUrl = "http://www.myorg/repository", compliant = FALSE)
3538
#' @export
3639
#'
37-
SDMXREST20RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, compliant,
40+
SDMXREST20RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL,
41+
formatter = NULL,compliant,
3842
unsupportedResources = list(),
3943
skipProviderId = FALSE, forceProviderId = FALSE,
4044
headers = list()){
4145

4246
#params formatter
43-
formatter = list(
44-
#dataflow
45-
dataflow = function(obj){return(obj)},
46-
#datastructure
47-
datastructure = function(obj){ return(obj)},
48-
#data
49-
data = function(obj){return(obj)}
50-
)
47+
if(is.null(formatter)) formatter = list()
48+
#dataflow
49+
if(is.null(formatter$dataflow)) formatter$dataflow = function(obj){return(obj)}
50+
#datastructure
51+
if(is.null(formatter$datastructure)) formatter$datastructure = function(obj){ return(obj)}
52+
#data
53+
if(is.null(formatter$data)) formatter$data = function(obj){return(obj)}
5154

5255
#resource handler
5356
handler <- list(

R/SDMXREST21RequestBuilder-methods.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#' service repository
1414
#' @param accessKey an object of class "character" indicating the name of request parameter for which
1515
#' an authentication or subscription user key/token has to be provided to perform requests
16+
#' @param formatter an object of class "list" giving a formatting function (for each resource) that
17+
#' takes an object of class "SDMXRequestParams" as single argument. Such parameter allows
18+
#' to customize eventual params (e.g. specific data provider rules)
1619
#' @param compliant an object of class "logical" indicating if the web-service
1720
#' is compliant with the SDMX REST web-service specifications
1821
#' @param unsupportedResources an object of class "list" giving eventual unsupported
@@ -35,20 +38,20 @@
3538
#' compliant = TRUE)
3639
#' @export
3740
#'
38-
SDMXREST21RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, compliant,
41+
SDMXREST21RequestBuilder <- function(regUrl, repoUrl, accessKey = NULL,
42+
formatter = NULL, compliant,
3943
unsupportedResources = list(),
4044
skipProviderId = FALSE, forceProviderId = FALSE,
4145
headers = list()){
4246

4347
#params formatter
44-
formatter = list(
45-
#dataflow
46-
dataflow = function(obj){return(obj)},
47-
#datastructure
48-
datastructure = function(obj){ return(obj)},
49-
#data
50-
data = function(obj){return(obj)}
51-
)
48+
if(is.null(formatter)) formatter = list()
49+
#dataflow
50+
if(is.null(formatter$dataflow)) formatter$dataflow = function(obj){return(obj)}
51+
#datastructure
52+
if(is.null(formatter$datastructure)) formatter$datastructure = function(obj){ return(obj)}
53+
#data
54+
if(is.null(formatter$data)) formatter$data = function(obj){return(obj)}
5255

5356
#resource handler
5457
handler <- list(

man/SDMXREST20RequestBuilder.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/SDMXREST21RequestBuilder.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)