betfaiR

bf_basic_req

The bf_basic_req function builds a very simple request object, with a different class depending on the method which the request is to be used for.

usage

req <- bf_basic_req(filter = marketFilter(),
                    method = "competitions")

arguments

param details
filter list returned by marketFilter or an empty list
method the method which this request will be passed to

return

The function returns a list containing any parameters entered via [marketFilter], and is assigned a class taken from the method argument. This class is used to help build the request via bf_request (see below).


bf_request

The bf_request function builds on the request returned by base_request, and converts it into valid JSON ready to used in a POST request to the relevant method.

req <- bf_request(bf_basic_req(filter = marketFilter(),
                               method = "competitions"))

arguments

param details
x a list returned by base_request

return

The function returns a JSON object, which will be entered in any POST request.

examples

(req <- bf_basic_req(filter = marketFilter(),
                     method = "competitions"))
named list()
attr(,"class")
[1] "list"         "competitions"
class(req)
[1] "list"         "competitions"
(req <- bf_request(req))
{"jsonrpc":"2.0","method":"SportsAPING/v1.0/listCompetitions","params":{"filter":{}},"id":1} 
(req <- bf_basic_req(filter = marketFilter(eventTypeIds = 7),
                     method = "events"))
$eventTypeIds
[1] 7

attr(,"class")
[1] "list"   "events"
(req <- bf_request(req))
{"jsonrpc":"2.0","method":"SportsAPING/v1.0/listEvents","params":{"filter":{"eventTypeIds":[7]}},"id":1}