restapi

Summit REST API Client

summit.restapi provides Summit Applications with access to the Summit REST API. Rather than having to use basic auth and the http library, where you would have to manage your keys, you can use the restapi library and be automatically authenticated.

Request URLs must be paths only. No hosts or scheme allowed. Parameters can only be params for query parameters or data to specify the request body, which may be a JSON-encodable table or may be JSON encoded. Results are JSON decoded for you.

Methods supported are: get post put patch delete

Examples

local restapi = require "summit.restapi"

-- Simple GET

result, err = restapi.get("/domain")

if not err then
  print("my domain id is "..tostring(result.data[1].domain_id))
end

-- Request body

schedule_data = {
    "destination_type" : "endpoint",
    "destination" : "1234",
    "application" : "test_app",
    "application_data" : "my data",
    "application_destination" : "my dest",
    "internal_caller_id_number" : "1234",
    "internal_caller_id_name" : "That Guy"
}
result, err = restapi.post("/channel/schedule", {data=schedule_data})
-- or equivalently
-- result, err = restapi.post("/channel/schedule", {data=json:encode(schedule_data)})

-- Query params

my_channel_id = channel.channel_id
result, err = restapi.get("/channel/schedule", {params={channel_id=my_channel_id}})