From 2bb75fdfffe7364a36120b7b1498eef7572db447 Mon Sep 17 00:00:00 2001 From: Tony Fujs Date: Wed, 20 Jul 2022 10:55:53 +0200 Subject: [PATCH 1/6] Increment version number to 0.0.2.9000 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 107c13e..0d09eb7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: pipr Title: Client for the PIP API -Version: 0.0.2 +Version: 0.0.2.9000 Authors@R: c(person(given = "Tony", family = "Fujs", diff --git a/NEWS.md b/NEWS.md index aaf25ec..f3d8d7d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# pipr (development version) + # pipr 0.0.2 ## Bug fixes From 670b3dc19ad893b549bf03c3c7f7000023f79a52 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Sun, 18 Sep 2022 15:19:16 +0800 Subject: [PATCH 2/6] add new arguments for get_stats --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/get_stats.R | 8 ++++++-- R/utils.R | 5 ++++- man/get_stats.Rd | 6 ++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0d09eb7..efcee98 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,7 +28,7 @@ License: MIT + file LICENSE Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.1 URL: https://github.com/worldbank/pipr, https://worldbank.github.io/pipr/ BugReports: https://github.com/worldbank/pipr/issues diff --git a/NEWS.md b/NEWS.md index f3d8d7d..7465d62 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pipr (development version) +* [Add new ppp_version and release_version parameters](https://github.com/worldbank/pipr/issues/37) + # pipr 0.0.2 ## Bug fixes diff --git a/R/get_stats.R b/R/get_stats.R index 5fd5833..08e92b8 100644 --- a/R/get_stats.R +++ b/R/get_stats.R @@ -13,6 +13,8 @@ #' @param welfare_type character: Welfare type either of c("all", "income", "consumption") #' @param reporting_level character: Geographical reporting level either of c("all", "national", "urban", "rural") #' @param version character: Data version. See `get_versions()` +#' @param ppp_version ppp year to be used +#' @param release_version date when the data was published in YYYYMMDD format #' @param api_version character: API version #' @param format character: Response format either of c("rds", "json", "csv") #' @param simplify logical: If TRUE (the default) the response is returned as a @@ -60,6 +62,8 @@ get_stats <- function(country = "all", welfare_type = c("all", "income", "consumption"), reporting_level = c("all", "national", "urban", "rural"), version = NULL, + ppp_version = NULL, + release_version = NULL, api_version = "v1", format = c("rds", "json", "csv"), simplify = TRUE, @@ -69,7 +73,6 @@ get_stats <- function(country = "all", reporting_level <- match.arg(reporting_level) api_version <- match.arg(api_version) format <- match.arg(format) - # popshare can't be used together with povline if (!is.null(popshare)) povline <- NULL @@ -102,10 +105,11 @@ get_stats <- function(country = "all", welfare_type = welfare_type, reporting_level = reporting_level, version = version, + ppp_version = ppp_version, + release_version = release_version, format = format ) u <- build_url(server, endpoint, api_version) - # Send query res <- httr::GET(u, query = args, httr::user_agent(pipr_user_agent)) diff --git a/R/utils.R b/R/utils.R index e07db72..d7123e6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -70,6 +70,8 @@ build_args <- function(country = NULL, reporting_level = NULL, table = NULL, version = NULL, + ppp_version = ppp_version, + release_version = release_version, format = NULL) { # Collapse to a single string @@ -82,7 +84,8 @@ build_args <- function(country = NULL, welfare_type = welfare_type, reporting_level = reporting_level, group_by = group_by, table = table, - version = version, format = format + version = version, ppp_version = ppp_version, + release_version = release_version,format = format ) attempt::stop_if_all(args, is.null, "You need to specify at least one argument") diff --git a/man/get_stats.Rd b/man/get_stats.Rd index ab60a42..b8ea12c 100644 --- a/man/get_stats.Rd +++ b/man/get_stats.Rd @@ -15,6 +15,8 @@ get_stats( welfare_type = c("all", "income", "consumption"), reporting_level = c("all", "national", "urban", "rural"), version = NULL, + ppp_version = NULL, + release_version = NULL, api_version = "v1", format = c("rds", "json", "csv"), simplify = TRUE, @@ -54,6 +56,10 @@ sub-groups. Either 'wb_regions' or 'none'.} \item{version}{character: Data version. See \code{get_versions()}} +\item{ppp_version}{ppp year to be used} + +\item{release_version}{date when the data was published in YYYYMMDD format} + \item{api_version}{character: API version} \item{format}{character: Response format either of c("rds", "json", "csv")} From a495c2492a6e78e7b74c6341a9f27d9d85354a70 Mon Sep 17 00:00:00 2001 From: Ronak Shah Date: Sun, 18 Sep 2022 15:58:52 +0800 Subject: [PATCH 3/6] update NEWS --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 7465d62..2419c72 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # pipr (development version) -* [Add new ppp_version and release_version parameters](https://github.com/worldbank/pipr/issues/37) +* [Add new ppp_version and release_version parameters](https://github.com/worldbank/pipr/pull/38) # pipr 0.0.2 From 7855b4262855428d96c497234bdbc5c822a2c792 Mon Sep 17 00:00:00 2001 From: Tony Fujs Date: Tue, 20 Sep 2022 10:12:04 +0200 Subject: [PATCH 4/6] remove systematic call to check_api() --- NEWS.md | 1 + R/get_stats.R | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 2419c72..77b4517 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # pipr (development version) * [Add new ppp_version and release_version parameters](https://github.com/worldbank/pipr/pull/38) +* [Remove systematic check_api() call in get_stats()](https://github.com/worldbank/pipr/pull/38) # pipr 0.0.2 diff --git a/R/get_stats.R b/R/get_stats.R index 08e92b8..dcc04bd 100644 --- a/R/get_stats.R +++ b/R/get_stats.R @@ -92,7 +92,6 @@ get_stats <- function(country = "all", # Check connection check_internet() - check_api(api_version, server) # Build query string args <- build_args( From 93d6f73340e31d765fa1f4baa992ec99a1bcfa90 Mon Sep 17 00:00:00 2001 From: Tony Fujs Date: Tue, 20 Sep 2022 10:19:01 +0200 Subject: [PATCH 5/6] export check_api() function --- NAMESPACE | 2 +- R/get_stats.R | 3 --- R/other.R | 8 ++++---- R/utils.R | 6 +++--- man/{health_check.Rd => check_api.Rd} | 12 ++++++------ 5 files changed, 14 insertions(+), 17 deletions(-) rename man/{health_check.Rd => check_api.Rd} (60%) diff --git a/NAMESPACE b/NAMESPACE index 65a5def..760d5b9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(check_api) export(get_aux) export(get_countries) export(get_cpi) @@ -18,4 +19,3 @@ export(get_stats) export(get_survey_means) export(get_versions) export(get_wb) -export(health_check) diff --git a/R/get_stats.R b/R/get_stats.R index dcc04bd..3136f1a 100644 --- a/R/get_stats.R +++ b/R/get_stats.R @@ -90,9 +90,6 @@ get_stats <- function(country = "all", group_by <- NULL } - # Check connection - check_internet() - # Build query string args <- build_args( country = country, diff --git a/R/other.R b/R/other.R index f757e11..ba9d3e6 100644 --- a/R/other.R +++ b/R/other.R @@ -1,14 +1,14 @@ -#' Check API status +#' Check internet connection and API status #' @inheritParams get_stats #' @return character #' @export #' @examples #' \dontrun{ -#' health_check() +#' check_api() #' } -health_check <- function(api_version = "v1", server = NULL) { +check_api <- function(api_version = "v1", server = NULL) { check_internet() - res <- check_api(api_version, server = server) + res <- health_check(api_version, server = server) parse_response(res, simplify = FALSE)$content } diff --git a/R/utils.R b/R/utils.R index d7123e6..92deae9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,10 +5,10 @@ check_internet <- function() { invisible(TRUE) } -#' check_api -#' @inheritParams get_stats +#' health_check +#' @inheritParams check_api #' @noRd -check_api <- function(api_version, server = NULL) { +health_check <- function(api_version, server = NULL) { u <- build_url(server, "health-check", api_version) res <- httr::GET(u) attempt::stop_if_not( diff --git a/man/health_check.Rd b/man/check_api.Rd similarity index 60% rename from man/health_check.Rd rename to man/check_api.Rd index 1c5ea51..645ae4c 100644 --- a/man/health_check.Rd +++ b/man/check_api.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/other.R -\name{health_check} -\alias{health_check} -\title{Check API status} +\name{check_api} +\alias{check_api} +\title{Check internet connection and API status} \usage{ -health_check(api_version = "v1", server = NULL) +check_api(api_version = "v1", server = NULL) } \arguments{ \item{api_version}{character: API version} @@ -15,10 +15,10 @@ health_check(api_version = "v1", server = NULL) character } \description{ -Check API status +Check internet connection and API status } \examples{ \dontrun{ -health_check() +check_api() } } From 4701be190a0aed2de5771cea4687b5c2b627be6d Mon Sep 17 00:00:00 2001 From: Tony Fujs Date: Tue, 20 Sep 2022 10:19:42 +0200 Subject: [PATCH 6/6] Increment version number to 0.0.3 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index efcee98..754b8fc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: pipr Title: Client for the PIP API -Version: 0.0.2.9000 +Version: 0.0.3 Authors@R: c(person(given = "Tony", family = "Fujs", diff --git a/NEWS.md b/NEWS.md index 77b4517..96697a4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# pipr (development version) +# pipr 0.0.3 * [Add new ppp_version and release_version parameters](https://github.com/worldbank/pipr/pull/38) * [Remove systematic check_api() call in get_stats()](https://github.com/worldbank/pipr/pull/38)