This is an extremely minimal client. You need to know the API to be able to use this client. All this function does is:
Try to substitute each listed parameter into
endpoint
, using the{parameter}
notation.If a GET request (the default), then add all other listed parameters as query parameters.
If not a GET request, then send the other parameters in the request body, as JSON.
Convert the response to an R list using
jsonlite::fromJSON()
.
Usage
.pp(
endpoint,
...,
per_page = NULL,
.destfile = NULL,
.overwrite = FALSE,
.api_url = NULL,
.method = "GET",
.limit = NULL,
.accept = "application/json",
.send_headers = NULL,
.progress = TRUE,
.params = list(),
.api_version = 1,
.unnest = !is.null(.unnest_element),
.unnest_element = NULL,
.unnest_dont_unlist = NULL
)
Arguments
- endpoint
Prodpad API endpoint. Must be one of the following forms:
METHOD path
, e.g.GET /feedbacks
,path
, e.g./feedbacks
,METHOD url
, e.g.GET https://api.prodpad.com/v1/feedbacks
,url
, e.g.https://api.prodpad.com/v1/feedbacks
.
If the method is not supplied, will use
.method
, which defaults to"GET"
.- ...
Name-value pairs giving API parameters. Will be matched into
endpoint
placeholders, sent as query parameters in GET requests, and as a JSON body of POST requests. If there is only one unnamed parameter, and it is a raw vector, then it will not be JSON encoded, but sent as raw data, as is. This can be used for example to add assets to releases. NamedNULL
values are silently dropped. For GET requests, namedNA
values trigger an error. For other methods, namedNA
values are included in the body of the request, as JSONnull
.- per_page
Number of items to return per page. If omitted, will be substituted by
max(.limit, 100)
if.limit
is set, otherwise determined by the API (never greater than 100).- .destfile
Path to write response to disk. If
NULL
(default), response will be processed and returned as an object. If path is given, response will be written to disk in the form sent.- .overwrite
If
.destfile
is provided, whether to overwrite an existing file. Defaults toFALSE
.- .api_url
Prodpad API url (default: https://api.prodpad.com/v1). Used if
endpoint
just contains a path. Defaults toPRODPAD_API_URL
environment variable if set.- .method
HTTP method to use if not explicitly supplied in the
endpoint
.- .limit
Number of records to return. This can be used instead of manual pagination. By default it is
NULL
, which means that the defaults of the Prodpad API are used. You can set it to a number to request more (or less) records, and also toInf
to request all records. Note, that if you request many records, then multiple Prodpad API calls are used to get them, and this can take a potentially long time.- .accept
The value of the
Accept
HTTP header. Defaults to"application/json
. IfAccept
is given in.send_headers
, then that will be used. This parameter can be used to provide a custom media type, in order to access a preview feature of the API.- .send_headers
Named character vector of header field values (except
Authorization
, which is handled via.token
). This can be used to override or augment the defaultUser-Agent
header:"https://github.com/andrie/prodpad"
.- .progress
Whether to show a progress indicator for calls that need more than one HTTP request.
- .params
Additional list of parameters to append to
...
. It is easier to use this than...
if you have your parameters in a list already.- .api_version
This must be
1
.- .unnest
If TRUE, unnests the result object
- .unnest_element
Name of element to extract before unnesting the result object
- .unnest_dont_unlist
Vector of columns name to ignore during the unnesting.