@@ -459,30 +459,55 @@ pub_covid_hosp_facility <- function(
459459# '
460460# ' @param states character. Two letter state abbreviations.
461461# ' @param dates [`timeset`]. Dates to fetch.
462- # ' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
463- # ' most recent issue is returned.
464462# ' @param ... not used for values, forces later arguments to bind by name
463+ # ' @param as_of Date. Optionally, the as of date for the issues to fetch. If not
464+ # ' specified, the most recent data is returned. Mutually exclusive with
465+ # ' `issues`.
466+ # ' @param issues [`timeset`]. Optionally, the issue of the data to fetch. If not
467+ # ' specified, the most recent issue is returned. Mutually exclusive with
468+ # ' `as_of` or `lag`.
465469# ' @param fetch_args [`fetch_args`]. Additional arguments to pass to `fetch()`.
466470# ' @return [`tibble::tibble`]
467471# '
468472# ' @keywords endpoint
469473# ' @export
470474#
471- pub_covid_hosp_state_timeseries <- function (states , dates , ... , issues = NULL , fetch_args = fetch_args_list()) {
475+ pub_covid_hosp_state_timeseries <- function (
476+ states ,
477+ dates ,
478+ ... ,
479+ as_of = NULL ,
480+ issues = NULL ,
481+ fetch_args = fetch_args_list()) {
482+ # Check parameters
472483 rlang :: check_dots_empty()
473484
485+ if (missing(states ) || missing(dates )) {
486+ stop(
487+ " `states` and `dates` are both required"
488+ )
489+ }
490+
491+ if (sum(! is.null(issues ), ! is.null(as_of )) > 1 ) {
492+ stop(" `issues`and `as_of` are mutually exclusive" )
493+ }
494+
474495 assert_character_param(" states" , states )
475496 assert_timeset_param(" dates" , dates )
497+ assert_date_param(" as_of" , as_of , len = 1 , required = FALSE )
476498 assert_timeset_param(" issues" , issues , required = FALSE )
499+
477500 dates <- parse_timeset_input(dates )
478501 issues <- parse_timeset_input(issues )
502+ as_of <- parse_timeset_input(as_of )
479503
480504 create_epidata_call(
481505 " covid_hosp_state_timeseries/" ,
482506 list (
483507 states = states ,
484508 dates = dates ,
485- issues = issues
509+ issues = issues ,
510+ as_of = as_of
486511 ),
487512 list (
488513 create_epidata_field_info(" state" , " text" ),
0 commit comments