ue-node-sdk

1.0.16 • Public • Published

unificationengine-client NPM version Build Status Dependency Status

A UnificationEngine client SDK for NodeJS

Here's how simple it is to post a message on your wall and a Facebook page, in a single call:

connection.sendMessage({
    "receivers":[
        {"name":"me"},
        {"name":"Page", "id":"122"}
    ],
    "message":{"body": "Hello World!"}
});

Installation

$ npm install --save ue-node-sdk

Usage

var UEClient = require('ue-node-sdk');
 
var app = new UEClient("APP_KEY","APP_SECRET");

Creating User

app.createUser()
.then(function(user){
   //user is a User object
})
.catch(function(err){
   //Handle error
});

Listing Users

app.listUsers()
.then(function(users){
   //users is an array of User objects
})
.catch(function(err){
   //Handle error
});

Deleting User

app.deleteUser(user)
.then(function(){
    //user deleted succesfully
})
.catch(function(err){
   //Handle error
});

Adding a connection to a user

user.addConnection(connectionName, service, serviceAccessToken, optionalParams)
.then(function(connection){
    //connection is a Connection object
})
.catch(function(err){
   //Handle error
});
  • connectionName must be unique per connection.
  • serviceAccessToken has to be valid and working from the provider side
  • optionalParams an object with key:value pair

Listing User connections

user.listConnections()
.then(function(connections){
    //connections is an array of Connection objects
})
.catch(function(err){
   //Handle error
});

Removing a User Connection

user.removeConnection(connectionName)
.then(function(){
    //connection removed successfully
})
.catch(function(err){
   //Handle error
});

Testing a connection

user.testConnection(serviceUrl) //eg: facebook://accesstoken@facebook.com
.then(function(){
    //serviceUrl is valid and can be added as a conncetion
})
.catch(function(err){
   //Handle error
});

Sending a message using a connection

connection.sendMessage({
  "receivers":[
    {
     "name":"me"
    },
    {
     "name":"Page",
     "id":"122"
    }
  ],
  "message":{
    "subject":"test",
    "body": "ABC",            
    "image":"http://imageUrl",
    "link":{
      "uri": "http://google.com",
      "description": "link desc",
      "title":"link title"
    }
  }
})
.then(function(uris){
    console.log(uris); //URIs of the sent messages
})
.catch(function(err){
    //handle error
});
 

Package Sidebar

Install

npm i ue-node-sdk

Weekly Downloads

5

Version

1.0.16

License

Apache-2.0

Last publish

Collaborators

  • daedlock
  • jijoamt