cmu-delphi / epidatr

Delphi Epidata API R Client
https://cmu-delphi.github.io/epidatr/
Other
1 stars 5 forks source link

Add missing field specs for endpoints; parse `release_date` as date #223

Closed nmdefries closed 9 months ago

nmdefries commented 9 months ago

Add missing field specs for endpoints. I could only manually check field specs for private endpoints against the corresponding server code, so it's possible those have additional missing field specs. If so, a call to those endpoints will issue a warning listing the missing fields.

Parse release_date fields as hyphen-separated dates, rather than as text. To do so, I used a list of date formats (YYYYMMDD and YYYY-MM-DD) for tryFormats in as.Date. This has slightly different behavior than using the format arg:

nmdefries commented 9 months ago

If endpoint metadata is missing the spec for a field that is actually returned, a warning is triggered. That field is returned as the type provided in the response JSON (maybe plus some auto-typing from data.frame/tibble conversions).

We attempt to apply every metadata field spec to the response; non-specified fields aren't handled at all. When no metadata is provided, the response is returned as-is. (Maybe this case should have a warning too?)

If the response is missing a field that the endpoint metadata provides the spec for, nothing happens -- it's silently ignored (since the code loops over metadata field specs rather than over columns in the response df). We ignore this case because users can request a subset of fields to be fetched via fetch_args_list. That would cause a lot of spurious warnings.