From e3596d44b469e25925c43107e48e47b586005f2f Mon Sep 17 00:00:00 2001 From: eblondel Date: Thu, 9 Jan 2025 21:36:40 +0100 Subject: [PATCH] #216 formatter inSDMXDotStatRequestBuilder, Rdoc fixes --- DESCRIPTION | 4 ++-- R/SDMXDotStatRequestBuilder-methods.R | 21 ++++++++++++--------- R/SDMXREST20RequestBuilder-methods.R | 2 +- R/SDMXREST21RequestBuilder-methods.R | 2 +- R/SDMXRequestParams-methods.R | 3 ++- README.md | 2 +- man/SDMXDotStatRequestBuilder.Rd | 6 +++++- man/SDMXREST20RequestBuilder.Rd | 2 +- man/SDMXREST21RequestBuilder.Rd | 2 +- man/SDMXRequestParams.Rd | 3 ++- 10 files changed, 28 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6578f12..592c170 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rsdmx -Version: 0.6-4 -Date: 2024-12-16 +Version: 0.6-5 +Date: 2025-01-09 Title: Tools for Reading SDMX Data and Metadata Authors@R: c( person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")), diff --git a/R/SDMXDotStatRequestBuilder-methods.R b/R/SDMXDotStatRequestBuilder-methods.R index 024279c..fb93c27 100644 --- a/R/SDMXDotStatRequestBuilder-methods.R +++ b/R/SDMXDotStatRequestBuilder-methods.R @@ -3,7 +3,7 @@ #' @aliases SDMXDotStatRequestBuilder,SDMXDotStatRequestBuilder-method #' #' @usage -#' SDMXDotStatRequestBuilder(regUrl, repoUrl, accessKey = NULL, +#' SDMXDotStatRequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter = NULL, #' unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, #' headers = list()) #' @@ -11,6 +11,9 @@ #' @param repoUrl an object of class "character" giving the base Url of the SDMX 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 unsupportedResources an object of class "list" giving eventual unsupported #' REST resources. Default is an empty list object #' @param skipProviderId an object of class "logical" indicating that the provider @@ -27,19 +30,19 @@ #' @export #' SDMXDotStatRequestBuilder <- function(regUrl, repoUrl, accessKey = NULL, + formatter = NULL, 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( diff --git a/R/SDMXREST20RequestBuilder-methods.R b/R/SDMXREST20RequestBuilder-methods.R index 8beb1b1..25928c8 100644 --- a/R/SDMXREST20RequestBuilder-methods.R +++ b/R/SDMXREST20RequestBuilder-methods.R @@ -3,7 +3,7 @@ #' @aliases SDMXREST20RequestBuilder,SDMXREST20RequestBuilder-method #' #' @usage -#' SDMXREST20RequestBuilder(regUrl, repoUrl, accessKey = NULL, compliant, +#' SDMXREST20RequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter, compliant, #' unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, #' headers = list()) #' diff --git a/R/SDMXREST21RequestBuilder-methods.R b/R/SDMXREST21RequestBuilder-methods.R index 00f739d..3a89480 100644 --- a/R/SDMXREST21RequestBuilder-methods.R +++ b/R/SDMXREST21RequestBuilder-methods.R @@ -3,7 +3,7 @@ #' @aliases SDMXREST21RequestBuilder,SDMXREST21RequestBuilder-method #' #' @usage -#' SDMXREST21RequestBuilder(regUrl, repoUrl, accessKey = NULL, compliant, +#' SDMXREST21RequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter = NULL, compliant, #' unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, #' headers = list()) #' diff --git a/R/SDMXRequestParams-methods.R b/R/SDMXRequestParams-methods.R index e492ab5..9e5c79b 100644 --- a/R/SDMXRequestParams-methods.R +++ b/R/SDMXRequestParams-methods.R @@ -29,7 +29,8 @@ #' params <- SDMXRequestParams( #' regUrl = "", repoUrl ="", accessKey = NULL, #' providerId = "", agencyId ="", resource = "data", resourceId = "", -#' version = "", flowRef = "", key = NULL, start = NULL, end = NULL, references = NULL, compliant = FALSE +#' version = "", flowRef = "", key = NULL, start = NULL, end = NULL, +#' references = NULL, compliant = FALSE #' ) #' @export #' diff --git a/README.md b/README.md index 27ae41c..d36af3b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://github.com/opensdmx/rsdmx/actions/workflows/r-cmd-check.yml/badge.svg?branch=master)](https://github.com/opensdmx/rsdmx/actions/workflows/r-cmd-check.yml) [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rsdmx)](https://cran.r-project.org/package=rsdmx) [![cran checks](https://badges.cranchecks.info/worst/rsdmx.svg)](https://cran.r-project.org/web/checks/check_results_rsdmx.html) -[![Github_Status_Badge](https://img.shields.io/badge/Github-0.6--4-blue.svg)](https://github.com/opensdmx/rsdmx) +[![Github_Status_Badge](https://img.shields.io/badge/Github-0.6--5-blue.svg)](https://github.com/opensdmx/rsdmx) [![DOI](https://zenodo.org/badge/5183/opensdmx/rsdmx.svg)](https://doi.org/10.5281/zenodo.592404) ``rsdmx``: Tools for reading SDMX data and metadata documents in R diff --git a/man/SDMXDotStatRequestBuilder.Rd b/man/SDMXDotStatRequestBuilder.Rd index 1ab8122..230634e 100644 --- a/man/SDMXDotStatRequestBuilder.Rd +++ b/man/SDMXDotStatRequestBuilder.Rd @@ -8,7 +8,7 @@ \alias{SDMXDotStatRequestBuilder,SDMXDotStatRequestBuilder-method} \title{Class "SDMXDotStatRequestBuilder"} \usage{ -SDMXDotStatRequestBuilder(regUrl, repoUrl, accessKey = NULL, +SDMXDotStatRequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter = NULL, unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, headers = list()) } @@ -20,6 +20,10 @@ SDMXDotStatRequestBuilder(regUrl, repoUrl, accessKey = NULL, \item{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} +\item{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)} + \item{unsupportedResources}{an object of class "list" giving eventual unsupported REST resources. Default is an empty list object} diff --git a/man/SDMXREST20RequestBuilder.Rd b/man/SDMXREST20RequestBuilder.Rd index ef91362..e2ab476 100644 --- a/man/SDMXREST20RequestBuilder.Rd +++ b/man/SDMXREST20RequestBuilder.Rd @@ -8,7 +8,7 @@ \alias{SDMXREST20RequestBuilder,SDMXREST20RequestBuilder-method} \title{Class "SDMXREST20RequestBuilder"} \usage{ -SDMXREST20RequestBuilder(regUrl, repoUrl, accessKey = NULL, compliant, +SDMXREST20RequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter, compliant, unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, headers = list()) } diff --git a/man/SDMXREST21RequestBuilder.Rd b/man/SDMXREST21RequestBuilder.Rd index 9775893..1e59cfc 100644 --- a/man/SDMXREST21RequestBuilder.Rd +++ b/man/SDMXREST21RequestBuilder.Rd @@ -8,7 +8,7 @@ \alias{SDMXREST21RequestBuilder,SDMXREST21RequestBuilder-method} \title{Class "SDMXREST21RequestBuilder"} \usage{ -SDMXREST21RequestBuilder(regUrl, repoUrl, accessKey = NULL, compliant, +SDMXREST21RequestBuilder(regUrl, repoUrl, accessKey = NULL, formatter = NULL, compliant, unsupportedResources = list(), skipProviderId = FALSE, forceProviderId = FALSE, headers = list()) } diff --git a/man/SDMXRequestParams.Rd b/man/SDMXRequestParams.Rd index 0f4e4e1..53aec25 100644 --- a/man/SDMXRequestParams.Rd +++ b/man/SDMXRequestParams.Rd @@ -90,7 +90,8 @@ encapsulate it as slot, when parsing an SDMX-ML document. params <- SDMXRequestParams( regUrl = "", repoUrl ="", accessKey = NULL, providerId = "", agencyId ="", resource = "data", resourceId = "", - version = "", flowRef = "", key = NULL, start = NULL, end = NULL, references = NULL, compliant = FALSE + version = "", flowRef = "", key = NULL, start = NULL, end = NULL, + references = NULL, compliant = FALSE ) } \author{