mock_tableau_request() creates a JSON object formatted like a request from Tableau. The JSON object it returns can be pasted directly into the "Try it out" field in the Swagger documentation for an endpoint to test its functionality.

mock_tableau_request(script, data, ...)

Arguments

script

String indicating the path to the endpoint to be called

data

A list or dataframe that is serialized to JSON

...

Additional arguments passed to jsonlite::toJSON()

Value

A JSON object that can be passed to a Tableau endpoint

Details

Behind the scenes, Tableau sends all requests to the /evaluate endpoint. Each request is a JSON object containing two items: script and data. plumbertableau uses script to specify an individual endpoint to call, and passes the arguments in data on to the function at that endpoint.

Examples

mock_tableau_request("/loess/predict", mtcars[,c("hp", "mpg")])
#> { #> "script": "/loess/predict", #> "data": { #> "_arg1": [ #> 110, #> 110, #> 93, #> 110, #> 175, #> 105, #> 245, #> 62, #> 95, #> 123, #> 123, #> 180, #> 180, #> 180, #> 205, #> 215, #> 230, #> 66, #> 52, #> 65, #> 97, #> 150, #> 150, #> 245, #> 175, #> 66, #> 91, #> 113, #> 264, #> 175, #> 335, #> 109 #> ], #> "_arg2": [ #> 21, #> 21, #> 22.8, #> 21.4, #> 18.7, #> 18.1, #> 14.3, #> 24.4, #> 22.8, #> 19.2, #> 17.8, #> 16.4, #> 17.3, #> 15.2, #> 10.4, #> 10.4, #> 14.7, #> 32.4, #> 30.4, #> 33.9, #> 21.5, #> 15.5, #> 15.2, #> 13.3, #> 19.2, #> 27.3, #> 26, #> 30.4, #> 15.8, #> 19.7, #> 15, #> 21.4 #> ] #> } #> } #>