robin-js-sdk

2019-08-22

A JavaScript SDK to communicate with the Robin platform.

Robin JavaScript SDK

A JavaScript SDK to communicate with the Robinplatform.

This SDK provides the ability to communicate both with the Robin API and the Robin Grid.

Installation

node

npm install git@github.com:robinpowered/robin-js-sdk.git --savewill save this to the dependenciessection of your package.json

You may then requirethis sdkas follows:

var Robin = require('robin-js-sdk');
browser

Include the script from https://static.robinpowered.com/js/sdk/$version/robin.browser.min.js, where $versionis the npm version number in package.json. robin-js-sdkwill be automatically attached to the windowobject as window.Robin.

Instantiation

robin-js-sdkis instantiated with two arguments, the first is a Robin Access Token. The second is an optional argument that can be null, a string, an objector undefined.

Options

If the second argument is undefinedor null, this SDKwill be instantiated with endpoints pointing to production.

If it is a string, it must be a valid robinendpoint. Valid values are test, stagingor production. Otherwise an error is thrown.

If it is an object:

  • An empty object will result in all endpoints defaulting to production.
  • If it contains an envproperty, all endpoints will default to that env. Values other than string types for this property will throw errors.
  • If it has a urlsproperty, then values for core, gridor placeswill override the default endpoint for any of those apps. Types for this property other than objectwill throw errors. Properties of this object other than core, gridor placeswill throw errors.

Robin API

The Robin API is a REST based API. Calls to the API return a promise.

Core API Routes:

RouteSource
Accountsaccounts.js
Appsapps.js
Authauth.js
Channelschannels.js
DeviceManifestsdevicemanifests.js
Devicesdevices.js
Identifiersidentifiers.js
Locationslocations.js
Meme.js
Organizationsorganizations.js
Projectsprojects.js
Spacesspaces.js
Triggerstriggers.js
Usersusers.js

Places API Routes:

RouteSource
Eventsevents.js

Robin Grid

_TODO: Improve this section in a future PR_

The Grid is a websocket server that allows PubSub between clients and devices through configured channels. The Grid module is an EventEmitter, to allow real-time updates.

The Grid exposes several modules, which allow you to connect and listen:

  • join- Allows clients to listen to updates from channels
  • leave- Disconnects the client from receiving updates for a particular channel
  • send- Allows a client to send messages to a channel.

Development Roadmap

The following should be implemented:

  • <input checked="" disabled="" type="checkbox"> Support for use in browsers, as well as node.js
  • [ ] Add winston for logging - will this work in browsers?
  • <input checked="" disabled="" type="checkbox"> Handle scope of access tokens for extended functionality (such as retrieving all API items)
  • <input disabled="" type="checkbox"> Adhere to Robin Javascript Coding Standards - this is TBD.
  • <input checked="" disabled="" type="checkbox"> Implement API function arguments based on API documentation
  • <input disabled="" type="checkbox"> Expand documentation to include all API modules
  • <input disabled="" type="checkbox"> Can we autogenerate API module functions based on a object template?

Browserify

Running grunt browsergenerates two files in the browser/folder.

  • browser/robin.browser.jsis the full file after being run through browserify.
  • browser/robin.browser.min.jsis the minified version.

HomePage

https://github.com/robinpowered/robin-js-sdk-public

Repository

https@github.com:robinpowered/robin-js-sdk-public


上一篇:remapify
下一篇:jdy
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部