Skip to content
Richard Thombs edited this page May 21, 2014 · 20 revisions

Integration Events provide an easy way to ensure that a third party system is kept up to date with changes made to Answers, Calls, Targets and Users in TeamHaven.

Integration Events are exposed through a Microsoft Windows Azure queue. When an update is made, TeamHaven adds a new message containing a JSON representation of an IntegrationEvent instance to the queue. The IntegrationEvent contains information identifying the changed object's type and unique identifier which can in turn be used by the third party system to determine what action should be taken.

Authorisation

Before it can process messages from the event queue, an application must first obtain an authorisation token. A token and all the other necessary connection information can be obtained using the following API call:

GET /api/events/authorisation

This will return a simple JSON object:

{
  Token: '?sv=2014-02-14&si=ThirdPartyAccess&sig=hblA4fGlhx4m%2FOcbeS5vlzHceMv7l78bvClRoTaQHMQ%3D',
  Expires: '2014-05-22T01:41:59.4187326Z',
  QueueName: 'events-1234',
  StorageUri:
  {
    PrimaryUri: 'https://teamhaven.queue.core.windows.net',
    SecondaryUri: 'https://teamhaven-secondary.queue.core.windows.net'
  }
}

The application can continue to use the token without requesting a new one until the expiry time has passed, at which point the token will cease to operate and a new one must be obtained. It is recommended that the application renews the token at least 5 minutes before it expires avoid any access problems.

Retrieving messages from the queue

See the standard Microsoft Windows Azure Storage Queue documentation for full information.

Once a CloudQueue instance has been created, GetMessage can be used to retrieve the next message from the queue. Once a message has been successfully processed, use DeleteMessage to remove it from the queue.

IntegrationEvent instances

The contents of messages in the event queue are JSON UTF-8 strings. The JSON representation of an IntegrationEvent looks like this:

{
  Object: { ObjectType: 12, ObjectID: 12345 }, // The object that was changed
  EventType: 4                                // What kind of change was made
  User: { AccountID: 23, UserID: 45 },        // Who made the change
  Timestamp: '2014-05-22T01:41:59.4187326Z'   // When the change occurred
}

The following ObjectType values may appear:

  • 7 Object is a User (Not currently implemented)
  • 10 Object is a Project Target (Not currently implemented)
  • 12 Object is a Call

The following EventType values may appear:

  • 1 Object was created (Not currently implemented)
  • 2 Object was updated (Not currently implemented)
  • 3 Object was deleted (Not currently implemented)
  • 4 Call's Answers were Created or Updated

Clone this wiki locally