Module

util

A module containing helpful utilities to ease the use of xmtoolbox.

View Source util.js, line 5

Methods

# inner CsvToJson(data, options) → {Object}

Takes a string of data in CSV format and returns a JSON object representing the data. Included to prevent the need for additional packages in most cases. If this doesn't work for you implement your own or use some of the other packages available.
Parameters:
Name Type Description
data string the CSV data.
options module:util.CSVTOJSON_OPTIONS options object to allow some flexibility when converting CSV files to JSON.

View Source util.js, line 49

JSON Object representation of the CSV data
Object

# async inner CsvToJsonFromFile(path, options) → {Object}

Takes a path to a CSV file and returns a JSON object representing the file. Included to prevent the need for additional packages in most cases. If this doesn't work for you implement your own or use some of the other packages available.
Parameters:
Name Type Description
path string path to to CSV file.
options module:util.CSVTOJSON_OPTIONS options object to allow some flexibility when converting CSV files to JSON.

View Source util.js, line 36

JSON Object representation of the CSV data
Object

# inner defaults(object, source)

if keys from source are undefined in object, they are set on the object and object is returned.
Parameters:
Name Type Description
object *
source *

View Source util.js, line 289

# inner isMatch(object, source)

Compares Objects for match, object can contain more than source
Parameters:
Name Type Description
object *
source *

View Source util.js, line 272

# async inner post(env, api, json, query)

POST request to xMatters Instance. Useful for sending data to a Workflow Flow.

Abides by the concurrency limit for the instance.

WARNING: The environment's readOnly option is not enforced when using this function.
Parameters:
Name Type Description
env module:environments.xMattersEnvironment The xmtoolbox representation of an xMatters instance.
api string The api endpoint past the base URL. Example: '/api/xm/1/groups' or 'https://SUBDOMAIN.xmatters.com'
json Object The object to include in the request body as json
query Object A json object representing the query string parameters for this request.

View Source util.js, line 144

Type Definitions

Object

# CSVTOJSON_OPTIONS

Properties:
Name Type Description
headerRow number Default: 0 The line index where the header starts.
dataStartRow number Default: 1 The line index where the data starts.
headers Array.<string> default: undefined If no header row is included, include an array of string names for the columns. Included a name for all columns from left most column to right most needed column. If headers are not included it may be desired to set the dataStartRow option to start at index 0.

View Source util.js, line 11