Skip to content

Commit b1f89ba

Browse files
committed
refactor: update endpoints to have keyword-only args
1 parent 61445e8 commit b1f89ba

22 files changed

+95
-43
lines changed

R/endpoints.R

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' @examples
66
#' \dontrun{
77
#' pvt_cdc(
8-
#' auth = "yourkey",
8+
#' auth = Sys.getenv("SECRET_API_AUTH_CDC"),
99
#' locations = "fl,ca",
1010
#' epirange(201501, 201601)
1111
#' )
@@ -68,6 +68,7 @@ pvt_cdc <- function(auth, locations, epiweeks, fetch_args = fetch_args_list()) {
6868
#' covid_hosp_facility_lookup(state = "fl")
6969
#' covid_hosp_facility_lookup(city = "southlake")
7070
#' }
71+
#' @param ... not used for values, forces later arguments to bind by name
7172
#' @param state string. A two-letter character state abbreviation.
7273
#' @param ccn string. A facility CMS certification number.
7374
#' @param city string. A city name.
@@ -80,6 +81,7 @@ pvt_cdc <- function(auth, locations, epiweeks, fetch_args = fetch_args_list()) {
8081
#' @keywords endpoint
8182
#' @export
8283
covid_hosp_facility_lookup <- function(
84+
...,
8385
state = NULL,
8486
ccn = NULL,
8587
city = NULL,
@@ -155,6 +157,7 @@ covid_hosp_facility_lookup <- function(
155157
#' }
156158
#' @param hospital_pks character. Facility identifiers.
157159
#' @param collection_weeks [`timeset`]. Epiweeks to fetch.
160+
#' @param ... not used for values, forces later arguments to bind by name
158161
#' @param publication_dates [`timeset`]. Publication dates to fetch.
159162
#' @param fetch_args [`fetch_args`]. Additional arguments to pass to `fetch()`.
160163
#' @return [`epidata_call`]
@@ -167,6 +170,7 @@ covid_hosp_facility_lookup <- function(
167170
covid_hosp_facility <- function(
168171
hospital_pks,
169172
collection_weeks,
173+
...,
170174
publication_dates = NULL,
171175
fetch_args = fetch_args_list()) {
172176
assert_character_param("hospital_pks", hospital_pks)
@@ -457,13 +461,14 @@ covid_hosp_facility <- function(
457461
#' @param dates [`timeset`]. Dates to fetch.
458462
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
459463
#' most recent issue is returned.
464+
#' @param ... not used for values, forces later arguments to bind by name
460465
#' @param fetch_args [`fetch_args`]. Additional arguments to pass to `fetch()`.
461466
#' @return [`epidata_call`]
462467
#'
463468
#' @keywords endpoint
464469
#' @export
465470
#
466-
covid_hosp_state_timeseries <- function(states, dates, issues = NULL, fetch_args = fetch_args_list()) {
471+
covid_hosp_state_timeseries <- function(states, dates, ..., issues = NULL, fetch_args = fetch_args_list()) {
467472
assert_character_param("states", states)
468473
assert_timeset_param("dates", dates)
469474
assert_timeset_param("issues", issues, required = FALSE)
@@ -678,6 +683,7 @@ covidcast_meta <- function(fetch_args = fetch_args_list()) {
678683
#' all. (See:
679684
#' <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>.)
680685
#' @param time_values [`timeset`]. Dates to fetch.
686+
#' @param ... not used for values, forces later arguments to bind by name
681687
#' @param as_of Date. Optionally, the as of date for the issues to fetch. If not
682688
#' specified, the most recent data is returned. Mutually exclusive with
683689
#' `issues` or `lag`.
@@ -701,6 +707,7 @@ covidcast <- function(
701707
time_type,
702708
geo_values,
703709
time_values,
710+
...,
704711
as_of = NULL,
705712
issues = NULL,
706713
lag = NULL,
@@ -810,12 +817,11 @@ delphi <- function(system, epiweek, fetch_args = fetch_args_list()) {
810817
#'
811818
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/dengue_nowcast.html>
812819
#'
813-
#' TODO: what are valid locations here?
814820
#' @examples
815821
#' \dontrun{
816822
#' dengue_nowcast(
817823
#' locations = "pr",
818-
#' epiweeks = epirange(201501, 202001)
824+
#' epiweeks = epirange(201401, 202301)
819825
#' )
820826
#' }
821827
#' @param locations character. Locations to fetch.
@@ -848,7 +854,7 @@ dengue_nowcast <- function(locations, epiweeks, fetch_args = fetch_args_list())
848854
#' @examples
849855
#' \dontrun{
850856
#' pvt_dengue_sensors(
851-
#' auth = "yourkey",
857+
#' auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
852858
#' names = "ght",
853859
#' locations = "ag",
854860
#' epiweeks = epirange(201501, 202001)
@@ -902,6 +908,7 @@ pvt_dengue_sensors <- function(auth, names, locations, epiweeks, fetch_args = fe
902908
#' }
903909
#' @param regions character. Regions to fetch.
904910
#' @param epiweeks [`timeset`]. Epiweeks to fetch.
911+
#' @param ... not used for values, forces later arguments to bind by name
905912
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
906913
#' most recent issue is returned. Mutually exclusive with `lag`.
907914
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -910,7 +917,7 @@ pvt_dengue_sensors <- function(auth, names, locations, epiweeks, fetch_args = fe
910917
#' @return [`epidata_call`]
911918
#' @keywords endpoint
912919
#' @export
913-
ecdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
920+
ecdc_ili <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
914921
assert_character_param("regions", regions)
915922
assert_timeset_param("epiweeks", epiweeks)
916923
assert_timeset_param("issues", issues, required = FALSE)
@@ -957,6 +964,7 @@ ecdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args =
957964
#' }
958965
#' @param locations character. Character vector indicating location.
959966
#' @param epiweeks [`timeset`]. Epiweeks to fetch.
967+
#' @param ... not used for values, forces later arguments to bind by name
960968
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
961969
#' most recent issue is returned. Mutually exclusive with `lag`.
962970
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -965,7 +973,7 @@ ecdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args =
965973
#' @return [`epidata_call`]
966974
#' @keywords endpoint
967975
#' @export
968-
flusurv <- function(locations, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
976+
flusurv <- function(locations, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
969977
assert_character_param("locations", locations)
970978
assert_timeset_param("epiweeks", epiweeks)
971979
assert_timeset_param("issues", issues, required = FALSE)
@@ -1012,6 +1020,7 @@ flusurv <- function(locations, epiweeks, issues = NULL, lag = NULL, fetch_args =
10121020
#' @param epiweeks [`timeset`]. Epiweeks to fetch in the form
10131021
#' epirange(startweek,endweek), where startweek and endweek are of the form
10141022
#' YYYYWW (string or numeric).
1023+
#' @param ... not used for values, forces later arguments to bind by name
10151024
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
10161025
#' most recent issue is returned. Mutually exclusive with `lag`.
10171026
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -1020,7 +1029,7 @@ flusurv <- function(locations, epiweeks, issues = NULL, lag = NULL, fetch_args =
10201029
#' @return [`epidata_call`]
10211030
#' @keywords endpoint
10221031
#' @export
1023-
fluview_clinical <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
1032+
fluview_clinical <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
10241033
assert_character_param("regions", regions)
10251034
assert_timeset_param("epiweeks", epiweeks)
10261035
assert_timeset_param("issues", issues, required = FALSE)
@@ -1101,6 +1110,7 @@ fluview_meta <- function(fetch_args = fetch_args_list()) {
11011110
#' @param epiweeks [`timeset`]. Epiweeks to fetch in the form
11021111
#' `epirange(startweek, endweek)`, where startweek and endweek are of the form
11031112
#' YYYYWW (string or numeric).
1113+
#' @param ... not used for values, forces later arguments to bind by name
11041114
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
11051115
#' most recent issue is returned. Mutually exclusive with `lag`.
11061116
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -1111,7 +1121,7 @@ fluview_meta <- function(fetch_args = fetch_args_list()) {
11111121
#' @return [`epidata_call`]
11121122
#' @keywords endpoint
11131123
#' @export
1114-
fluview <- function(regions, epiweeks, issues = NULL, lag = NULL, auth = NULL, fetch_args = fetch_args_list()) {
1124+
fluview <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, auth = NULL, fetch_args = fetch_args_list()) {
11151125
assert_character_param("regions", regions)
11161126
assert_timeset_param("epiweeks", epiweeks)
11171127
assert_timeset_param("issues", issues, required = FALSE)
@@ -1198,13 +1208,12 @@ gft <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
11981208
#'
11991209
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/ght.html>
12001210
#'
1201-
#' TODO: find a non-trivial query
12021211
#' @examples
12031212
#' \dontrun{
12041213
#' pvt_ght(
1205-
#' auth = "yourkey",
1206-
#' locations = "ca",
1207-
#' epiweeks = epirange(201201, 202001),
1214+
#' auth = Sys.getenv("SECRET_API_AUTH_GHT"),
1215+
#' locations = "ma",
1216+
#' epiweeks = epirange(199301, 202304),
12081217
#' query = "how to get over the flu"
12091218
#' )
12101219
#' }
@@ -1243,13 +1252,13 @@ pvt_ght <- function(auth, locations, epiweeks, query, fetch_args = fetch_args_li
12431252
#'
12441253
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/kcdc_ili.html>
12451254
#'
1246-
#' TODO: find a non-trivial region
12471255
#' @examples
12481256
#' \dontrun{
12491257
#' kcdc_ili(regions = "ROK", epiweeks = 200436)
12501258
#' }
12511259
#' @param regions character. Regions to fetch.
12521260
#' @param epiweeks [`timeset`]. Epiweeks to fetch.
1261+
#' @param ... not used for values, forces later arguments to bind by name
12531262
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
12541263
#' most recent issue is returned. Mutually exclusive with `lag`.
12551264
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -1258,7 +1267,7 @@ pvt_ght <- function(auth, locations, epiweeks, query, fetch_args = fetch_args_li
12581267
#' @return [`epidata_call`]
12591268
#' @keywords endpoint
12601269
#' @export
1261-
kcdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
1270+
kcdc_ili <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
12621271
assert_character_param("regions", regions)
12631272
assert_timeset_param("epiweeks", epiweeks)
12641273
assert_timeset_param("issues", issues, required = FALSE)
@@ -1294,7 +1303,7 @@ kcdc_ili <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args =
12941303
#'
12951304
#' @examples
12961305
#' \dontrun{
1297-
#' pvt_meta_norostat(auth = "yourkey")
1306+
#' pvt_meta_norostat(auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"))
12981307
#' }
12991308
#' @param auth string. Restricted access key (not the same as API key).
13001309
#' @param fetch_args [`fetch_args`]. Additional arguments to pass to `fetch()`.
@@ -1376,6 +1385,7 @@ nidss_dengue <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
13761385
#' }
13771386
#' @param regions character. Regions to fetch.
13781387
#' @param epiweeks [`timeset`]. Epiweeks to fetch.
1388+
#' @param ... not used for values, forces later arguments to bind by name
13791389
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
13801390
#' most recent issue is returned. Mutually exclusive with `lag`.
13811391
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -1384,7 +1394,7 @@ nidss_dengue <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
13841394
#' @return [`epidata_call`]
13851395
#' @keywords endpoint
13861396
#' @export
1387-
nidss_flu <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
1397+
nidss_flu <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
13881398
assert_character_param("regions", regions)
13891399
assert_timeset_param("epiweeks", epiweeks)
13901400
assert_timeset_param("issues", issues, required = FALSE)
@@ -1424,7 +1434,7 @@ nidss_flu <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args =
14241434
#' @examples
14251435
#' \dontrun{
14261436
#' pvt_norostat(
1427-
#' auth = "yourkey",
1437+
#' auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"),
14281438
#' locations = "1",
14291439
#' epiweeks = 201233
14301440
#' )
@@ -1504,6 +1514,7 @@ nowcast <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
15041514
#' }
15051515
#' @param regions character. Regions to fetch.
15061516
#' @param epiweeks [`timeset`]. Epiweeks to fetch.
1517+
#' @param ... not used for values, forces later arguments to bind by name
15071518
#' @param issues [`timeset`]. Optionally, the issues to fetch. If not set, the
15081519
#' most recent issue is returned. Mutually exclusive with `lag`.
15091520
#' @param lag integer. Optionally, the lag of the issues to fetch. If not set,
@@ -1512,7 +1523,7 @@ nowcast <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
15121523
#' @return [`epidata_call`]
15131524
#' @keywords endpoint
15141525
#' @export
1515-
paho_dengue <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
1526+
paho_dengue <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
15161527
assert_character_param("regions", regions)
15171528
assert_timeset_param("epiweeks", epiweeks)
15181529
assert_timeset_param("issues", issues, required = FALSE)
@@ -1551,7 +1562,7 @@ paho_dengue <- function(regions, epiweeks, issues = NULL, lag = NULL, fetch_args
15511562
#' @examples
15521563
#' \dontrun{
15531564
#' pvt_quidel(
1554-
#' auth = "yourkey",
1565+
#' auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"),
15551566
#' epiweeks = epirange(201201, 202001),
15561567
#' locations = "hhs1"
15571568
#' )
@@ -1591,7 +1602,7 @@ pvt_quidel <- function(auth, locations, epiweeks, fetch_args = fetch_args_list()
15911602
#' @examples
15921603
#' \dontrun{
15931604
#' pvt_sensors(
1594-
#' auth = "yourkey",
1605+
#' auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
15951606
#' names = "sar3",
15961607
#' locations = "nat",
15971608
#' epiweeks = epirange(201501, 202001)
@@ -1635,18 +1646,23 @@ pvt_sensors <- function(auth, names, locations, epiweeks, fetch_args = fetch_arg
16351646
#'
16361647
#' @examples
16371648
#' \dontrun{
1638-
#' pvt_twitter(auth = "yourkey", locations = "CA", epiweeks = epirange(201501, 202001))
1649+
#' pvt_twitter(
1650+
#' auth = Sys.getenv("SECRET_API_AUTH_TWITTER"),
1651+
#' locations = "CA",
1652+
#' epiweeks = epirange(201501, 202001)
1653+
#' )
16391654
#' }
16401655
#' @param auth string. Restricted access key (not the same as API key).
16411656
#' @param locations character. Locations to fetch.
1657+
#' @param ... not used for values, forces later arguments to bind by name
16421658
#' @param dates [`timeset`]. Dates to fetch. Mutually exclusive with `epiweeks`.
16431659
#' @param epiweeks [`timeset`]. Epiweeks to fetch. Mutually exclusive with
16441660
#' `dates`.
16451661
#' @param fetch_args [`fetch_args`]. Additional arguments to pass to `fetch()`.
16461662
#' @return [`epidata_call`]
16471663
#' @keywords endpoint
16481664
#' @export
1649-
pvt_twitter <- function(auth, locations, dates = NULL, epiweeks = NULL, fetch_args = fetch_args_list()) {
1665+
pvt_twitter <- function(auth, locations, ..., dates = NULL, epiweeks = NULL, fetch_args = fetch_args_list()) {
16501666
assert_character_param("auth", auth, len = 1)
16511667
assert_character_param("locations", locations)
16521668
assert_timeset_param("dates", dates, required = FALSE)
@@ -1696,6 +1712,7 @@ pvt_twitter <- function(auth, locations, dates = NULL, epiweeks = NULL, fetch_ar
16961712
#' wiki(articles = "avian_influenza", epiweeks = epirange(201501, 201601))
16971713
#' }
16981714
#' @param articles character. Articles to fetch.
1715+
#' @param ... not used for values, forces later arguments to bind by name
16991716
#' @param dates [`timeset`]. Dates to fetch. Mutually exclusive with `epiweeks`.
17001717
#' @param epiweeks [`timeset`]. Epiweeks to fetch. Mutually exclusive with
17011718
#' `dates`.
@@ -1707,6 +1724,7 @@ pvt_twitter <- function(auth, locations, dates = NULL, epiweeks = NULL, fetch_ar
17071724
#' @export
17081725
wiki <- function(
17091726
articles,
1727+
...,
17101728
dates = NULL,
17111729
epiweeks = NULL,
17121730
hours = NULL,

man/covid_hosp_facility.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/covid_hosp_facility_lookup.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/covid_hosp_state_timeseries.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/covidcast.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)