npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jlafer/twilio-helpers

v1.0.12

Published

My collection of helpers for using the Twilio NodeJS SDK

Downloads

16

Readme

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.