Back to Top

Mesa SDK Methods 1.0.0

Mesa.log.info(message[, meta])

Log debugging info to Mesa Logs.

Parameters

Name Type Description
message string
meta object Optional

Returns

Void

Mesa.log.warn(message[, meta])

Log a warning to Mesa Logs.

Parameters

Name Type Description
message string
meta object Optional

Returns

Void

Mesa.log.error(message[, meta])

Log an error to Mesa Logs.

Parameters

Name Type Description
message string
meta object Optional

Returns

Void

Mesa.request.get(path[, options])

Make a GET request to an external Rest API.

Parameters

Name Type Description
path string
options object Optional
options.json bool

Automatically add JSON Content-Type headers and decode the response. Default: true

Optional
options.query object

Parameters to append to the querystring.

Optional
options.headers object

Headers to send to the request.

Optional
options.debug bool

Log request information and response headers.

Optional

Returns

string object

The response returned by the request. object if options.json is true, string if options.json is false.

Mesa.request.post(path, data[, options])

Make a POST request to an external Rest API.

Parameters

Name Type Description
path string
data object
options object Optional
options.json bool

Automatically add JSON Content-Type headers and decode the response. Default: true

Optional
options.query object

Parameters to append to the querystring.

Optional
options.headers object

Headers to send to the request.

Optional
options.debug bool

Log request information and response headers.

Optional

Returns

string object

The response returned by the request. object if options.json is true, string if options.json is false.

Mesa.request.put(path, data[, options])

Make a PUT request to an external Rest API.

Parameters

Name Type Description
path string
data object
options object Optional
options.json bool

Automatically add JSON Content-Type headers and decode the response. Default: true

Optional
options.query object

Parameters to append to the querystring.

Optional
options.headers object

Headers to send to the request.

Optional
options.debug bool

Log request information and response headers.

Optional

Returns

string object

The response returned by the request. object if options.json is true, string if options.json is false.

Mesa.request.patch(path, data[, options])

Make a PATCH request to an external Rest API.

Parameters

Name Type Description
path string
data object
options object Optional
options.json bool

Automatically add JSON Content-Type headers and decode the response. Default: true

Optional
options.query object

Parameters to append to the querystring.

Optional
options.headers object

Headers to send to the request.

Optional
options.debug bool

Log request information and response headers.

Optional

Returns

string object

The response returned by the request. object if options.json is true, string if options.json is false.

Mesa.request.delete(path[, options])

Make a DELETE request to an external Rest API.

Parameters

Name Type Description
path string
options object Optional
options.json bool

Automatically add JSON Content-Type headers and decode the response. Default: true

Optional
options.query object

Parameters to append to the querystring.

Optional
options.headers object

Headers to send to the request.

Optional
options.debug bool

Log request information and response headers.

Optional

Returns

string object

The response returned by the request. object if options.json is true, string if options.json is false.

Mesa.secret.get(key)

Get a secret.

Parameters

Name Type Description
key string

Returns

string

The secret value.

Mesa.secret.set(key, value)

Save a secret value.

Parameters

Name Type Description
key string
value mixed

Returns

Void

Mesa.storage.get(key[, filter])

Get a storage item

Parameters

Name Type Description
key string
filter array

Key to filter the storage item by.

Optional

Returns

string object

The storage value. object if the storage item is valid JSON, otherwise a string.

Mesa.storage.set(key, value)

Get a storage item

Parameters

Name Type Description
key string
value mixed

Returns

Void

Mesa.liquid.render(template, params)

Render a liquid template with the params passed.

Parameters

Name Type Description
template string

String representing a liquid template.

params object

A keyed object of parameters to replace.

Returns

string

The rendered template code.

Mesa.output.done(payload)

Pass a payload to the Output configured to trigger this Script in the Mesa Dashboard.

Parameters

Name Type Description
payload object

Returns

Void

Mesa.output.send(outputKey, payload)

Call an output from a Mesa Script

Parameters

Name Type Description
outputKey string
payload object

Returns

Void

Mesa.ftp.deleteFile(filename)

Delete the file loaded by the Input.

Parameters

Name Type Description
filename string

Typically passed from context.filename.

Returns

Void

Mesa.ftp.moveFile(filename, destinationFilenameAndPath)

Move the file loaded by the Input to a new location.

Parameters

Name Type Description
filename string

Typically passed from context.filename.

destinationFilenameAndPath string

Returns

Void

Mesa.xml.decode(key, filter)

Convert an XML file into an {object}.

Parameters

Name Type Description
key string
filter object

Optional

Returns

string

The rendered template code.

Mesa.xml.encode(key, value)

Convert an object into an XML string.

Parameters

Name Type Description
key string
value mixed

Returns

Void

Mesa.csv.decode(data[, returnObject])

Convert a CSV file into an object. Keys will be matched from the first header row of the CSV file.

Parameters

Name Type Description
data string
returnObject bool

Defaults to true, which will return an object keyed by the first row in the CSV content. Set to false to return an array.

Optional

Returns

object array

Mesa.csv.encode(data[, headerRow])

Convert an object a CSV string.

Parameters

Name Type Description
data object
headerRow bool

Defaults to true. Set to false to skip the header row when returning CSV.

Optional

Returns

string

Mesa.vo.push(outputKey, payload)

Push to a Virtual Output.

Parameters

Name Type Description
outputKey string
payload mixed

Returns

Void

Mesa.vo.clear(outputKey)

Mark the matching Virtual Output records as cleared by the current Mesa Script.

Parameters

Name Type Description
outputKey string

Returns

Void

Mesa.vo.clearOne(outputKey, mesaId)

Mark a single Virtual Output record as cleared by the current Mesa Script.

Parameters

Name Type Description
outputKey string
mesaId string

The ID of the record to clear (returned as mesa_id in the Virtual Output).

Returns

Void

Mesa.email.send(to, subject, body)

Send an email.

Parameters

Name Type Description
to string
subject string
body string

Returns

Void