Skip to content

Commit

Permalink
Update for rapid function renames. (#42)
Browse files Browse the repository at this point in the history
* Update for rapid function renames.

* Remove S7 from remotes.
  • Loading branch information
jonthegeek authored Nov 15, 2023
1 parent 665078b commit abc9b51
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 25 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ VignetteBuilder:
knitr
Remotes:
jonthegeek/nectar,
jonthegeek/rapid,
rconsortium/S7
jonthegeek/rapid
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
20 changes: 10 additions & 10 deletions R/as_bk_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @inheritParams rlang::args_dots_empty
#' @param x The object to coerce. Currently supports conversion of
#' [security_scheme_collection()] objects.
#' [rapid::class_security_schemes()] objects.
#'
#' @return A list.
#' @keywords internal
Expand All @@ -13,7 +13,7 @@ as_bk_data <- S7::new_generic(
dispatch_args = "x"
)

S7::method(as_bk_data, rapid::security_scheme_collection) <- function(x) {
S7::method(as_bk_data, rapid::class_security_schemes) <- function(x) {
if (!length(x)) {
return(list())
}
Expand Down Expand Up @@ -109,11 +109,11 @@ S7::method(as_bk_data, rapid::security_scheme_collection) <- function(x) {
)
}

S7::method(as_bk_data, rapid::security_scheme_details) <- function(x) {
S7::method(as_bk_data, rapid::class_security_scheme_details) <- function(x) {
purrr::map(x, as_bk_data)
}

S7::method(as_bk_data, rapid::api_key_security_scheme) <- function(x) {
S7::method(as_bk_data, rapid::class_api_key_security_scheme) <- function(x) {
if (length(x)) {
return(
list(
Expand All @@ -133,12 +133,12 @@ S7::method(as_bk_data, rapid::api_key_security_scheme) <- function(x) {

S7::method(as_bk_data, S7::class_any) <- function(x) {
cli::cli_warn(
"No method for as_bk_data() for class {.cls class(x)}."
"No method for as_bk_data() for class {.cls {class(x)}}."
)
return(list())
}

# S7::method(as_bk_data, rapid::oauth2_authorization_code_flow) <- function(x) {
# S7::method(as_bk_data, rapid::class_oauth2_authorization_code_flow) <- function(x) {
# if (!length(x)) {
# return(list())
# }
Expand All @@ -152,7 +152,7 @@ S7::method(as_bk_data, S7::class_any) <- function(x) {
# )
# }

# S7::method(as_bk_data, rapid::oauth2_implicit_flow) <- function(x) {
# S7::method(as_bk_data, rapid::class_oauth2_implicit_flow) <- function(x) {
# if (!length(x)) {
# return(list())
# }
Expand All @@ -165,7 +165,7 @@ S7::method(as_bk_data, S7::class_any) <- function(x) {
# )
# }

# S7::method(as_bk_data, rapid::scopes) <- function(x) {
# S7::method(as_bk_data, rapid::class_scopes) <- function(x) {
# if (!length(x)) {
# return(list())
# }
Expand All @@ -177,7 +177,7 @@ S7::method(as_bk_data, S7::class_any) <- function(x) {
# )
# }

# S7::method(as_bk_data, rapid::oauth2_token_flow) <- function(x) {
# S7::method(as_bk_data, rapid::class_oauth2_token_flow) <- function(x) {
# if (!length(x)) {
# return(list())
# }
Expand All @@ -190,7 +190,7 @@ S7::method(as_bk_data, S7::class_any) <- function(x) {
# )
# }

# S7::method(as_bk_data, rapid::oauth2_security_scheme) <- function(x) {
# S7::method(as_bk_data, rapid::class_oauth2_security_scheme) <- function(x) {
# if (!length(x)) {
# return(list())
# }
Expand Down
12 changes: 9 additions & 3 deletions R/use_beekeeper.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' @inheritParams rlang::args_dots_empty
#' @param x An object to use to define the configuration, such as a
#' [rapid::rapid()] or a url to an OpenAPI document.
#' [rapid::class_rapid()] or a url to an OpenAPI document.
#' @param api_abbr A short (about 2-5 letter) abbreviation for the API, for use
#' in function names and environment variables.
#' @param config_file The path to the configuration file to write.
Expand All @@ -30,7 +30,7 @@ use_beekeeper <- S7::new_generic(
)

#' @importFrom usethis use_build_ignore
S7::method(use_beekeeper, rapid::rapid) <-
S7::method(use_beekeeper, rapid::class_rapid) <-
function(x,
api_abbr,
...,
Expand Down Expand Up @@ -63,7 +63,13 @@ S7::method(use_beekeeper, S7::class_any) <-
config_file = "_beekeeper.yml",
rapid_file = "_beekeeper_rapid.rds") {
x <- as_rapid(x)
use_beekeeper(x, api_abbr, ..., config_file = config_file)
use_beekeeper(
x,
api_abbr,
...,
config_file = config_file,
rapid_file = rapid_file
)
}

.read_config <- function(config_file = "_beekeeper.yml") {
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Most of the outline was included in the grant proposal.
- [x] I split the OpenAPI-parsing functionality into a separate package, [{rapid}](https://rapid.api2r.org). That package is being developed parallel to this one, and contains all of the *R API D*efinition-specific functionality.
- [x] I also realized I need a package for wrapping {httr2} calls. That package is called [{nectar}](https://nectar.api2r.org), and is also being developed parallel to this one.
- [x] **0.1.0: Basic authentication and endpoint calls.**
- [x] Export a function or functions to generate `R/*.R` files to call an API, given the URL of an OpenAPI spec in YAML format (or a `rapid::rapid()` object). The generated files will follow and encourage best practices, and will serve as the core around which the rest of a package would be built.
- [x] Export a function or functions to generate `R/*.R` files to call an API, given the URL of an OpenAPI spec in YAML format (or a `rapid::class_rapid()` object). The generated files will follow and encourage best practices, and will serve as the core around which the rest of a package would be built.
- [x] Also generate a `tests/testthat/*.R` file for that generated function.
- [x] Generate `R/*.R` and `tests/testthat/*.R` files to authenticate the user (using API keys).
- [x] Produce a vignette about configuring authentication. Folded into the main vignette since it's suprisingly straightforward.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ included in the grant proposal.
- [x] **0.1.0: Basic authentication and endpoint calls.**
- [x] Export a function or functions to generate `R/*.R` files to call
an API, given the URL of an OpenAPI spec in YAML format (or a
`rapid::rapid()` object). The generated files will follow and
`rapid::class_rapid()` object). The generated files will follow and
encourage best practices, and will serve as the core around which
the rest of a package would be built.
- [x] Also generate a `tests/testthat/*.R` file for that generated
Expand Down
2 changes: 1 addition & 1 deletion man/as_bk_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/use_beekeeper.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions tests/testthat/_fixtures/000-create_fixtures.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ config_path <- test_path(glue::glue("_fixtures/{api_abbr}_beekeeper.yml"))
apid_url |>
url() |>
use_beekeeper(
rapid,
api_abbr = api_abbr,
config_file = config_path,
rapid_file = rapid_write_path
Expand All @@ -18,7 +17,6 @@ config_path <- test_path(glue::glue("_fixtures/{api_abbr}_beekeeper.yml"))
apid_url |>
url() |>
use_beekeeper(
rapid,
api_abbr = api_abbr,
config_file = config_path,
rapid_file = rapid_write_path
Expand All @@ -31,7 +29,6 @@ config_path <- test_path(glue::glue("_fixtures/{api_abbr}_beekeeper.yml"))
apid_url |>
url() |>
use_beekeeper(
rapid,
api_abbr = api_abbr,
config_file = config_path,
rapid_file = rapid_write_path
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_fixtures/fec_beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ api_title: OpenFEC
api_abbr: fec
api_version: '1.0'
rapid_file: fec_rapid.rds
updated_on: 2023-10-11 14:59:01.432621
updated_on: 2023-11-15 18:36:30.794058
Binary file modified tests/testthat/_fixtures/fec_rapid.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/_fixtures/guru_beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ api_title: APIs.guru
api_abbr: guru
api_version: 2.2.0
rapid_file: guru_rapid.rds
updated_on: 2023-10-11 14:56:48.892847
updated_on: 2023-11-15 18:36:23.395772
Binary file modified tests/testthat/_fixtures/guru_rapid.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/_fixtures/trello_beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ api_title: Trello
api_abbr: trello
api_version: '1.0'
rapid_file: trello_rapid.rds
updated_on: 2023-10-11 14:59:33.634001
updated_on: 2023-11-15 18:36:36.569711
Binary file modified tests/testthat/_fixtures/trello_rapid.rds
Binary file not shown.

0 comments on commit abc9b51

Please sign in to comment.