3.1.22 • Published 3 years ago

node-sparky v3.1.22

Weekly downloads
303
License
MIT
Repository
github
Last release
3 years ago

node-sparky

NPM

Cisco Spark SDK for Node JS (Version 3)

var Spark = require('node-sparky');

var spark = new Spark({ token: '<my token>' });

spark.roomsGet(10)
  .then(function(rooms) {
    // process rooms as array
    rooms.forEach(function(room) {
      console.log(room.title);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

If you are coming from using node-sparky version 2.x or earlier, note that the architecture, commands, and some variable names have changed. While this release is similar to previous versions, there are some major differences. Please read the API docs below before migrating your code to this release. If you are looking for the old release version, node-sparky@2.0.27 is still available to be installed through NPM.

Features

  • Built in rate limiter and outbound queue that allows control over the number of parallel API calls and the minimum time between each call.
  • Transparently handles 429 (and/or other customizable) http errors and re-queues those requests.
  • File processor for retrieving attachments from room.
  • Event emitters tied to request, response, error, retry, and queue drops.
  • Returns promises that comply with A+ standards..
  • Handles pagination transparently. (Receive unlimited records)
  • (new) Support for Spark API Advanced Webhooks
  • (new) Support Teams API
  • (new) Support for markdown formatted messages
  • (new) Support for authenticated HMAC-SHA1 webhooks

Installation

This module can be installed via NPM:

npm install node-sparky --save

Reference

Initialization and Configuration

var Spark = require('node-sparky');

var spark = new Spark({
  token: 'mytoken',
  webhookUrl: 'http://mywebhook.url/path',
});

Classes

Objects

Events

Spark

Kind: global class
Throw: Error Throws on spark token missing in options object.

new Spark(options)

Creates a Spark API instance that is then attached to a Spark Account.

ParamTypeDescription
optionsObjectConfiguration object containing Spark settings

spark.options : object

Options Object

Kind: instance namespace of Spark
Properties

NameTypeDefaultDescription
tokenstringSpark Token.
webhookUrlstringURL that is used for SPark API to send callbacks.
webhookSecretstringIf specified, creates webhooks using this secret. The incoming webhook must still be authenticated. See Spark.webhookAuth().
maxPageItemsnumber50Max results that the paginator uses.
maxConcurrentnumber3Max concurrent sessions to the Spark API
minTimenumber600Min time between consecutive request starts.
requeueMinTimenumberminTime*10Min time between consecutive request starts of requests that have been re-queued.
requeueMaxRetrynumber3Msx number of atteempts to make for failed request.
requeueCodesarray429,500,503Array of http result codes that should be retried.
requestTimeoutnumber20000Timeout for an individual request recieving a response.
queueSizenumber10000Size of the buffer that holds outbound requests.
requeueSizenumber10000Size of the buffer that holds outbound re-queue requests.

spark.roomsGet(max) ⇒ Promise.<Array>

Return all Spark Rooms registered to account.

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.roomsGet(10)
  .then(function(rooms) {
    // process rooms as array
    rooms.forEach(function(room) {
      console.log(room.title);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomsDirect(max) ⇒ Promise.<Array>

Return all Spark 1:1 Rooms.

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.roomsDirect(10)
  .then(function(rooms) {
    // process rooms as array
    rooms.forEach(function(room) {
      console.log(room.title);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomsGroup(max) ⇒ Promise.<Array>

Return all Spark Group Rooms.

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.roomsGroup(10)
  .then(function(rooms) {
    // process rooms as array
    rooms.forEach(function(room) {
      console.log(room.title);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomsByTeam(teamId, max) ⇒ Promise.<Array>

Return all Spark Rooms for a particular Team ID.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringThe Spark Team ID
maxIntegerNumber of records to return

Example

spark.roomsByTeam('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 10)
  .then(function(rooms) {
    // process rooms as array
    rooms.forEach(function(room) {
      console.log(room.title);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomGet(roomId) ⇒ Promise.<Room>

Return details of Spark Room by ID.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID

Example

spark.roomGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(room) {
    console.log(room.title);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomAdd(title) ⇒ Promise.<Room>

Add new Spark Room.

Kind: instance method of Spark

ParamTypeDescription
titleStringTitle for new Room

Example

spark.roomAdd('myroom')
  .then(function(room) {
    console.log(room.title);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomRename(roomId, title) ⇒ Promise.<Room>

Rename Spark Room.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
titleStringTitle for new Room

Example

spark.roomRename('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'myroom2')
  .then(function(room) {
    console.log(room.title);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.roomRemove(roomId) ⇒ Promise

Remove Spark Room by ID.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID

Example

spark.roomRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Room removed.');
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.peopleSearch(displayName, max) ⇒ Promise.<Array>

Search Spark for People by display name.

Kind: instance method of Spark

ParamTypeDescription
displayNameStringSearch String to find as display name
maxIntegerNumber of records to return

Example

spark.peopleSearch('John', 10)
  .then(function(people) {
    // process people as array
    people.forEach(function(person) {
      console.log(person.displayName);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.personGet(personId) ⇒ Promise.<Person>

Return details of Spark User by ID.

Kind: instance method of Spark

ParamTypeDescription
personIdStringSpark Person ID

Example

spark.personGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(person) {
    console.log(person.displayName);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.personMe() ⇒ Promise.<Person>

Return details of Spark User that has authenticated.

Kind: instance method of Spark
Example

spark.personMe()
  .then(function(person) {
    console.log(person.displayName);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.personByEmail(email) ⇒ Promise.<Person>

Return details of Spark User by Email.

Kind: instance method of Spark

ParamTypeDescription
emailStringEmail address of Spark User

Example

spark.personByEmail('aperson@company.com')
  .then(function(person) {
    console.log(person.displayName);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.attachmentActionGet(attachmentActionId) ⇒ Promise.<AttachmentAction>

Return details of an attachment action by ID.

Kind: instance method of Spark
Returns: Promise.<AttachmentAction> - AttachmentAction object

ParamTypeDescription
attachmentActionIdStringAttachmentAction ID

Example

spark.attachmentActionGet('Tm90aGluZyB0byBzZWUgaGVy')
  .then(attachmentAction => console.log(attachmentAction))
  .catch(err => console.error(err));

spark.attachmentActionCreate(attachmentAction) ⇒ Promise.<AttachmentAction>

Create an Attachment Action.

Kind: instance method of Spark
Returns: Promise.<AttachmentAction> - AttachmentAction object

ParamTypeDescription
attachmentActionObject.<AttachmentAction>Attachment Action to create

Example

const newAttachmentAction = {
  type: 'submit',
  messageId: 'Tm90aGluZyB0byBzZWUgaGVy',
  "inputs": {
     "Name": "John Andersen",
     "Url": "https://example.com",
     "Email": "john.andersen@example.com",
     "Tel": "+1 408 526 7209"
    }
}

spark.attachmentActionCreate(newAttachmentAction)
  .then(attachmentAction => console.log(attachmentAction.id))
  .catch(err => console.error(err));

spark.messagesGet(roomId, max) ⇒ Promise.<Array>

Return messages in a Spark Room.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
maxIntegerNumber of records to return

Example

spark.messagesGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 100)
  .then(function(messages) {
    // process messages as array
    messages.forEach(function(message) {
      console.log(message.text);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.messageGet(messageId) ⇒ Promise.<Message>

Return details of Spark Message by ID.

Kind: instance method of Spark

ParamTypeDescription
messageIdStringSpark Message ID

Example

spark.messageGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 100)
  .then(function(message) {
    console.log(message.text);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.messageSendPerson(email, message) ⇒ Promise.<Message>

Sends 1:1 Spark message to a person.

Kind: instance method of Spark

ParamTypeDescription
emailStringEmail address of Spark User
messageObjectMessage Object

Example

spark.messageSendPerson('aperson@company.com', {
    text: 'Hello!',
    files: ['http://company.com/myfile.doc']
  })
  .then(function(message) {
    console.log('Message sent: %s', message.txt) ;
  })
  .catch(function(err){
    console.log(err);
  });

spark.messageSendRoom(roomId, message) ⇒ Promise.<Message>

Sends Spark message to a room.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
messageObjectMessage Object

Example

spark.messageSendRoom('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', {
    text: 'Hello!',
    files: ['http://company.com/myfile.doc']
  })
  .then(function(message) {
    console.log('Message sent: %s', message.txt);
  })
  .catch(function(err){
    console.log(err);
  });

spark.messageStreamRoom(roomId, message) ⇒ Promise.<Message>

Streams Spark message to a room.

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
messageObjectMessage Object

Example

var roomId = 'Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u';
var text = 'Hello';
var filename = 'test.png';
var stream = fs.createReadStream(filename);
var message = { 'text': text, 'filename': filename, 'stream': stream };
spark.messageStreamRoom(roomId, message)
  .then(function(message) {
    console.log('Message sent: %s', message.txt);
  })
  .catch(function(err){
    console.log(err);
  });

spark.upload(roomId, filepath) ⇒ Promise.<Message>

Upload a file by path to Spark Room

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
filepathStringpath to file

Example

var roomId = 'Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u';
spark.upload(roomId, '/some/local/file.png');

spark.messageRemove(messageId) ⇒ Promise

Remove Spark Message by ID.

Kind: instance method of Spark

ParamTypeDescription
messageIdStringSpark Message ID

Example

spark.messageRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Message removed.');
  })
  .catch(function(err){
    console.log(err);
  });

spark.contentGet(id) ⇒ Promise.<File>

Return details of Spark File by Content ID.

Kind: instance method of Spark

ParamTypeDescription
idStringSpark Content ID

Example

spark.contentGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(file) {
    console.log('File name: %s', file.name);
  })
  .catch(function(err){
    console.log(err);
  });

spark.contentByUrl(url) ⇒ Promise.<File>

Return details of Spark File by Spark Content URL.

Kind: instance method of Spark

ParamTypeDescription
urlStringSpark Content URL

Example

spark.contentByUrl('http://api.ciscospark.com/v1/contents/Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(file) {
    console.log('File name: %s', file.name);
  })
  .catch(function(err){
    console.log(err);
  });

spark.teamsGet(max) ⇒ Promise.<Array>

Return all Spark Teams registered to account.

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.teamsGet(10)
  .then(function(teams) {
    // process teams as array
    teams.forEach(function(team) {
      console.log(team.name);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamGet(teamId) ⇒ Promise.<Team>

Return details of Spark Team by ID.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID

Example

spark.teamGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(team) {
    console.log(team.name);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamAdd(name) ⇒ Promise.<Team>

Add new Spark Team.

Kind: instance method of Spark

ParamTypeDescription
nameStringName for new Team

Example

spark.teamAdd('myteam')
  .then(function(team) {
    console.log(team.name);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamRoomAdd(teamId, title) ⇒ Promise.<Room>

Add new Spark Team Room.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID
titleStringTitle for new Room

Example

spark.teamRoomAdd('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'myroom')
  .then(function(room) {
    console.log(room.title);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamRename(teamId, name) ⇒ Promise.<Team>

Rename a Spark Team.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID
nameStringName for new Team

Example

spark.teamRename('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'myteam2')
  .then(function(team) {
    console.log(team.name);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamRemove(teamId) ⇒ Promise

Remove Spark Team by ID.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID

Example

spark.teamRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Team removed.');
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamMembershipsGet(teamId, max) ⇒ Promise.<Array>

Return all Spark Team Memberships for a specific Team.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID
maxIntegerNumber of records to return

Example

spark.teamMembershipsGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 100)
  .then(function(memberships) {
    // process memberships as array
    memberships.forEach(function(membership) {
      console.log(membership.personEmail);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.teamMembershipGet(membershipId) ⇒ Promise.<TeamMembership>

Return Spark Team Membership by ID.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.membershipGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log(membership.personEmail);
  })
  .catch(function(err){
    console.log(err);
  });

spark.teamMembershipAdd(teamId, email, moderator) ⇒ Promise.<TeamMembership>

Add new Spark Team Membership.

Kind: instance method of Spark

ParamTypeDescription
teamIdStringSpark Team ID
emailStringEmail address of person to add
moderatorBooleanBoolean value to add as moderator

Example

spark.teamMembershipAdd('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'aperson@company.com')
  .then(function(membership) {
    console.log(membership.id);
  })
  .catch(function(err){
    console.log(err);
  });

spark.teamMembershipSetModerator(membershipId) ⇒ Promise.<TeamMembership>

Set a Team Membership as moderator.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.teamMembershipSetModerator('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log('%s is a moderator: %s', membership.personEmail, membership.isModerator);
  })
  .catch(function(err){
    console.log(err);
  });

spark.teamMembershipClearModerator(membershipId) ⇒ Promise.<TeamMembership>

Remove a Team Membership as moderator.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.teamMembershipClearModerator('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log('%s is a moderator: %s', membership.personEmail, membership.isModerator);
  })
  .catch(function(err){
    console.log(err);
  });

spark.teamMembershipRemove(membershipId) ⇒ Promise

Remove Spark Team Membership by ID..

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.teamMembershipRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Membership removed');
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipsGet(max) ⇒ Promise.<Array>

Return all Spark Memberships registered to account..

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.membershipsGet(100)
  .then(function(memberships) {
    // process memberships as array
    memberships.forEach(function(membership) {
      console.log(membership.personEmail);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.membershipsByRoom(roomId, max) ⇒ Promise.<Array>

Return all Spark Memberships in a Spark Room..

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
maxIntegerNumber of records to return

Example

spark.membershipsByRoom('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 100)
  .then(function(memberships) {
    // process memberships as array
    memberships.forEach(function(membership) {
      console.log(membership.personEmail);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.membershipGet(membershipId) ⇒ Promise.<Membership>

Return Spark Membership by ID..

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.membershipGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log(membership.personEmail);
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipByRoomByEmail(roomId, personEmail) ⇒ Promise.<Membership>

Return Spark Membership by Room and Email..

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Membership ID
personEmailStringEmail of Person

Example

spark.membershipByRoomByEmail('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'aperson@company.com')
  .then(function(membership) {
    console.log(membership.id);
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipAdd(roomId, email, moderator) ⇒ Promise.<Membership>

Add new Spark Membership..

Kind: instance method of Spark

ParamTypeDescription
roomIdStringSpark Room ID
emailStringEmail address of person to add
moderatorBooleanBoolean value to add as moderator

Example

spark.membershipAdd('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u', 'aperson@company.com')
  .then(function(membership) {
    console.log(membership.id);
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipSetModerator(membershipId) ⇒ Promise.<Membership>

Set a Membership as moderator.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.membershipSetModerator('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log('%s is a moderator: %s', membership.personEmail, membership.isModerator);
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipClearModerator(membershipId) ⇒ Promise.<Membership>

Remove a Membership as moderator.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.membershipClearModerator('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(membership) {
    console.log('%s is a moderator: %s', membership.personEmail, membership.isModerator);
  })
  .catch(function(err){
    console.log(err);
  });

spark.membershipRemove(membershipId) ⇒ Promise

Remove Spark Membership by ID.

Kind: instance method of Spark

ParamTypeDescription
membershipIdStringSpark Membership ID

Example

spark.membershipRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Membership removed');
  })
  .catch(function(err){
    console.log(err);
  });

spark.webhooksGet(max) ⇒ Promise.<Array>

Return all Spark Webhooks registered to account.

Kind: instance method of Spark

ParamTypeDescription
maxIntegerNumber of records to return

Example

spark.webhooksGet(100)
  .then(function(webhooks) {
    // process webhooks as array
    webhooks.forEach(function(webhook) {
      console.log(webhook.name);
    });
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.webhookGet(webhookId) ⇒ Promise.<Webhook>

Return details of Spark Webhook by ID.

Kind: instance method of Spark

ParamTypeDescription
webhookIdStringSpark Webhook ID

Example

spark.webhookGet('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(webhook) {
    console.log(webhook.name);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.webhookAdd(resource, event, name, filter) ⇒ Promise.<Webhook>

Add new Spark Webhook.

Kind: instance method of Spark

ParamTypeDescription
resourceStringResource for webhook
eventStringEvent for webhook
nameStringName assigned to webhook to add
filterStringfilter

Example

spark.webhookAdd('messages', 'created', 'mywebhook', 'Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function(webhook) {
    console.log(webhook.name);
  })
  .catch(function(err) {
    // process error
    console.log(err);
  });

spark.webhookRemove(webhookId) ⇒ Promise

Remove Spark Webhook by ID.

Kind: instance method of Spark

ParamTypeDescription
webhookIdStringSpark Webhook ID.

Example

spark.webhookRemove('Tm90aGluZyB0byBzZWUgaGVyZS4uLiBNb3ZlIGFsb25nLi4u')
  .then(function() {
    console.log('Webhook removed');
  })
  .catch(function(err){
    console.log(err);
  });

spark.webhookAuth(signature, payload) ⇒ Boolen

Authenticate X-Spark-Signature HMAC-SHA1 Hash.

Kind: instance method of Spark

ParamTypeDescription
signatureStringValue of "X-Spark-Signature" from header
payloadString | ObjectThis can either be the json object or a string representation of the webhook's body json payload

Example

var sig = req.headers['x-spark-signature'];
if(spark.webhookAuth(sig, req.body)) {
  // webhook is valid
} else {
  // webhook is invalid
}

Room : object

Room Object

Kind: global namespace
Properties

NameTypeDescription
idstringRoom ID
titlestringRoom Title
typestringRoom Type
isLockedbooleanRoom Moderated/Locked
teamIdstringTeam ID
lastActivitydateLast Activity in Room
createddateRoom Created

Person : object

Person Object

Kind: global namespace
Properties

NameTypeDescription
idstringPerson ID
emailsarrayEmails
displayNamestringDisplay Name
avatarstringAvatar URL
createddateDate created
emailstringEmail
usernamestringUsername
domainstringDomain name

Message : object

Message Object

Kind: global namespace
Properties

NameTypeDescription
idstringMessage ID
personIdstringPerson ID
personEmailstringPerson Email
roomIdstringRoom ID
textstringMessage text
filesarrayArray of File objects
createddateDate Message created

File : object

File Object

Kind: global namespace
Properties

NameTypeDescription
idstringSpark API Content ID
namestringFile name
extstringFile extension
typestringHeader content-type for file
binarybufferFile contents as binary
base64stringFile contents as base64 encoded string

Team : object

Team Object

Kind: global namespace
Properties

NameTypeDescription
idstringMessage ID
namestringTeam name
createddateDate Team created

TeamMembership : object

Team Membership Object

Kind: global namespace
Properties

NameTypeDescription
idstringMembership ID
teamIdstringTeam ID
personIdstringPerson ID
personEmailstringPerson Email
isModeratorbooleanMembership is a moderator
createddateDate Membership created

Membership : object

Membership Object

Kind: global namespace
Properties

NameTypeDescription
idstringMembership ID
personIdstringPerson ID
personEmailstringPerson Email
isModeratorbooleanMembership is a moderator
isMonitorbooleanMembership is a monitor
createddateDate Membership created

Webhook : object

Webhook Object

Kind: global namespace
Properties

NameTypeDescription
idstringWebhook ID
namestringWebhook name
targetUrlstringWebhook target URL
resourcebooleanWebhook resource
eventbooleanWebhook event
filterbooleanWebhook filter
createddateDate Webhook created

Validator : object

Spark Validation functions.

Kind: global namespace

Validator.isEmail(email) ⇒ Boolean

Validate String is Email.

Kind: static method of Validator

ParamType
emailString

Validator.isUrl(url) ⇒ Boolean

Validate String is URL.

Kind: static method of Validator

ParamType
urlString

Validator.isFilePath(path) ⇒ Boolean

Validate String is File path.

Kind: static method of Validator

ParamType
pathString

Validator.isRoom(object) ⇒ Boolean

Validate Spark Room Object.

Kind: static method of Validator

ParamType
objectRoom

Validator.isPerson(object) ⇒ Boolean

Validate Spark Person Object.

Kind: static method of Validator

ParamType
objectRoom

Validator.isMessage(object) ⇒ Boolean

Validate Spark Message Object.

Kind: static method of Validator

ParamType
objectMessage

Validator.isMembership(object) ⇒ Boolean

Validate Spark Membership Object.

Kind: static method of Validator

ParamType
objectMembership

Validator.isWebhook(object) ⇒ Boolean

Validate Spark Webhook Object.

Kind: static method of Validator

ParamType
objectWebhook

Validator.isTeam(object) ⇒ Boolean

Validate Spark Team Object.

Kind: static method of Validator

ParamType
objectTeam

Validator.isRooms(rooms) ⇒ Boolean

Validate Spark Room Objects in Array.

Kind: static method of Validator

ParamType
roomsArray

Validator.isPeople(persons) ⇒ Boolean

Validate Spark Person Objects in Array.

Kind: static method of Validator

ParamType
personsArray

Validator.isMessages(messages) ⇒ Boolean

Validate Spark Message Objects in Array.

Kind: static method of Validator

ParamType
messagesArray

Validator.isMemberships(memberships) ⇒ Boolean

Validate Spark Membership Objects in Array.

Kind: static method of Validator

ParamType
membershipsArray

Validator.isWebhooks(webhooks) ⇒ Boolean

Validate Spark Webhook Objects in Array.

Kind: static method of Validator

ParamType
webhooksArray

Validator.isTeams(teams) ⇒ Boolean

Validate Spark Team Objects in Array.

Kind: static method of Validator

ParamType
teamsArray

"drop"

Spark Queue Drop Event.

Kind: event emitted
Properties

NameTypeDescription
requestoptionsAPI Request
idstringSpark UUID

"request"

Spark request event.

Kind: event emitted
Properties

NameTypeDescription
requestoptionsAPI Request
idstringSpark UUID

"reponse"

Spark response event.

Kind: event emitted
Properties

NameTypeDescription
responseoptionsResponse
idstringSpark UUID

"retry"

Spark retry event.

Kind: event emitted
Properties

NameTypeDescription
requestoptionsAPI Request
idstringSpark UUID

License

The MIT License (MIT)

Copyright (c) 2016-2017

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3.1.22

3 years ago

4.6.0

4 years ago

4.5.0

4 years ago

3.1.21

4 years ago

3.1.20

4 years ago

4.4.0

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.9

5 years ago

4.1.8

5 years ago

4.1.7

5 years ago

4.1.6

5 years ago

4.1.5

5 years ago

4.1.4

5 years ago

4.1.3

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.0.10

5 years ago

4.0.9

5 years ago

4.0.8

5 years ago

4.0.7

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.1.19

5 years ago

3.1.18

6 years ago

3.1.17

6 years ago

3.1.16

6 years ago

3.1.15

6 years ago

3.1.14

6 years ago

3.1.13

6 years ago

3.1.12

6 years ago

3.1.11

6 years ago

3.1.10

6 years ago

3.1.9

6 years ago

3.1.8

6 years ago

3.1.7

6 years ago

3.1.6

6 years ago

3.1.5

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.27

6 years ago

2.0.26

6 years ago

2.0.25

6 years ago

2.0.24

6 years ago

2.0.23

6 years ago

2.0.22

6 years ago

2.0.21

6 years ago

2.0.20

6 years ago

2.0.19

6 years ago

2.0.18

6 years ago

2.0.17

6 years ago

2.0.15

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.45

6 years ago

1.0.44

6 years ago

1.0.43

6 years ago

1.0.42

6 years ago

1.0.41

6 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago