0.0.3 • Published 10 years ago

node-jivesbs-rest v0.0.3

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

node-jivesbs-rest

REST API and Feed Wrapper for Jive SBS 4.5. This module uses the require module, xml2js and basic auth to communicate with Jive SBS 4.5 and its REST service.

Before using this wrapper, you must enable feeds and the rest API itself in the admin console.

Using node-jivesbs-rest

$ npm install node-jivesbs-rest

With it now installed in your project:

settings =
    user      : "admin"
    pass      : "jive"
    url       : "https://jivesbs.company.com"
    strictSSL : true

JiveContainer = require 'node-jivesbs-rest'

jive = new JiveContainer(settings)

getGroups

is a prototype function of the JiveContainer class. It takes a callback (err, data), where data is the JSON results from Jive.

jive.getGroups (err, json)->
  if err
    console.log err
  else
    console.log json[id].name[0] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    ID: [ '1' ],
    objectType: [ '700' ],
    uuid: [ '' ],
    version: [ '1' ],
    contentTypesIDs: [ ... ],
    creationDate: [ '2011-05-23T09:46:20.687-05:00' ],
    description: [ 'This is a group' ],
    displayName: [ 'first-group' ],
    modificationDate: [ '2013-08-21T10:52:42.068-05:00' ],
    name: [ 'First Group' ],
    typeID: [ '0' ],
    userID: [ '2000' ]
  },
  {
    ID: [ '2' ],
    ...
  }
  ...
]

getCommunities

is a prototype function of the JiveContainer class. It takes a callback (err, json), where json is the RESTful results from Jive.

jive.getCommunities (err, json)->
  if err
    console.log err
  else
    console.log json[id].name[0] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    ID: [ '2175' ],
    objectType: [ '14' ],
    uuid: [ '' ],
    version: [ '1' ],
    availableContentTypes: [ ... ],
    contentTypes: [ ... ],
    creationDate: [ '2012-11-12T10:05:25.645-06:00' ],
    displayName: [ 'community_1' ],
    modificationDate: [ '2013-05-29T09:57:14.215-05:00' ],
    name: [ 'Community 1' ],
    communityCount: [ '0' ],
    communityDepth: [ '1' ],
    ...
  },
  {
    ID: ['10'],
    ...
  }
  ...
]

getCommunityDocuments

is a prototype function of the JiveContainer class. It takes a communityId string and a callback (err, json), where json is the RESTful results from Jive.

jive.getCommunityDocuments '1234', (err, json)->
  if err
    console.log err
  else
    console.log json[id].name[0] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    ID: [ '1207' ],
    objectType: [ '102' ],
    version: [ '1' ],
    body: [ '...' ],
    commentStatus: [ '2' ],
    containerID: [ '2222' ],
    containerType: [ '14' ],
    creationDate: [ '2010-12-06T06:08:38.401-06:00' ],
    documentID: [ 'DOC-1207' ],
    ...,
    language: [ 'en' ],
    modificationDate: [ '2010-12-06T06:13:12.523-06:00' ],
    subject: [ 'Document Subject Line' ],
    textBody: [ 'true' ],
    viewCount: [ '24' ]
  },
  {
    subject: ['Another community Document'],
    ...
  }
  ...
]

getAttachments

is a prototype function of the JiveContainer class. It takes a document ID string and a callback (err, json), where json is the RESTful results from Jive. jsonx.data0 will always contain the binary data for an existing attachment. json will be an empty set if there are no attachments for the given document Id.

jive.getAttachments '1234', (err, json)->
  if err
    console.log err
  else
    console.log json[id] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    ID: [ '4274' ],
    objectType: [ '13' ],
    uuid: [ '' ],
    version: [ '1' ],
    contentType: [ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ],
    data: [ [ 'BINARY' ] ],
    name: [ 'Attachment.docx' ]
  },
  {
    name: ['Another attachment.docx'],
    ...
  }
  ...
]

getBinaryDocuments

is a prototype function of the JiveContainer class. It takes a document ID string and a callback (err, json), where json is the RESTful results from Jive. jsonx.data0 will always contain the binary data for an existing attachment. json will be an empty set if there is no binary file for the given document Id.

jive.getBinaryDocument '1234', (err, json)->
  if err
    console.log err
  else
    console.log json.data[0]

The data returned looks something like this.

{
  ID: [ '11564' ],
  objectType: [ '110' ],
  uuid: [ '' ],
  version: [ '1' ],
  contentType: [ 'application/pdf' ],
  data: [ 'BINARY' ],
  downloadCount: [ '0' ],
  name: [ 'Document.pdf' ],
  size: [ '85315' ]
}

getGroupDocuments

is a prototype function of the JiveContainer class. It takes a groupId string and a callback (err, json), where json is the RESTful results from Jive.

jive.getGroupDocuments '1234', (err, json)->
  if err
    console.log err
  else
    console.log json[id].title[0] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    title: [ 'A Group Document' ],
    link: [ 'https://jive.server.com/docs/DOC-1624' ],
    description: [ '...' ],
    category: [ ... ],
    ...,
    pubDate: [ 'Wed, 22 Dec 2010 15:22:36 GMT' ],
    author: [ 'admin@jive.server.com' ],
    guid: [ 'https://jive.server.com/docs/DOC-1624' ]
  },
  {
    title: ['Another Group Document'],
    ...
  }
  ...
]

getPersonalDocuments

is a prototype function of the JiveContainer class. It takes an account string and a callback (err, json), where json is the results from Jive's feed. Note: this uses RSS since there is no straight forward API for this. Because of the way 4.5's RSS feed works providing an invalid username will still provide results in some cases. Therefore, verify your username before running this, for consistency.

jive.getPersonalDocuments 'username', (err, json)->
  if err
    console.log err
  else
    console.log json[id].title[0] for id of json

The data returned looks something like this. The "..." indicates a continuation:

[
  {
    title: [ 'A Group Document' ],
    link: [ 'https://jive.server.com/docs/DOC-1624' ],
    description: [ '...' ],
    category: [ ... ],
    ...,
    pubDate: [ 'Wed, 22 Dec 2010 15:22:36 GMT' ],
    author: [ 'admin@jive.server.com' ],
    guid: [ 'https://jive.server.com/docs/DOC-1624' ]
  },
  {
    title: ['Another Group Document'],
    ...
  }
  ...
]