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
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
First you'll need:
- Client credentials from the Skrumble Developer portal. See the Managing Applications guide for more about generating creds
- 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}`);
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.