Skip to content

Commit

Permalink
feat: update core request function
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig committed Aug 29, 2024
1 parent 4a3fc9e commit e915788
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 12 deletions.
46 changes: 34 additions & 12 deletions R/entrata_request.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,11 @@ entrata <- function(
validate_entrata_endpoint_method(endpoint, method)
validate_entrata_method_params(endpoint, method, method_params)

req_body <- list(
auth = list(
type = "basic"
),
requestId = 15,
method = list(
name = method,
version = method_version,
params = method_params
)
) |>
purrr::compact()
req_body <- derive_req_body(
method = method,
method_version = method_version,
method_params = method_params
)

username <- config$username
password <- config$password
Expand Down Expand Up @@ -253,3 +246,32 @@ entrata <- function(
res <- req |> httr2::req_perform(verbosity = verbosity)
return(res)
}

#' Derive Entrata API Request Body
#'
#' @description
#' Derives the request body for an Entrata API request.
#'
#' @param method The Entrata API method to use.
#' @param method_version The version of the API method to use.
#' @param method_params A named list of parameters to include in the request body.
#'
#' @return A list representing the request body.
#'
#' @export
#'
#' @importFrom purrr compact
derive_req_body <- function(method, method_version, method_params) {
list(
auth = list(
type = "basic"
),
requestId = 15,
method = list(
name = method,
version = method_version,
params = method_params
)
) |>
purrr::compact()
}
50 changes: 50 additions & 0 deletions man/entrata.Rd

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

0 comments on commit e915788

Please sign in to comment.