Skip to content

mattnorrisdev/spark-js-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spark-js-sdk

Greenkeeper badge

npm license Build status

The Cisco Spark JavaScript SDK

This is a monorepo containing all officially maintained Cisco Spark JavaScript SDK modules in the same repo.

ciscospark is a collection of node modules targeting our external APIs.

Install

We test against the current LTS version of Node.js (6.10) but the SDK should work with any supported version of Node.js.

To install the latest stable version from NPM:

npm install --save ciscospark

Usage

To use the SDK, you will need Cisco Spark credentials. If you do not already have a Cisco Spark account, visit Spark for Developers to create your account and retrieve your access token.

See the detailed docs for more usage examples.

Node.js

You will need to set the following environment variable:

  • CISCOSPARK_ACCESS_TOKEN
const assert = require(`assert`);
assert(process.env.CISCOSPARK_ACCESS_TOKEN, 'This example assumes you have set your access token as an environment variable');
const ciscospark = require(`ciscospark`);
ciscospark.rooms.create({title: `My First Room`})
  .then((room) => {
    return Promise.all([
      ciscospark.memberships.create({
        roomId: room.id,
        personEmail: `[email protected]`
      }),
      ciscospark.memberships.create({
        roomId: room.id,
        personEmail: `[email protected]`
      }),
    ])
      .then(() => ciscospark.messages.create({
        markdown: `**Hi Everyone**`,
        roomId: room.id
      }));
  });

Browsers

We do not provide a pre-built version of ciscospark.

If you've already got a commonjs or es6 build process in place, you can simply use const ciscospark = require('ciscospark').

If you need to load ciscospark via a script tag, you will need to build it first:

npm install ciscospark
npm install -g browserify
echo "window.ciscospark = require('ciscospark')" > ./index.js
browserify index.js > bundle.js

In-browser usage is pretty much the same as Node.js usage, with the addition of handling the user authentication flow for you. See the guide on the docs site for more information.

Samples

Sample code can be found in packages/node_modules/samples. You can run them yourself with the following commands:

Note: this installs all of the SDK's tooling dependencies, so you'll need libgcrypt and (possibly) graphicsmagick. On a mac, you can install these with brew install graphicsmagick libgrcrypt.

git clone [email protected]:ciscospark/spark-js-sdk.git
cd spark-js-sdk
npm install
npm run samples:serve

You'll be able to load the samples by visiting https://localhost:8000/packages/node_modules/samples/<PACKAGE NAME>.

Available Samples

Sample App Link Source
Implicit Grant Flow local app code
Single Party Calling local app code
Single Party Calling with Mute local app code
Multi Party Calling local app code
Call with Content Sharing local app code

Contribute

Pull requests welcome. Please see CONTRIBUTING.md for more details about building the packages and submitting pull requests for suggested changes.

License

© 2016-2018 Cisco and/or its affiliates. All Rights Reserved.

See LICENSE for details.

Packages

No packages published

Languages

  • JavaScript 83.3%
  • Shell 16.7%