Skip to content

Internals docs #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions R/check.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Allows character vectors
#' @importFrom checkmate assert_character assert_integerish
#' @keywords internal
assert_character_param <- function(name, value, len = NULL, required = TRUE) {
null.ok <- !required
assert_integerish(len, null.ok = TRUE, .var.name = "len")
Expand All @@ -8,6 +9,7 @@ assert_character_param <- function(name, value, len = NULL, required = TRUE) {

#' Allows integer-like vectors
#' @importFrom checkmate assert_integerish
#' @keywords internal
assert_integerish_param <- function(name, value, len = NULL, required = TRUE) {
null.ok <- !required
assert_integerish(len, null.ok = TRUE, .var.name = "len")
Expand All @@ -16,6 +18,7 @@ assert_integerish_param <- function(name, value, len = NULL, required = TRUE) {

#' Allows a vector of date_like params: date, character, or integer-like
#' @importFrom checkmate check_date check_character check_integerish
#' @keywords internal
assert_date_param <- function(name, value, len = NULL, required = TRUE) {
null.ok <- !required
assert_integerish(len, null.ok = TRUE, .var.name = "len")
Expand Down
11 changes: 6 additions & 5 deletions R/epidatacall.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fetch <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE) {
}

#' Fetches the data and returns a tibble
#' @rdname epidata_call
#' @rdname fetch_tbl
#'
#' @param epidata_call an instance of `epidata_call`
#' @param fields a list of epidata fields to return, or NULL to return all
Expand All @@ -142,7 +142,7 @@ fetch <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE) {
#' @return
#' - For `fetch_tbl`: a [`tibble::tibble`]
#' @importFrom tibble as_tibble
#'
#' @keywords internal
fetch_tbl <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE) {
stopifnot(inherits(epidata_call, "epidata_call"))
stopifnot(is.null(fields) || is.character(fields))
Expand All @@ -162,7 +162,7 @@ fetch_tbl <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE)
#' Fetches the data, raises on epidata errors, and returns the results as a
#' JSON-like list
#'
#' @rdname epidata_call
#' @rdname fetch_classic
#'
#' @param epidata_call an instance of `epidata_call`
#' @param fields a list of epidata fields to return, or NULL to return all
Expand All @@ -176,7 +176,7 @@ fetch_tbl <- function(epidata_call, fields = NULL, disable_date_parsing = FALSE)
#' @importFrom jsonlite fromJSON
#' @return
#' - For `fetch_classic`: a JSON-like list
#'
#' @keywords internal
fetch_classic <- function(epidata_call, fields = NULL, disable_data_frame_parsing = TRUE) {
stopifnot(inherits(epidata_call, "epidata_call"))
stopifnot(is.null(fields) || is.character(fields))
Expand Down Expand Up @@ -224,7 +224,7 @@ full_url <- function(epidata_call) {
}

#' Returns the full request url for the given epidata_call
#' @rdname epidata_call
#' @rdname request_url
#'
#' @param epidata_call an instance of `epidata_call`
#' @param format_type format to return one of classic,json,csv
Expand All @@ -235,6 +235,7 @@ full_url <- function(epidata_call) {
#' @importFrom httr modify_url
#' @return
#' - For `request_url`: string containing the URL
#' @keywords internal
request_url <- function(epidata_call, format_type = "classic", fields = NULL) {
stopifnot(inherits(epidata_call, "epidata_call"))
url <- full_url(epidata_call)
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Helper function to cast values, non-list vectors, and/or EpiRanges to strings
#'
#' @noRd
#' @keywords internal
format_item <- function(value) {
if (inherits(value, "EpiRange")) {
paste0(toString(value$from), "-", toString(value$to))
Expand All @@ -13,7 +13,7 @@ format_item <- function(value) {

#' Helper function to build a list of values and/or ranges
#'
#' @noRd
#' @keywords internal
format_list <- function(values) {
paste(vapply(values, format_item, character(1L)), collapse = ",")
}
1 change: 1 addition & 0 deletions man/assert_character_param.Rd

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

1 change: 1 addition & 0 deletions man/assert_date_param.Rd

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

1 change: 1 addition & 0 deletions man/assert_integerish_param.Rd

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

27 changes: 0 additions & 27 deletions man/epidata_call.Rd

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