Skip to content

Commit

Permalink
add dry run catches for resource functions
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs committed Jan 29, 2025
1 parent 74457f7 commit 0892b9c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/countries.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ list_countries <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_countries_list(structure(
data,
Expand Down
3 changes: 3 additions & 0 deletions R/latest.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ list_location_latest <- function(
)
path <- paste("locations", locations_id, "latest", sep = "/")
data <- fetch(path, params_list, dry_run = dry_run)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
invisible(as.data.frame.openaq_latest_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/locations.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_location <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_locations_list(structure(
data,
Expand Down Expand Up @@ -189,6 +192,9 @@ list_locations <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_locations_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/manufacturers.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_manufacturer <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_manufacturers_list(structure(
data,
Expand Down Expand Up @@ -95,6 +98,9 @@ list_manufacturers <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_manufacturers_list(structure(
data,
Expand Down
3 changes: 3 additions & 0 deletions R/measurements.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ list_sensor_measurements <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_measurements_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/owners.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_owner <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_owners_list(structure(
data,
Expand Down Expand Up @@ -96,6 +99,9 @@ list_owners <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_owners_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_parameter <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_parameters_list(structure(
data,
Expand Down Expand Up @@ -95,6 +98,9 @@ list_parameters <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_parameters_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/providers.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_provider <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_providers_list(structure(
data,
Expand Down Expand Up @@ -95,6 +98,9 @@ list_providers <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_providers_list(structure(
data,
Expand Down
6 changes: 6 additions & 0 deletions R/sensors.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ get_sensor <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_sensors_list(structure(
data,
Expand Down Expand Up @@ -75,6 +78,9 @@ get_location_sensors <- function(
rate_limit = rate_limit,
api_key = api_key
)
if (isTRUE(dry_run)) {
return(data)
}
if (as_data_frame == TRUE) {
return(as.data.frame.openaq_sensors_list(structure(
data,
Expand Down

0 comments on commit 0892b9c

Please sign in to comment.