1.3.0 • Published 8 years ago

turtle-f411418-core v1.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Smooch Core

Smooch Core is the most basic for interaction possible for the Smooch API. It wraps the public API in a convenient Javascript API.

This library is meant to be isomorphic, which means it can be used in the browser and server-side with Node.js. However, the webhooks API and the JWT utils are not available in the browser to reduce the bundle size. Those actions should not be done in the browser anyway.

Installation

$ npm install smooch-core --save

Usage

In the browser (using browserify or webpack)

var SmoochCore = require('smooch-core');

// using app token
var smoochCore = new SmoochCore({
    appToken: 'some-token'
});


// using generated JWT
var smoochCore = new SmoochCore({
    jwt: 'some-jwt'
});

// ...

smoochCore.appUsers.init(options).then(function(response) {
  // do something with the response.
});

Server-side

var SmoochCore = require('smooch-core');

// using app token
var smoochCore = new SmoochCore({
    appToken: 'some-token'
});


// using generated JWT
var smoochCore = new SmoochCore({
    jwt: 'some-jwt'
});

// using JWT components
// Only available server-side. NEVER put your keyId and secret
// in you client-side code.
var smoochCore = new SmoochCore({
    keyId: 'some-key',
    secret: 'some-secret',
    scope: 'appUser', // app or appUser
    userId: 'some-id' // not necessary if scope === 'app'
});

// ...

smoochCore.webhooks.get(id).then(function(response) {
  // do something with the response.
});

API

This is an overview of what the library has to offer. A better documentation will be available soon.

ModuleMethodEndpoint
appUsersinitPOST /v1/init
getGET /v1/appusers/:id
updatePUT /v1/appusers/:id
trackEventPOST /v1/appusers/:id/events
conversationsgetGET /v1/appusers/:id/conversation
sendMessagePOST /v1/appusers/:id/conversation/messages
webhookslistGET /v1/webhooks
createPOST /v1/webhooks
getGET /v1/webhooks/:id
updatePUT /v1/webhooks/:id
deleteDELETE /v1/webhooks/:id