Skip to content

Commit

Permalink
ensure that service string is uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhsparks committed Oct 9, 2024
1 parent f719574 commit e491b60
Showing 1 changed file with 40 additions and 41 deletions.
81 changes: 40 additions & 41 deletions R/get_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#'
#' @export
get_key <- function(service = c("DPIRD", "SILO")) {

service <- toupper(service)
service <- match.arg(service)

if (service == "DPIRD") {
Expand All @@ -47,47 +47,46 @@ get_key <- function(service = c("DPIRD", "SILO")) {
}
}

#' Help the User Request an API Key for the DPIRD API
#'
#' Opens a browser window at the DPIRD API key request URL and provides
#' instruction on how to store the key. After filling the form you will get
#' the key soon, but not immediately.
#'
#' @keywords internal
#' @noRd
#' @return Called for its side-effects, opens a browser window at the DPIRD
#' weather data API key request form.
.set_dpird_key <- function() {
if (interactive()) {
utils::browseURL("https://www.agric.wa.gov.au/form/dpird-api-registration")
}

stop(
"You need to set your DPIRD API key.\n",
"After getting your key set it as 'DPIRD_API_KEY' in .Renviron.\n",
"DPIRD_API_KEY='youractualkeynotthisstring'\n",
"For that, use `usethis::edit_r_environ()`"
)

invisible("https://www.agric.wa.gov.au/form/dpird-api-registration")
#' Help the User Request an API Key for the DPIRD API
#'
#' Opens a browser window at the DPIRD API key request URL and provides
#' instruction on how to store the key. After filling the form you will get
#' the key soon, but not immediately.
#'
#' @keywords internal
#' @noRd
#' @return Called for its side-effects, opens a browser window at the DPIRD
#' weather data API key request form.
.set_dpird_key <- function() {
if (interactive()) {
utils::browseURL("https://www.agric.wa.gov.au/form/dpird-api-registration")

Check warning on line 62 in R/get_key.R

View check run for this annotation

Codecov / codecov/patch

R/get_key.R#L61-L62

Added lines #L61 - L62 were not covered by tests
}
stop(
"You need to set your DPIRD API key.\n",
"After getting your key set it as 'DPIRD_API_KEY' in .Renviron.\n",
"DPIRD_API_KEY='youractualkeynotthisstring'\n",
"For that, use `usethis::edit_r_environ()`"
)

Check warning on line 69 in R/get_key.R

View check run for this annotation

Codecov / codecov/patch

R/get_key.R#L64-L69

Added lines #L64 - L69 were not covered by tests

#' Help the User Set Up Their SILO API Key
#'
#' Instructs the user on how to set up the SILO API key to automatically find
#' it.
#'
#' @return Invisible `NULL`, called for its side-effects, returns a message
#' with instructions.
#' @keywords internal
#' @noRd
invisible("https://www.agric.wa.gov.au/form/dpird-api-registration")

Check warning on line 71 in R/get_key.R

View check run for this annotation

Codecov / codecov/patch

R/get_key.R#L71

Added line #L71 was not covered by tests
}

#' Help the User Set Up Their SILO API Key
#'
#' Instructs the user on how to set up the SILO API key to automatically find
#' it.
#'
#' @return Invisible `NULL`, called for its side-effects, returns a message
#' with instructions.
#' @keywords internal
#' @noRd

.set_silo_key <- function() {
stop(
"Set your SILO API key (email address) as 'SILO_API_KEY' in .Renviron.\n",
"SILO_API_KEY='youractualemailnotthisstring'\n",
"For that, use `usethis::edit_r_environ()`"
)
.set_silo_key <- function() {
stop(
"Set your SILO API key (email address) as 'SILO_API_KEY' in .Renviron.\n",
"SILO_API_KEY='youractualemailnotthisstring'\n",
"For that, use `usethis::edit_r_environ()`"
)

invisible(NULL)
}
invisible(NULL)

Check warning on line 91 in R/get_key.R

View check run for this annotation

Codecov / codecov/patch

R/get_key.R#L91

Added line #L91 was not covered by tests
}

0 comments on commit e491b60

Please sign in to comment.