Skip to contents

mm_list_get_reqs() returns the necessary GET request(s) for fetching the supplied endpoint and parameters. Multiple GET requests are sometimes needed for two reasons.

One, Megamation does not support common ways of separating multiple values for a field inside an HTTP URL. These ways include:

  • using a ,, e.g. ?x=1,2

  • using a |, e.g. ?x=1|2

  • turning each element into its own parameter, e.g. ?x=1&x=2

    For Megamation, the first two ways will result in a 404 error. The last way fetches data where x is both 1 and 2 (not 1 or 2). Hence mm_list_get_reqs() defines separate GET requests for each value given to a parameter.

Two, the timecard endpoint is unique in that separate GET requests must be made for separate years of data (e.g. 2022 vs 2023). This is also automatically handled by mm_list_get_reqs().

Usage

mm_list_get_reqs(endpoint, ..., allfields = TRUE)

Arguments

endpoint

The API endpoint. For example, "timecard" for employee transactions, and "workorder" for work orders. All endpoints are listed at https://apidocs.megamation.com/.

...

<dynamic-dots> Name-value pairs to filter the request. The name should be the lower-case name of a field that is filter-enabled (in Megamation's words, a criteria). These arguments are processed with rlang::quos() and support unquote via !! and unquote-splice via !!!.

allfields

If TRUE, return all fields currently available for the endpoint.

Value

A list of GET requests of class httr2_request.

Examples

if (FALSE) { # megamation:::has_creds()
date <- seq.Date(as.Date("2022-01-01"), as.Date("2023-01-31"), by = "day")
megamation:::mm_list_get_reqs("timecard", date = date)
}