@jlafer/twilio-helpers v1.0.12
jlafer/twilio-helpers
This is my collection of utility functions that I find useful in Twilio projects.
Installation
npm install --save @jlafer/twilio-helpers
Helper Functions
getClient
getClient(accountSid, authToken)
Returns a NodeJS Twilio SDK client.
getFlexConfig
getFlexConfig :: (accountSID, authToken) -> Promise
Returns a Promise that, on success, resolves to the Flex service configuration object.
getFlexConfigProps
getFlexConfigProps :: (accountSID, authToken, keys) -> Promise
Returns a Promise that, on success, resolves to the properties with the selected keys from the Flex service configuration object.
getFlexConfigAttributes
getFlexConfigAttributes :: (accountSID, authToken) -> Promise
Returns a Promise that, on success, resolves to the attributes
property from the Flex service configuration object.
getFlexPluginAttributes
getFlexPluginAttributes :: (accountSID, authToken, namespace) -> Promise
Returns a Promise that, on success, resolves to the property having the selected namespace within the attributes
property of the Flex service configuration object.
updateFlexConfig
updateFlexConfig :: (accountSID, authToken, newCfg) -> Promise
Asynchronously updates the Flex service configuration object.
WARNING: this is a destructive put
operation -- not a patch. For every key supplied in newCfg
, all desired final data for that key must be supplied. Use getFlexConfig
to retrieve the entire service configuration object.
updateFlexAttributes
updateFlexAttributes :: (accountSID, authToken, newAttributes) -> Promise
Asynchronously updates the attributes
property within the Flex service configuration object.
WARNING: this is a destructive put
operation -- not a patch. For every key supplied in newCfg
, all desired final data for that key must be supplied. Use getFlexConfigAttributes
to retrieve the entire attributes
property`.
updateFlexPluginAttributes
updateFlexAttributes :: (accountSID, authToken, namespace, pluginData) -> Promise
Asynchronously updates a single plugin namespace within the attributes
property of the Flex service configuration object. The pluginData
object will be merged into the attributes
property using the namespace
value as the key. In this way, other subkeys of attributes
will be left unchanged.
patchFlexConfigKey
patchFlexConfigKey :: (accountSID, authToken, key, patchObj) -> Promise
Asynchronously patches the property with the specified key
in the Flex service configuration object, using data in patchObj
. The patchObj
data will be merged into the property with the specified key. In this way, any subkeys of key
not specified in patchObj
will be left unchanged.
deleteFlexPluginAttributes
deleteFlexPluginAttributes :: (accountSID, authToken, namespace) -> Promise
Asynchronously deletes a single plugin namespace from within the attributes
property of the Flex service configuration object.
formatWorkspace
formatWorkspace(workspace)
Formats the key properties of the argument.
logWorkspace
logWorkspace(workspace)
Logs the key properties of the argument to the console.
getWorkspaces
getWorkspaces(client)
Returns all TaskRouter workspaces for the project.
getWorkspace
getWorkspace(client, sid)
Returns a TaskRouter workspace by its SID.
getWorkspaceByName
getWorkspaceByName(client, name)
Returns a TaskRouter workspace by its name.
formatActivity
formatActivity(activity)
Formats the key properties of the argument.
logActivity
logActivity(activity)
Logs the key properties of the argument to the console.
getActivities
getActivities(client, wrkspcSid)
Returns all TaskRouter activities for the project.
getActivity
getActivity(client, wrkspcSid, sid)
Returns a TaskRouter activity by its SID.
getActivityByName
getActivityByName(client, wrkspcSid, name)
Returns a TaskRouter activity by its name.
formatWorkflow
formatWorkflow(workspace)
Formats the key properties of the argument.
logWorkflow
logWorkflow(workspace)
Logs the key properties of the argument to the console.
getWorkflows
getWorkflows(client, wrkspcSid)
Returns all TaskRouter workspaces for the project.
getWorkflow
getWorkflow(client, wrkspcSid, sid)
Returns a TaskRouter workspace by its SID.
getWorkflowByName
getWorkflowByName(client, wrkspcSid, name)
Returns a TaskRouter workspace by its name.
formatEvent
formatEvent(event)
Formats the key properties of the argument.
logEvent
logEvent(event)
Logs the key properties of the argument to the console.
getEvents
getEvents(client, wrkspcSid)
Returns all TaskRouter events for the workspace identified by the argument. NOTE: currently, no date range or other limits are placed on this call, so it's only suitable for use in a small test workspace.
formatTask
formatTask(task)
Formats the key properties of the argument.
logTask
logTask(task)
Logs the key properties of the argument to the console.
getTasks
getTasks(client, wrkspcSid)
Returns all TaskRouter tasks for the workspace identified by the argument. NOTE: currently, no filters are placed on this call so it's only suitable for use in a small test workspace.
getTask
getTask(client, wrkspcSid, taskSid)
Returns a TaskRouter task for the workspace and task SID identified by the arguments.
createTask
createTask(client, wrkspcSid, data)
Creates a new TaskRouter task in the workspace identified by the argument. The data object can include properties such as workflowSid, taskChannel, priority and attributes.
updateTask
updateTask(client, wrkspcSid, taskSid, data)
Updates a TaskRouter task. The data object can include properties assignmentStatus, reason, priority and attributes.
formatExecution
formatExecution(execution)
Formats the key properties of the argument.
logExecution
logExecution(execution)
Logs the key properties of the argument to the console.
getExecutions
getExecutions(client, flowSid, fromDt, toDt)
Returns a Promise that resolves to an array of objects with two properties: execution
and context
. The array will contain all Studio executions for the Workflow identified by flowSid
within the date-time range defined by fromDt
and toDt
. Dates are specified with strings in ISO 8601 format.
getExecutionsPage
getExecutionsPage(client, flowSid, param)
Returns a Promise that resolves to one page of Studio executions for the Workflow identified by flowSid
. It returns an object with two properties: execContexts
and nextPageUrl
. execContexts
is an array of objects with two properties: execution
and context
.
To retrieve the first page of data, param
should contain an object with list filtering properties (e.g., fromDt
, toDt
, pageSize
). Dates are specified with strings in ISO 8601 format. If nextPageUrl
in the result is non-null, the next page of data can be retrieved by passing it as the param
value.
getExecution
getExecution(client, flowSid, execSid)
Returns a Studio execution for the Workflow identified by flowSid
and execution identified by execSid
.
getExecContext
getExecContext(client, flowSid, execSid)
Returns the execution context for the Studio Workflow identified by flowSid
and execution identified by execSid
.