Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DSCC
FSO Metadata Auto R
Commits
c1f9ee17
Commit
c1f9ee17
authored
Oct 26, 2021
by
Pauline Maury Laribière
Browse files
adding language for api
parent
3229456c
Pipeline
#271531
passed with stage
in 3 minutes and 5 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
install.R
View file @
c1f9ee17
...
...
@@ -8,4 +8,7 @@ library(methods)
library
(
glue
)
library
(
httr
)
library
(
jsonlite
)
library
(
rsdmx
)
\ No newline at end of file
library
(
rsdmx
)
# pkgload::load_all('my_package')
# styler::style_pkg('my_package')
\ No newline at end of file
my_package/R/api_call.R
View file @
c1f9ee17
...
...
@@ -10,6 +10,7 @@
#' @return response based on the export format
#' @export
get_codelist
<-
function
(
identifier
,
language
=
"en"
,
export_format
=
"SDMX-ML"
,
version_format
=
2.1
,
annotations
=
FALSE
)
{
...
...
@@ -19,7 +20,7 @@ get_codelist <- function(identifier,
parameters
=
glue
::
glue
(
"annotations={tolower(annotations)}"
),
id
=
identifier
)
api
$
get_response
()
dplyr
::
select
(
api
$
get_response
()
,
contains
(
language
)
|
matches
(
"id"
))
}
...
...
my_package/R/api_class.R
View file @
c1f9ee17
...
...
@@ -9,10 +9,10 @@
#' @field language character (default = "en"). The language of the response data.
#' Available are 'fr', 'de', 'it', 'en'
#' @field version_format numeric (default = 2.1). The export format's version
#' (2.0 or 2.1 when format is SDMX-ML)
#' (2.0 or 2.1 when format is SDMX-ML)
#' (for 'codelist')
#' @field api_url character. The url to make the request to.
#'
#'
#' @importFrom methods new
api_class
<-
setRefClass
(
"Api"
,
...
...
@@ -38,7 +38,7 @@ api_class <- setRefClass(
parameters
=
parameters
,
id
=
id
,
language
=
language
,
version_format
=
version_format
,
version_format
=
version_format
)
get_url
(
id
,
export_format
,
version_format
,
language
)
},
...
...
@@ -60,7 +60,7 @@ api_class <- setRefClass(
"nomenclature_one_level"
=
glue
::
glue
(
"Nomenclatures/{id}/levelexport/CSV"
),
"nomenclature_multiple_levels"
=
glue
::
glue
(
"Nomenclatures/{id}/multiplelevels/CSV"
)
,
glue
::
glue
(
"Nomenclatures/{id}/multiplelevels/CSV"
)
)
api_url
<<-
url_mapping
[[
api_type
]]
}
...
...
my_package/R/format_request.R
View file @
c1f9ee17
...
...
@@ -54,4 +54,4 @@ hash_to_string <- function(filters) {
}
}
string
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment