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
5070debd
Commit
5070debd
authored
Oct 20, 2021
by
Pauline Maury Laribière
Browse files
url encoding and ll for i14y
parent
77659e1b
Pipeline
#269064
passed with stage
in 18 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
api_call.R
View file @
5070debd
...
...
@@ -9,7 +9,7 @@ get_codelist <- function(
export_format
=
"SDMX-ML"
,
version_format
=
2.1
,
annotations
=
FALSE
)
{
)
{
api
<-
api_class
(
api_type
=
"codelist"
,
export_format
=
export_format
,
...
...
@@ -77,7 +77,12 @@ get_data_structure(identifier='HCL_NOGA', language='it')
get_nomenclature_path_nodes
<-
function
(
identifier
,
path
=
'.'
,
filters
=
''
,
language
=
'en'
){
get_nomenclature_path_nodes
<-
function
(
identifier
,
path
=
'.'
,
filters
=
''
,
language
=
'en'
){
api
<-
api_class
(
api_type
=
"nomenclature_path_nodes"
,
id
=
identifier
,
...
...
@@ -95,7 +100,74 @@ get_nomenclature_path_nodes(identifier='HCL_CH_ISCO_19_PROF', path='.', filters=
get_nomenclature_one_level
<-
function
(
identifier
,
filters
,
level_number
=
1
,
language
=
'en'
,
annotations
=
FALSE
){
parameters
=
glue
(
"language={language}&level={level_number}&annotations={tolower(annotations)}&{stringify(filters)}"
)
print
(
parameters
)
api
<-
api_class
(
api_type
=
"nomenclature_one_level"
,
id
=
identifier
,
parameters
=
parameters
,
export_format
=
"CSV"
)
api
$
get_response
()
}
get_nomenclature_one_level
(
identifier
=
'HCL_CH_ISCO_19_PROF'
,
filters
=
my_filters
,
level_number
=
2
)
get_nomenclature_multiple_levels
<-
function
(
identifier
,
filters
,
level_from
=
1
,
level_to
=
2
,
language
=
'en'
,
annotations
=
FALSE
){
parameters
=
glue
(
"language={language}&levelFrom={level_from}&levelTo={level_to}&annotations={tolower(annotations)}&{stringify(filters)}"
)
api
<-
api_class
(
api_type
=
"nomenclature_multiple_levels"
,
id
=
identifier
,
parameters
=
parameters
,
export_format
=
"CSV"
)
api
$
get_response
()
###############################################################
# TODO: post processing in R
###############################################################
}
get_nomenclature_multiple_levels
(
identifier
=
'HCL_CH_ISCO_19_PROF'
,
filters
=
my_filters
,
level_from
=
2
,
level_to
=
5
)
query_nomenclature
<-
function
(
identifier
,
query
,
page_number
,
page_size
,
filters
,
language
=
'en'
){
parameters
=
glue
(
"query={URLencode(query)}&page={page_number}&pageSize={page_size}&language={language}&{stringify(filters)}"
)
api
<-
api_class
(
api_type
=
"nomenclature_search"
,
id
=
identifier
,
parameters
=
parameters
)
api
$
get_response
()
}
query_nomenclature
(
identifier
=
'HCL_CH_ISCO_19_PROF'
,
query
=
'SELECT *'
,
page_number
=
5
,
page_size
=
2
,
filters
=
my_filters
)
###############################################################
########################## dcat APIs ##########################
###############################################################
api_class.R
View file @
5070debd
...
...
@@ -101,23 +101,3 @@ api_class <- setRefClass(
}
)
)
api_call
<-
api_class
(
api_type
=
"codelist"
,
export_format
=
"SDMX-ML"
,
parameters
=
"level=1&annotations=true&additionalProp2=string&language=fr"
,
id
=
"CL_NOGA_SECTION"
)
api_call
$
api_url
api_call
$
get_response
()
api_call
<-
api_class
(
api_type
=
"nomenclature_one_level"
,
export_format
=
"CSV"
,
parameters
=
"level=1&annotations=true&additionalProp2=string&language=fr"
,
id
=
"HCL_CH_ISCO_19_PROF"
)
api_call
$
api_url
api_call
$
get_response
()
format_request.R
View file @
5070debd
...
...
@@ -14,4 +14,4 @@ json_request <- function(url) {
csv_request
<-
function
(
url
)
{
read.csv
(
url
)
}
}
\ No newline at end of file
utils.R
0 → 100644
View file @
5070debd
stringify
<-
function
(
filters
)
{
string
=
""
for
(
prop
in
ls
(
filters
))
{
for
(
value
in
filters
[[
prop
]]){
if
(
string
==
""
)
{
string
=
glue
(
"{prop}={value}"
)
}
else
{
string
=
paste
(
string
,
glue
(
"{prop}={value}"
),
sep
=
"&"
)
}
}
}
string
}
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