Skip to content

SDK for 3rd party developers wanting to use the Skrumble API in their Javascript SPA.

License

Notifications You must be signed in to change notification settings

Skrumble/js-sdk

Repository files navigation

Skrumble API Join the chat at https://gitter.im/Skrumble/js-sdk

Installation

The JS SDK is distributed through the npm registry, which means it can be installed with npm. In a bash window, run:

npm i --save @skrumble/js-sdk 

Or to install with yarn, run:

yarn add @skrumble/js-sdk

Usage

The SDK supports multiple formats for loading, depending on your environment:

UMD

var {
  Chat,
  APISocket
} = require('@skrumble/js-sdk')

ES6

import {
  Chat, 
  APISocket
} from '@skrumble/js-sdk'

In case your environment doesn't support either, the SDK also exports a global called Skrumble, which contains the same classes as properties:

let Chat = Skrumble.Chat    
let APISocket = Skrumble.APISocket

Configuring & Logging-in

First you'll need:

  1. Client credentials from the Skrumble Developer portal. See the Managing Applications guide for more about generating creds
  2. Hostnames for the environment you're using, see the Environment URLs guide for a reference
import {
  Chat,
  APISocket
} from '@skrumble/js-sdk';
let registeredUser, loadedChat

APISocket.config({ 
  client_id: "iK47Sr....",
  client_secret: "$2y$10$J...", 
  api_hostname: "sandbox.skrumble.com",
  auth_hostname: "sandbox-auth.skrumble.com"
})

try {
  registeredUser = await APISocket.login({
    email: "skrumble_user@example.com",
    password: "123456"
  })
} catch(err) {
  throw new Error(err);  
}

try {
  chatList = await Chat.getAll();
} catch(err) {
  throw new Error(err);
}

console.log(`Logged in as ${registeredUser.first_name}, found chat list of ${chatList}`); 

Contributing

The SDK is an open-source project, so Pull Requests and bug reports are encouraged. Before contributing, see the Github Issues page to ensure your issue/feature isn't a duplicate, and consult the CONTRIBUTING.md doc for information about contribution guidelines as well as the feature roadmap.

About

SDK for 3rd party developers wanting to use the Skrumble API in their Javascript SPA.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published