1.0.0 • Published 4 years ago

klouddisplay-node-sdk v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 years ago

README

What is this repository for?

This repository is for an SDK to KloudDisplay

Created Dec 14th 2019 - Version 1.0.0

How do I get set up?

  • Checkout the repository
  • Navigate to the klouddisplay-node-sdk directory
  • Run npm install to install dependencies
  • Your SDK is now ready to be used
  • Navigate to test directory
  • Run node client.js

The SDK should connect to KloudDisplay server running on your host and interact with it (sending events, announcements etc).

What are the pre-requisites to use this SDK?

  • You need to have a valid account on KloudDisplay
  • You need to get ID and SecretKey from your Account -> Settings -> Third Party Integration page
  • You should have at least one KloudDisplay configured under your account

How do I use this SDK?

Using the SDK is pretty straight forward. Here is a sample code to import the SDK and connect to KloudDisplay


//1) Import KloudDisplay library (from wherever it is located)
var KLOUDDISPLAY = require('../lib/klouddisplay');

//2) Create a KloudDisplay client by providing the ID and SecretKey (can get one from your Account Settings page)
var displayclient = new KLOUDDISPLAY({
	'host': '<your kloudspot instance baseurl>',
	'id': '<your kloudspot clientID>',
	'secretKey': '<your kloudspot clientSecret>'
});

//3) Send an event to KloudDisplay (Payload should contain appropriate parameters)
var eventPayload = {
		"deviceId": "0a:0a:0a:00:00:27",
		"age": 12,
		"gender": "female"
	};
displayclient.sendEvent(eventPayload, function(response) {
	console.log(response);
});

//4) Or Send an announcement to KloudDisplay
var eventPayload = {
		"terminals": [
      		"736f42f0921d456c8089c399b3ce915c"
      	],
      	"announcement": "Potential shooter in the building !!",
      	"priority": "critical",
      	"startTime" : moment().valueOf(),
      	"endTime" : moment().add(2, 'hours').valueOf(),
      	"location" : null
	};

displayclient.sendAnnouncement(eventPayload, function(response) {
	console.log(response);
});

//Tip: KloudDisplay SDK also supports Promises. The above call can also be accomplished like this:
displayclient.sendAnnouncement(eventPayload).then(function(response) {
	console.log(response);
});

//Tip: If you are familiar with async/await, youc an wrap the above code inside of an async function and await on the result.
async function notifyEmergency() {
	var response = await displayclient.sendAnnouncement(eventPayload);
	//Do something with this response
	console.log(response);
}

Who do I talk to?

For any further questions on using the SDK, please contact -

  • Uday Pyda (uday@kloudspot.com)