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

csco-spark

v3.2.0

Published

A module that performs tasks using the Cisco Spark API

Downloads

38

Readme

Cisco Spark API Integration

Install
npm install --save csco-spark
Special Note

** This requires NodeJS version 4+ as it utilizes some ES2015 (ES6) features not found in other versions of Node.

Listing Rooms, Memberships, Webhooks, People, and Messages

When retrieving a Spark Users Rooms/Memberships, Webhooks, the Messages in a given Spark Room, and the Memberships in a room where you are the Member of, The Spark API uses Pagination to control the response time of a particular API Call.

In the Library I have implemented Pagination in the retrieval of these objects utilizing NodeJS EventEmitters.

var Spark = require('csco-spark');
var spark = Spark({
  uri: 'https://api.ciscospark.com/v1',
  token: 'Spark Access Token'
});
// Getting Spark Rooms
var listRooms = spark.listItemEvt({
  item: 'rooms',
  max: '15' || undefined // Default = 50
});
// Listen for Rooms
listRooms.on('rooms', function(rooms) {
  console.log(rooms)
});

listRooms.on('rooms-end', function(rooms) {
  // Yes I am sending Data on the End Event
  // I believe most don't
})

Refer to the Examples Listings for utilizing the rest..

General Module Usage

If there are any examples you would like to see..just add an issue and I can get it posted for you...

var sparkFactory = require('csco-spark'),

var spark = sparkFactory({
  uri: 'https://api.ciscospark.com/v1',
  token: 'token'
});

// Send a Message
spark.sendMessage({
  roomId:'roomId',
  text: 'message'
}).then((res) => {
  /*Store the res data?*/
});

// Create a Spark Room
spark.createRoom({ title: 'title'}).then((res) => {
  /*Store the res data?*/
});

// Delete a Room
spark.removeRoom(roomId).then((res) {
  /* resp should be null */
});

// Add User To a Spark Room
spark.addMemberToRoom({
  roomId: 'id',
  personEmail: '[email protected]' || null,
  personId: 'spark personId' || null,
  isModerator: true || false
}).then((resp) => {
  /* handle response */
});

// Download Files from Spark Room
spark.dlFiles('uri of file location', 'optional token').then((resp) => {
  /*
   * RESP is a List of Objects Consisting of the Below:
   * [{fileName: `filename`, blob: `buffered contents of file`}]
   * The buffered contents of the file is ready to be written to disk
   * it is not human readable
   */
});

// Get ALL Messages from a Spark Room
spark.getMessages({ roomId: 'spark roomId'}).then((messages) => {
  /*
   * The LIB handles Pagination for You; it DLs 200 Messages at a time
   * and adds them to a List. All the properties of the Messages object
   * are untouched
   */
});

// Get all the Rooms a Spark User is In
spark.getRooms().then((rooms) => {
  /*
   * Like Messages, pagination is handled for you.
   */
});

// Get Access/Refresh Token
// Authentication on Behalf of a User (Granting App Permissions)
// Refer to https://developer.ciscospark.com/authentication.html
spark.getAccessToken({
  code: 'code received from /authorize step1',
  id: 'application clientId',
  secret: 'application clientSecret',
  redirectUri: 'application redirect_uri'
}).then((resp) => {
  var authData = resp;
  /*
   * {access_token: 'token', refresh_token: 'token', ...}
   */
});