Teamwork Connector

reshuffle-teamwork-connectors

Code | npm |

npm install reshuffle-teamwork-connectors

Reshuffle Teamwork Connector

This package contains a Reshuffle connector to connect Teamwork Online app APIs.

The following example exposes an endpoint to return the data of a Task after an Update action.

const { Reshuffle } = require('reshuffle')
const { TeamworkConnector } = require('reshuffle-teamwork-connectors')

const app = new Reshuffle()

const connector = new TeamworkConnector(app,  {
  apiKey: YOUR_API_KEY,
  subdomain: YOUR_SUB_DOMAIN,
  webhookPath: '/webhooks/teamwork'
})

connector.on({ type: 'TASK.UPDATED' }, async (event, app) => {
  console.log('Task updated on Teamwork YOUR_SUB_DOMAIN')
  console.log(event.eventCreator.id)
  console.log(event.taskList.name)
  console.log(event.task)
})

app.start()

Table of Contents

Configuration Options

Connector Events

Listening to Teamwork events

Connector Actions

SDK - Retrieve a full Teamwork sdk object

Configuration options

const app = new Reshuffle()
const connector = new TeamworkConnector(app, {
  apiKey: YOUR_API_KEY, 
  subdomain: YOUR_SUB_DOMAIN, 
  webhookPath: WEBHOOK_PATH 
})

More details about the fields are described in teamwork-api

You can use the webhookPath to configure the url that Teamwork hits when it makes its calls to Reshuffle. For example - having the Reshuffle runtime URL https://my-reshuffle.com and webhookPath=/webhook will result in a complete webhook path of https://my-reshuffle.com/webhook. If you do not provide a webhookPath, Reshuffle will use the default webhook path for the connector which is /webhooks/teamwork. You will need to register this webhook with Teamwork. See instructions.

Events

Listening to Teamwork events

To listen to events happening in Teamwork, you'll need to capture them with the connector's on function, providing a TeamworkConnectorEventOptions to it.

interface TeamworkConnectorEventOptions {
  type: TeamworkEventType // See bellow 
}

// Where...
type TeamworkEventType =
  | 'CALENDAREVENT.CREATED'
  | 'CALENDAREVENT.DELETED'
  | 'CALENDAREVENT.REMINDER'
  | 'CALENDAREVENT.UPDATED'
  | 'CARD.CREATED'
  | 'CARD.DELETED'
  | 'CARD.UPDATED'
  | 'COLUMN.CREATED'
  | 'COLUMN.DELETED'
  | 'COLUMN.UPDATED'
  | 'COMMENT.CREATED'
  | 'COMMENT.DELETED'
  | 'COMMENT.UPDATED'
  | 'COMPANY.CREATED'
  | 'COMPANY.DELETED'
  | 'COMPANY.UPDATED'
  | 'EXPENSE.CREATED'
  | 'EXPENSE.DELETED'
  | 'EXPENSE.UPDATED'
  | 'FILE.CREATED'
  | 'FILE.DELETED'
  | 'FILE.DOWNLOADED'
  | 'FILE.TAGGED'
  | 'FILE.UNTAGGED'
  | 'FILE.UPDATED'
  | 'INVOICE.COMPLETED'
  | 'INVOICE.CREATED'
  | 'INVOICE.DELETED'
  | 'INVOICE.REOPENED'
  | 'INVOICE.UPDATED'
  | 'LINK.CREATED'
  | 'LINK.DELETED'
  | 'LINK.TAGGED'
  | 'LINK.UNTAGGED'
  | 'LINK.UPDATED'
  | 'MESSAGE.CREATED'
  | 'MESSAGE.DELETED'
  | 'MESSAGE.TAGGED'
  | 'MESSAGE.UNTAGGED'
  | 'MESSAGE.UPDATED'
  | 'MESSAGEREPLY.CREATED'
  | 'MESSAGEREPLY.DELETED'
  | 'MESSAGEREPLY.UPDATED'
  | 'MILESTONE.COMPLETED'
  | 'MILESTONE.CREATED'
  | 'MILESTONE.DELETED'
  | 'MILESTONE.REMINDER'
  | 'MILESTONE.REOPENED'
  | 'MILESTONE.TAGGED'
  | 'MILESTONE.UNTAGGED'
  | 'MILESTONE.UPDATED'
  | 'NOTEBOOK.CREATED'
  | 'NOTEBOOK.DELETED'
  | 'NOTEBOOK.TAGGED'
  | 'NOTEBOOK.UNTAGGED'
  | 'NOTEBOOK.UPDATED'
  | 'PORTFOLIOBOARD.CREATED'
  | 'PORTFOLIOBOARD.DELETED'
  | 'PORTFOLIOBOARD.UPDATED'
  | 'PORTFOLIOCARD.CREATED'
  | 'PORTFOLIOCARD.DELETED'
  | 'PORTFOLIOCARD.MOVED'
  | 'PORTFOLIOCARD.REOPENED'
  | 'PORTFOLIOCARD.UPDATED'
  | 'PORTFOLIOCOLUMN.CREATED'
  | 'PORTFOLIOCOLUMN.DELETED'
  | 'PORTFOLIOCOLUMN.UPDATED'
  | 'PROJECT.ARCHIVED'
  | 'PROJECT.COMPLETED'
  | 'PROJECT.COPIED'
  | 'PROJECT.CREATED'
  | 'PROJECT.DELETED'
  | 'PROJECT.REOPENED'
  | 'PROJECT.TAGGED'
  | 'PROJECT.UNTAGGED'
  | 'PROJECT.UPDATED'
  | 'PROJECTUPDATE.CREATED'
  | 'PROJECTUPDATE.DELETED'
  | 'PROJECTUPDATE.UPDATED'
  | 'RISK.CREATED'
  | 'RISK.DELETED'
  | 'RISK.UPDATED'
  | 'ROLE.CREATED'
  | 'ROLE.DELETED'
  | 'ROLE.UPDATED'
  | 'STATUS.CREATED'
  | 'STATUS.DELETED'
  | 'STATUS.UPDATED'
  | 'TASK.COMPLETED'
  | 'TASK.CREATED'
  | 'TASK.DELETED'
  | 'TASK.MOVED'
  | 'TASK.REMINDER'
  | 'TASK.REOPENED'
  | 'TASK.TAGGED'
  | 'TASK.UNTAGGED'
  | 'TASK.UPDATED'
  | 'TASKLIST.COMPLETED'
  | 'TASKLIST.CREATED'
  | 'TASKLIST.CREATEDFROMTEMPLATE'
  | 'TASKLIST.DELETED'
  | 'TASKLIST.REOPENED'
  | 'TASKLIST.UPDATED'
  | 'TIME.CREATED'
  | 'TIME.DELETED'
  | 'TIME.TAGGED'
  | 'TIME.UNTAGGED'
  | 'TIME.UPDATED'
  | 'USER.CREATED'
  | 'USER.DELETED'
  | 'USER.UPDATED'

Events require that an integration webhook is configured in Teamwork.

The connector triggers events of many types, you can get more details about them here

Example:

connector.on({ type: 'TASK.UPDATED' }, async (event, app) => {
  console.log('Task updated on Teamwork YOUR_SUB_DOMAIN')
  console.log(event.eventCreator.id)
  console.log(event.taskList.name)
  console.log(event.task)
})

The description of fields and events can be found here

Actions

The actions are provided via the sdk.

sdk

Returns an object providing full access to the Teamwork APIs. Full list of available actions, requests and responses can be found here

const sdk = await connector.sdk()

Example:

const sdk = await connector.sdk()
const taskLists = await sdk.tasklist.get()
console.log('Tasklists:', JSON.stringify(taskLists))
const task = await sdk.tasks.get({}, YOUR_TASK_ID))
console.log('Task YOUR_TASK_ID:', JSON.stringify(task))