-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Metropolitan-Council/14-update-streetligh…
…tr-to-align-with-most-recent-api-changes Update (version 1.2.0)
- Loading branch information
Showing
52 changed files
with
1,656 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
^\.github$ | ||
^README\.Rmd$ | ||
^LICENSE\.md$ | ||
^data-raw$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ jobs: | |
|
||
strategy: | ||
fail-fast: false | ||
max-parallel: 1 | ||
matrix: | ||
config: | ||
- {os: macos-latest, r: 'release'} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#' Check the review status of a analysis in the StreetLight API. | ||
#' | ||
#' @inheritParams check_streetlight_api | ||
#' @inheritParams lookup_analysis_id | ||
#' @inheritParams create_streetlight_analysis | ||
#' | ||
#' | ||
#' @return If successful, a list with two items | ||
#' Otherwise, an httr2 response. | ||
#' | ||
#' @export | ||
#' | ||
#' @importFrom httr2 req_body_json req_perform req_headers req_error | ||
#' @importFrom cli cli_warn cli_alert | ||
#' @importFrom purrr map2 | ||
#' | ||
check_analysis_review <- function(analysis_name = NULL, | ||
uuid = NULL, | ||
key = NULL) { | ||
# check for API key access | ||
key <- check_api_key_access(key) | ||
# validate parameters | ||
purrr::map2( | ||
names(as.list(match.call())), | ||
eval(as.list(match.call())), | ||
validate_parameters | ||
) | ||
|
||
# if no uuid, lookup uuid | ||
if (is.null(uuid)) { | ||
uuid <- lookup_analysis_id( | ||
analysis_name = analysis_name, | ||
uuid = uuid | ||
) | ||
} | ||
|
||
# fetch analysis status from endpoint | ||
resp <- streetlight_insight( | ||
key = key, | ||
endpoint = paste0( | ||
"analyses/", | ||
uuid, | ||
"/review_detail" | ||
) | ||
) %>% | ||
httr2::req_headers( | ||
"content-type" = "application/json" | ||
) %>% | ||
httr2::req_error(is_error = function(resp) FALSE) %>% | ||
httr2::req_perform() | ||
|
||
|
||
# if error message returnd, return WARNING | ||
if (httr2::resp_status(resp) != 200) { | ||
return( | ||
cli::cli_warn(c( | ||
"Review check failed with message: ", | ||
httr2::resp_body_json(resp) | ||
)) | ||
) | ||
} else { | ||
# otherwise, return succ | ||
return(cli::cli_alert(c( | ||
"Review check succceeded with message: ", | ||
httr2::resp_body_json(resp) | ||
))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.