Skip to contents

A class to interact with the KoboToolbox API, extending crul::HttpClient.

Super class

crul::HttpClient -> KoboClient

Methods

Inherited methods


Method new()

Initialization method for class "KoboClient".

Usage

KoboClient$new(base_url, kobo_token = Sys.getenv("KBTBR_TOKEN"))

Arguments

base_url

character. The full base URL of the API.

kobo_token

character. The API token. Defaults to requesting the system environment variable KBTBR_TOKEN.


Method get()

Perform a GET request (with additional checks)

Usage

KoboClient$get(path, query = list(), ...)

Arguments

path

character. Path component of the endpoint.

query

list. A named list which is parsed to the query component. The order is not hierarchical.

...

crul-options. Additional option arguments, see crul::HttpClient for reference

Details

Extension of the crul::HttpClient$get() method that checks the HttpResponse object on status, that it is of type application/json, and parses the response text subsequently from JSON to R list representation.

Returns

the server response as a crul::HttpResponse object.


Method post()

Perform a POST request

Usage

KoboClient$post(path, body, ...)

Arguments

path

character. Path component of the endpoint.

body

R list. A data payload to be sent to the server.

...

crul-options. Additional option arguments, see crul::HttpClient for reference

Details

Extension of the crul::HttpClient$post() method.

Returns

Returns an object of class crul::HttpResponse.


Method clone()

The objects of this class are cloneable with this method.

Usage

KoboClient$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.