0.1.2 • Published 5 years ago
thingspro-cloud v0.1.2
ThingsPro Cloud SDK for Node.js
An API wrapper for the ThingsPro Cloud API.
Installation
yarn add thingspro-cloud-sdk
Getting started
Import the module and create a new client. Passing api urls is optional if you need call private cloud service.
const tpc = require('thingspro-cloud-sdk')()
// Optional: change the api server url
tpc.setServerUrl({
admin: 'https://api.thingsprocloud.com/admin-api/v1',
dsc: 'https://api.thingsprocloud.com/dsc/v1',
dlm: 'https://api.thingsprocloud.com/api/v1',
rtm: 'https://api.thingsprocloud.com/rtm/v1',
pic: 'https://pic.thingsprocloud.com/api/v1',
sr: 'https://repo.thingsprocloud.com/api/v1'
})
// login dlm with email and password
await tpc.dlm().login('guest@thingsprocloud.com', 'your_password')
// get logged in user profile
console.log(tpc.dlm().me)
// get all projects
console.log((await tpc.dlm().project.get())
Table of Contents
Admin API
admin login
Login admin api with email and password.
await tpc.admin().login('guest@thingsprocloud.com', 'password')
const me = tpc.admin().me
console.log(me)
admin logout
Logout admin api.
await tpc.admin().logout()
const me = tpc.admin().me
console.log(me)
admin me
get logged in user profile.
const me = tpc.admin().me
console.log(me)
admin request
get axios instance with logged in session.
const request = tpc.admin().request
const companies = await tpc.admin().request.get('/companys')
console.log(companies)
{
companyId: '22237172-cd34-474a-bc4d-8a0070597b77',
createdAt: '2020-04-07T01:32:10.512430Z',
dashboard: { layout: [ [Object], [Object], [Object], [Object], [Object] ] },
name: 'MOXA',
status: 'enable',
updatedAt: '2020-04-07T01:32:10.512430Z'
}
DSC API
dsc login
Login dsc api with email and password.
await tpc.dsc().login('guest@thingsprocloud.com', 'password')
const me = tpc.dsc().me
console.log(me)
dsc logout
Logout dsc api.
await tpc.dsc().logout()
const me = tpc.dsc().me
console.log(me)
dsc me
get logged in user profile.
const me = tpc.dsc().me
console.log(me)
dsc request
get axios instance with logged in session.
const request = tpc.dsc().request
const projects = await tpc.dsc().request.get('/projects')
console.log(projects)
[
{
createdAt: '2020-11-26T09:16:07.585323Z',
description: '',
name: '[test] Practical Fresh Shoes',
projectId: '073f329f-7edd-4651-8d6f-a998b04771dd',
updatedAt: '2020-11-26T09:16:07.585323Z',
userList: [ [Object], [Object], [Object] ]
}
]
DLM API
dlm login
Login dlm api with email and password.
await tpc.dlm().login('guest@thingsprocloud.com', 'password')
const me = tpc.dlm().me
console.log(me)
dlm logout
Logout dlm api.
await tpc.dlm().logout()
const me = tpc.dlm().me
console.log(me)
dlm me
get logged in user profile.
const me = tpc.dlm().me
console.log(me)
dlm request
get axios instance with logged in session.
const request = tpc.dlm().request
const projects = await tpc.dlm().request.get('/projects')
console.log(projects)
[
{
createdAt: '2020-11-26T09:16:07.585323Z',
description: '',
name: '[test] Practical Fresh Shoes',
projectId: '073f329f-7edd-4651-8d6f-a998b04771dd',
updatedAt: '2020-11-26T09:16:07.585323Z',
userList: [ [Object], [Object], [Object] ]
}
]