Skip to content

Commit

Permalink
version 1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin authored and cran-robot committed Apr 7, 2024
1 parent b14a4b0 commit 62cd04f
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 62 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
@@ -1,12 +1,12 @@
Package: Rapi
Type: Package
Title: Interface for Multiple Data Providers 'EDDS' and 'FRED'
Version: 1.0.4
Date: 2024-02-19
Version: 1.0.5
Date: 2024-04-06
Authors@R: c(
person("Sermet", "Pekin", , "sermetpekin@gmail.com", role = c("aut", "cre" , "cph"))
person("Sermet", "Pekin", , "sermet.pekin@gmail.com", role = c("aut", "cre" , "cph"))
)
Maintainer: Sermet Pekin <sermetpekin@gmail.com>
Maintainer: Sermet Pekin <sermet.pekin@gmail.com>
URL: https://github.com/DataRapi/Rapi, https://DataRapi.github.io/Rapi/
BugReports: https://github.com/DataRapi/Rapi/issues
Description: Interface for multiple data sources, such as the
Expand All @@ -31,7 +31,7 @@ RoxygenNote: 7.3.1
Encoding: UTF-8
Config/testthat/edition: 3
NeedsCompilation: yes
Packaged: 2024-02-23 04:32:22 UTC; sermetpekin
Packaged: 2024-04-06 16:15:56 UTC; sermetpekin
Author: Sermet Pekin [aut, cre, cph]
Repository: CRAN
Date/Publication: 2024-02-26 16:20:09 UTC
Date/Publication: 2024-04-06 23:43:04 UTC
42 changes: 25 additions & 17 deletions MD5
@@ -1,47 +1,47 @@
f3cfe3f6808152f7fd932c9f9a5fb89a *DESCRIPTION
e992e124b4a33bc1735295d79c2e3144 *DESCRIPTION
c676e2fb21044d09ed71a9d722bb280a *LICENSE
ea848e3c9d847ee089e93ac311e61cb6 *NAMESPACE
146b8f7751d82c44835164c48236e3d6 *NEWS.md
f27e7a7d544f5c2cd666dea823655e9f *NEWS.md
eea626d4d859e839794e96cd91ab331b *R/00_a_Rapi_name_space.R
8557b08c3939f6d1f4fdd6e91d8ae370 *R/00_cache.R
3b79750bf1f78131ff0106ed489c8c83 *R/00_cache_export.R
25b1057ae4fce01098b69c815245360d *R/00_globals.R
a5dcb0880b72c3e4ff5de77328377133 *R/00_verbose.R
cd7aaf6375eb68adc788937976f59e03 *R/00_vyos_utils.R
972408c0965ea5cf7e5ab7fd606ac205 *R/01_sp_utils.R
27bee502f1ba6177bdc6b2a175f2b1e0 *R/01_sp_utils.R
70738552daecae55fe1d9698f29adfea *R/API_list.R
22f82a3109743276268b7ca6b99d7b51 *R/RcppExports.R
5538b5a5af0b703b82a9b4cee96eef2e *R/api_keys.R
d6d44c7eacee64a550229b7b62a15a68 *R/RcppExports.R
a434b469fa8bf2051d07e9dc9c8e5b7f *R/api_keys.R
e6c4b502eb64f34bb63426c8d3332a12 *R/checks_data.R
5bf90ec3c17da6b5bee922dbe58012de *R/colors.R
26979bd33eab46fed1e948c5c4441dc5 *R/evds_forward.R
c677bd03fed57b78495c73aaffbf9e81 *R/evds_table_api.R
5d593524ff3ac3db044aa1520416fb6f *R/evds_forward.R
1daacbc23eb91312c91bd3ba611bd70d *R/evds_table_api.R
d9b9260ad9e8eac1b848c33c3448db34 *R/examples_for_build_step.R
90d73a9f4c08c6c0c7b85781539da9f1 *R/excel.R
c3b604721eccf0b36805dccaf6cd1a40 *R/excel_internal.R
ae761784b52f6748bb496a3650344f2a *R/generics.R
536d30946fa727f62fecbd3579fb7149 *R/excel_internal.R
0895beeea27f37e1d80dbe0aade985ff *R/generics.R
1032070e152c7cc33c0601b22c320568 *R/get_data_api_abstract.R
8796f873aed3e031d2e2ab3159c3b874 *R/get_lines_index.R
107124a03b83cb886793cded457586a5 *R/get_series.R
6f0168eec047030bf153660a9e76be3d *R/get_series_export.R
1676e01e2033d83bd9d4323ce58199cd *R/internal_evds.R
6233ce83575faf733a8adaf7cebf6e8b *R/internal_evds.R
bb4f3eae797f67317b8abce18f05dcd6 *R/internal_fred.R
9e5c8a28a6ee101954f1f128a030ba6d *R/lag_df.R
8925747feeecb8517b90cad159797b7c *R/messages.R
77076eecb194fdd4c93099a97d9b65d5 *R/post_process_data.R
e75978e17ceda2a7bbdb183beffe486d *R/post_process_data.R
bed5fbc28cc65c586ffd561514e0192d *R/request_cache_funcs.R
0a5da8f3b3a3b2013c6a82276ab62c43 *R/request_checks.R
81223879e8d2240b745434f2d0d7a4e6 *R/request_errors.R
4039e6afc9909ca2f20312264557cb58 *R/request_funcs.R
c2200603d6c5ab80634096774c7fd3ca *R/request_funcs.R
462cf9173cc998b8095f411bdbc8137f *R/request_prepare.R
8934855eddc0368c42b1c23d3143b16b *R/request_wait_times.R
17aec03a8bd1702d4ad7ef78fdf2b7d8 *R/response_evds.R
b74c4af50007d8b353adc00f8501dfa2 *R/response_evds.R
e9a39b4af0c1d9446ffac52db4eac4e7 *R/response_evds2.R
623543c9f917aaee992852aeb46bedd3 *R/response_funcs.R
f447d6e8dbca020ad86263afc047d0b2 *R/sp_df_utils.R
a7bb6458b3570b59ab7ee98053222f38 *R/response_funcs.R
9b9b82aa76751ecfbe50af682282b838 *R/sp_df_utils.R
3899c73bb978353f25d543d934dc6dc2 *R/sp_op_utils.R
7803195a4c75b269a72a87b23559fee9 *R/z_testing_f.R
4e0e688212dcaef9aecc45acd2435807 *README.md
29a7393e2b16b68d6fd3b7a4d27affc7 *README.md
ffe01b5bdff319445011de2f05b8caf0 *man/Rapi-build-checks.Rd
eb020884cdf1dac40ab24fdd214fab87 *man/change_cache_folder.Rd
e4fe841411dc949f7478610a1936e26c *man/excel.Rd
Expand All @@ -59,13 +59,21 @@ b3fd562d8135eb2f75da08ef15375086 *man/verbose_off.Rd
8d82498d25addc5aae9d6bb3f61f4344 *man/verbose_on.Rd
1e08452e735bd22859a4efb6b35accf9 *src/Rapi.h
76ccc68b0c851bcd5dc48546c37c282c *src/RcppExports.cpp
e33d79003889d19b18238deece308c99 *src/sp_df.cpp
4704f40e6650ee0ea398e8afd0f2ca73 *src/sp_df.cpp
39f80eb51056439dff211730437e2a16 *src/sp_df_bridge.cpp
b62e65323892a7d85e953d4086d6e49e *tests/testthat.R
6fba3baf097f68e344f114276b3e10eb *tests/testthat/caches_Rapi/0edfb96425ca0841082054975994159b_2024_14_CACHE.RData
dcd126ba0978b8e2b69beb94958cc659 *tests/testthat/caches_Rapi/0edfb96425ca0841082054975994159b_2024_8_CACHE.RData
30bbaa8e739e703ab4787c6126622a1a *tests/testthat/caches_Rapi/0edfb96425ca0841082054975994159b_2024_9_CACHE.RData
e4402ab9d755945ce8b1f0e4c8ae72a4 *tests/testthat/caches_Rapi/28e64743469b182c516544244dbf7bed_2024_14_CACHE.RData
04bd96604afcf4a8e3dfba05d2d5d35a *tests/testthat/caches_Rapi/28e64743469b182c516544244dbf7bed_2024_8_CACHE.RData
60623497c5013f25d061374445dc2fa8 *tests/testthat/caches_Rapi/28e64743469b182c516544244dbf7bed_2024_9_CACHE.RData
4a98331764b79674f237ae3fae286a68 *tests/testthat/caches_Rapi/3d4dc283b1b4c53f5aba5057bf787a63_2024_14_CACHE.RData
d07fd6d1cd01a62a031b3e0c275b215f *tests/testthat/caches_Rapi/3d4dc283b1b4c53f5aba5057bf787a63_2024_8_CACHE.RData
d07fd6d1cd01a62a031b3e0c275b215f *tests/testthat/caches_Rapi/3d4dc283b1b4c53f5aba5057bf787a63_2024_9_CACHE.RData
7e57177d2d50e3710d4e31653cd0f657 *tests/testthat/caches_Rapi/56cf7bda13139d113fde8412f5baa875_2024_14_CACHE.RData
5323d75ab173cfdb5f46ea0972e51a83 *tests/testthat/caches_Rapi/56cf7bda13139d113fde8412f5baa875_2024_8_CACHE.RData
f647c8c97ef6fca09e9506196ec9d709 *tests/testthat/caches_Rapi/56cf7bda13139d113fde8412f5baa875_2024_9_CACHE.RData
76a8723162340e39696d6fe5f76a123e *tests/testthat/caches_Rsearch/0edfb96425ca0841082054975994159b_2024_8_CACHE.RData
e31310f95559696e91301f3a443bc08d *tests/testthat/caches_Rsearch/28e64743469b182c516544244dbf7bed_2024_8_CACHE.RData
608bb731f1ffd3be683772fbff210a17 *tests/testthat/caches_Rsearch/3d4dc283b1b4c53f5aba5057bf787a63_2024_8_CACHE.RData
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,3 +1,6 @@
# Rapi 1.0.5
* Moved key parameter to the header for the source `EVDS`.

# Rapi 1.0.4
* Deleted a few development related verbose functions.

Expand Down
2 changes: 0 additions & 2 deletions R/01_sp_utils.R
@@ -1,4 +1,3 @@

get_hash <- function(n = 50) {
a <- do.call(paste0, replicate(3, sample(LETTERS, n, TRUE), FALSE))
paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE))
Expand Down Expand Up @@ -59,7 +58,6 @@ assign_ <- function(name, data) {
hash_func <- function(v) {
g <- paste0(v, collapse = "_")
digest::digest(g)

}

g <- glue::glue
Expand Down
9 changes: 4 additions & 5 deletions R/RcppExports.R
Expand Up @@ -2,18 +2,17 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

as_tibblex <- function(df) {
.Call(`_Rapi_as_tibblex`, df)
.Call(`_Rapi_as_tibblex`, df)
}

lag_df_c <- function(df2, lag_list) {
.Call(`_Rapi_lag_df_c`, df2, lag_list)
.Call(`_Rapi_lag_df_c`, df2, lag_list)
}

lag_df2_c <- function(df2, lag_list) {
.Call(`_Rapi_lag_df2_c`, df2, lag_list)
.Call(`_Rapi_lag_df2_c`, df2, lag_list)
}

remove_column_cpp <- function(df, column) {
.Call(`_Rapi_remove_column_cpp`, df, column)
.Call(`_Rapi_remove_column_cpp`, df, column)
}

2 changes: 1 addition & 1 deletion R/api_keys.R
Expand Up @@ -17,7 +17,7 @@ check_connection_google <- function() {
check_web_connection("https://www.google.com")
}
check_connection_documentation <- function() {
check_web_connection("https://spRapi.github.io/Rapi/")
check_web_connection("https://datarapi.github.io/Rapi/")
}

check_list_connections <- function(verbose = TRUE) {
Expand Down
18 changes: 13 additions & 5 deletions R/evds_forward.R
Expand Up @@ -14,18 +14,26 @@ create_evds_url <- function(type = c(
api_key_evds <- get_api_key("evds")
}
g <- glue::glue

# liste <- list(
# subject = g("{domain}/categories/key={api_key_evds}&type=json"),
# datagroups = g("{domain}/datagroups/key={api_key_evds}&mode=2&code={subject_num}&type=json"),
# info_api = g("{domain}/serieList/key={api_key_evds}&type=json&code={table_name}")
# )

liste <- list(
subject = g("{domain}/categories/key={api_key_evds}&type=json"),
datagroups = g("{domain}/datagroups/key={api_key_evds}&mode=2&code={subject_num}&type=json"),
info_api = g("{domain}/serieList/key={api_key_evds}&type=json&code={table_name}")
subject = g("{domain}/categories/type=json"),
datagroups = g("{domain}/datagroups/mode=2&code={subject_num}&type=json"),
info_api = g("{domain}/serieList/type=json&code={table_name}")
)

liste[[type]]
}

get_evds_table_names_with_subject_num <- function(subject_num = 5,
cache = F) {
url <- create_evds_url("datagroups", subject_num)
response <- request_httr2_helper(url, cache)
response <- request_httr2_helper_evds(url, cache)
if (!is_response(response)) {
return(false)
}
Expand All @@ -38,7 +46,7 @@ get_evds_table_names_with_subject_num <- function(subject_num = 5,
# ....................................................... get_evds_table_info_api
get_evds_subject_list_api <- function(cache = T) {
url <- create_evds_url("subject")
response <- request_httr2_helper(url, cache)
response <- request_httr2_helper_evds(url, cache)
if (!is_response(response)) {
return(false)
}
Expand Down
2 changes: 1 addition & 1 deletion R/evds_table_api.R
Expand Up @@ -86,7 +86,7 @@ get_evds_table_info_api <- function(table_name = "bie_altingr", cache = T) {
url <- create_evds_url("info_api",
table_name = table_name
)
gelen <- request_httr2_helper(url, cache)
gelen <- request_httr2_helper_evds(url, cache)
if (!is_response(gelen)) {
return(false)
}
Expand Down
2 changes: 0 additions & 2 deletions R/excel_internal.R
Expand Up @@ -43,12 +43,10 @@ excel_internal <- function(
return(invisible(1))
}
if (!inherits(dfs, "list") && !inherits(dfs, "data.frame")) {

message_func("excel function requires data.frame or list of data.frames(1)")
return(invisible(1))
}
if (!len(dfs)) {

message_func("excel function requires data.frame or list of data.frames(2)")
return(invisible(2))
}
Expand Down
3 changes: 2 additions & 1 deletion R/generics.R
Expand Up @@ -55,6 +55,7 @@ combine_df <- function(x, ...) {
df
}
combine_dfs_by_date2 <- function(liste) {

combined <- NULL
for (item in liste) {
item2 <- item
Expand Down Expand Up @@ -116,7 +117,7 @@ get_data_all <- function(x) {

DATA <- post_process_data_main(DATA, x)

if (is.null(DATA)) {
if (is.null(DATA) || isFALSE(DATA)) {
data.[[row]] <- "null"
} else {
data.[[row]] <- DATA
Expand Down
2 changes: 1 addition & 1 deletion R/internal_evds.R
@@ -1,6 +1,6 @@
quick_check_evds <- function(key = "..") {
url <- create_evds_url("subject", key = key)
gelen <- request_httr2_helper(url, cache = F)
gelen <- request_httr2_helper_evds(url, cache = F)
if (!is_response(gelen)) {
return(false)
}
Expand Down
2 changes: 1 addition & 1 deletion R/post_process_data.R
@@ -1,5 +1,5 @@
limit_years_of_data <- function(.data, dots_params) {
if (is.null(.data)) {
if (is.null(.data)|| isFALSE(.data)) {
return(null)
}

Expand Down
95 changes: 83 additions & 12 deletions R/request_funcs.R
Expand Up @@ -12,8 +12,9 @@ request_httr <- function(currentObj) {
}
request_httr2 <- function(currentObj) {
# evds
Rapi_env$currentObj <- currentObj
url <- createUrlForSeries(currentObj)
request_httr2_helper(url, currentObj$cache)
request_httr2_helper_evds(url, currentObj$cache)
}
seriesCollapse <- function(liste) {
names_ <- names(liste)
Expand Down Expand Up @@ -86,7 +87,7 @@ get_freq_number_evds <- function(freq) {
m = "month",
y = "year",
q = "quarter",
w = "week" ,
w = "week",
"null" = "day"
) # series will default to most freq possible so
# null should be the most frequent
Expand All @@ -107,7 +108,6 @@ get_freq_number_evds <- function(freq) {
freq_u
}
check_freq_only_evds_series <- function(currentObj, urlParts) {

.base <- toString(attr(urlParts$series, "base"))
.source <- toString(attr(urlParts$series, "source"))
if (!(is_(.base, "series") && is_(.source, "evds"))) {
Expand Down Expand Up @@ -137,23 +137,25 @@ createUrlForSeries <- function(currentObj) {
urlParts <- currentObj$series_fnc(prop_value)
# freq is not needed in table ones only series of evds
urlParts <- check_freq_only_evds_series(currentObj, urlParts) # side effect start date will be checked


Rapi_env$urlParts <- urlParts

urlParts <- check_series_ID_for_dots(currentObj, urlParts) # replace '_' , '.'

urlParts$key <- null
paste0(
currentObj$url,
currentObj$observations_url,
seriesCollapse(urlParts)
)
}
# ...................................................... request_httr2_helper
request_httr2_helper <- function(url, cache = TRUE) {

cache_name <- cache_name_format("request_httr2_helper", url)
check <- check_cache_comp(cache_name, cache)
if (check) {
return(load_cache(cache_name))
}
# check if vector
check_url_for_request(url)




req_version_1_no_header <- function(url) {
# ..................... 1
req <- try_or_default(
{
Expand All @@ -168,6 +170,75 @@ request_httr2_helper <- function(url, cache = TRUE) {
},
.default = null
)
return(inv(resp))
}

req_version_2_w_header <- function(url) {
# currently only EVDS request uses this version due to header policy change
# TODO generalize if new source being added
api_key <- get_api_key("evds")

req <- httr2::request(url)
req <- req |> httr2::req_headers(key = api_key)

# req |> httr2::req_dry_run()
suppressWarnings({
resp <- try_or_default(
{
req |> httr2::req_perform()
},
.default = null
)

})

return(inv(resp))
}
# request_with_param <- function(url) {
# api_key <- get_api_key("evds")
# req <- httr2::request(url)
# req <- req |> httr2::req_headers(Bearer = api_key)
#
# req |> httr2::req_dry_run()
# response <- req |> httr2::req_perform()
#
# return(response)
# }

# ...................................................... request_httr2_helper
request_httr2_helper_evds <- function(url, cache = TRUE) {
cache_name <- cache_name_format("request_httr2_helper_evds", url)
check <- check_cache_comp(cache_name, cache)
if (check) {
return(load_cache(cache_name))
}
# check if vector
check_url_for_request(url)
Rapi_env$last_req_url <- url

# resp <- req_version_1_no_header(url) # with no Param
resp <- req_version_2_w_header(url) # with PARAM

if (is_response(resp)) {
save_cache(cache_name, resp)
}
inv(resp)
}

# ...................................................... request_httr2_helper
request_httr2_helper <- function(url, cache = TRUE) {
cache_name <- cache_name_format("request_httr2_helper", url)
check <- check_cache_comp(cache_name, cache)
if (check) {
return(load_cache(cache_name))
}
# check if vector
check_url_for_request(url)
Rapi_env$last_req_url <- url

resp <- req_version_1_no_header(url)


if (is_response(resp)) {
save_cache(cache_name, resp)
}
Expand Down

0 comments on commit 62cd04f

Please sign in to comment.