Skip to content

Commit

Permalink
Merge pull request #33 from ropensci/sitc-bug
Browse files Browse the repository at this point in the history
Sitc bug
  • Loading branch information
ChrisMuir authored Jul 18, 2021
2 parents c61eb01 + 7ef07ce commit 0541fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Authors@R: c(person("Chris", "Muir",
role = "rev",
comment = c(ORCID = "0000-0002-3092-3493",
"Rafael reviewed the package for rOpenSci,
see https://github.com/ropensci/onboarding/issues/141")))
see https://github.com/ropensci/onboarding/issues/141")),
person("Juergen", "Amann", role=c("ctb")))
Description: Interface with and extract data from the United Nations Comtrade
API <https://comtrade.un.org/data/>. Comtrade provides country level shipping
data for a variety of commodities, these functions allow for easy API query
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
comtradr 0.2.2.09000
====================

## NEW FEATURES

* Modifications to `ct_search()` to add support for commodity code `ag6` ([#30](https://github.com/ropensci/comtradr/pull/30))

## BUG FIXES

* Passing an API token string to `ct_register_token()` now properly bumps the hourly rate limit up to 10,000
Expand Down
11 changes: 6 additions & 5 deletions R/ct_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ ct_search <- function(reporters, partners,
"&p=", partners,
"&rg=", trade_direction,
"&cc=", commod_codes,
"&fmt=", "json",
"&head=", "H"
"&head=", "H",
"&fmt=", "json"
)

## If token within global options is not NULL, append the token str to the
Expand Down Expand Up @@ -391,8 +391,9 @@ execute_api_request <- function(url) {
if (httr::http_type(res) != "application/json") {
stop(
sprintf(
"API did not return json. Instead, %s data was returned",
httr::http_type(res)
"API did not return json. Instead, %s data was returned. Return data:\n%s",
httr::http_type(res),
httr::content(res, "text", encoding = "UTF-8")
), call. = FALSE
)
}
Expand Down Expand Up @@ -547,7 +548,7 @@ is_year_month <- function(x) {
#'
#' @noRd
codes_as_ints <- function(char_vect) {
if (any(tolower(char_vect) %in% c("all", "total"))) {
if (any(tolower(char_vect) %in% c("all", "total", "ag1", "ag2", "ag3", "ag4", "ag5", "ag6"))) {
return(TRUE)
}
as_ints <- suppressWarnings(as.integer(char_vect))
Expand Down

0 comments on commit 0541fe8

Please sign in to comment.