Skip to content

Commit

Permalink
version 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobtz authored and cran-robot committed Nov 29, 2023
1 parent 3c4c50f commit 0a209aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: imf.data
Title: An Interface to IMF (International Monetary Fund) Data JSON API
Version: 0.1.2
Version: 0.1.3
Authors@R:
person("Pedro", "Baltazar",, "pedrobtz@gmail.com", role = c("aut", "cre"))
Description: A straightforward interface for accessing the IMF
Expand All @@ -21,8 +21,8 @@ Config/testthat/edition: 3
URL: https://pedrobtz.github.io/imf.data/
BugReports: https://github.com/pedrobtz/imf.data/issues
NeedsCompilation: no
Packaged: 2023-11-23 19:52:50 UTC; pbtz
Packaged: 2023-11-27 20:44:10 UTC; pbtz
Author: Pedro Baltazar [aut, cre]
Maintainer: Pedro Baltazar <pedrobtz@gmail.com>
Repository: CRAN
Date/Publication: 2023-11-23 20:10:02 UTC
Date/Publication: 2023-11-28 10:00:06 UTC
6 changes: 3 additions & 3 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
857831814b823fdc58f31aab49b7a95f *DESCRIPTION
6eb754fbd25c5207f7f36f94a6f78d65 *DESCRIPTION
4b4dc26a2562dc2187d00821cbe32e36 *LICENSE
4b4a95efc195552823cbe2b6923db362 *NAMESPACE
7c8c39529785cda8101f599edd5f71be *NEWS.md
a0605dd1222d50fda640c0ddd5557995 *NEWS.md
0402dc39f9eebe8fe19c32d5a6f028e4 *R/database.R
edff3bcc034e3a9e734566a99d032b44 *R/methods.R
da868b7e4774aea2c941b4c79a96df46 *R/methods.R
c3c4f326dca8c8e795db55b8da1d242b *R/package.R
1277d734fbc34b933e56626f0145e627 *R/request.R
6cd1949e458a43656c057a196a632af2 *R/settings.R
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# imf.data

# imf.data 0.1.3

* improve error handling, when service responds with html message.

# imf.data 0.1.2

* [#2](https://github.com/pedrobtz/imf.data/issues/2) fix bug while extracting the dimensions for database, when a dimension has single values.
* [#2](https://github.com/pedrobtz/imf.data/issues/2) fix bug while extracting the dimensions for database, when a dimension has a single value.

# imf.data 0.1.1

Expand Down
21 changes: 11 additions & 10 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ mt_dataflow <- local({
function(){
if(is.null(.data)){
resp <- get_request(url = build_api_path("Dataflow"))
if(is.null(resp)){
return(null_response())
if(is.null(resp) || is.character(resp)){
return(null_response(resp))
}
if(is.atomic(resp))
return(resp)

.data <<- resp$Structure$Dataflows$Dataflow
}
Expand Down Expand Up @@ -44,8 +42,8 @@ mt_data_structure <- function(id){
if(!id %in% ls_ids)
stop(sprintf("DatabaseID `%s` not found in Dataflow datasets", id))
resp <- get_request(url = build_api_path(paste0("DataStructure/", id)))
if(is.null(resp)){
return(null_response())
if(is.null(resp) || is.character(resp)){
return(null_response(resp))
}
return(resp)
}
Expand Down Expand Up @@ -80,8 +78,8 @@ mt_compact_data <- function(id,
path <- sprintf("CompactData/%s/%s", id, query)
path <- paste(path, dates, sep = "?")
resp <- get_request(url = build_api_path(path))
if(is.null(resp)){
return(null_response())
if(is.null(resp) || is.character(resp)){
return(null_response(resp))
}
return(resp)
}
Expand All @@ -93,8 +91,11 @@ build_query <- function(dimensions){
return(x)
}

null_response <- function(){
message("Data service did not respond.")
null_response <- function(msg = NULL){
if(is.null(msg))
message("Data service did not respond.")
else
message("Data service response:","\n", msg)
return(invisible(NULL))
}

0 comments on commit 0a209aa

Please sign in to comment.