README
Allthings Node/Javascript SDK
Contents
Installation & Usage
yarn add @allthings/sdk
const allthings = require('@allthings/sdk')
const client = allthings.restSdk({
accessToken: '043dab7447450772example1214b552838003522',
})
client.getCurrentUser().then(viewer =>
console.log(`Welcome back ${viewer.username}!`)
)
Configuration
Configuration Options
The available configuration options are outlined here:
Option | Default | Description |
---|---|---|
accessToken | API Access Token | |
clientId | OAuth 2.0 clientId | |
clientSecret | OAuth 2.0 client secret | |
username | Username to use with OAuth 2.0 Password Grant authentication flow | |
password | Password to use with OAuth 2.0 Password Grant authentication flow | |
concurrency | Number of concurrent requests to perform in parallel. Default behavior is burst of 30/s, 1/s thereafter |
OAuth Implicit Grant Example
@TODO
const allthings = require('@allthings/sdk')
const client = allthings.restSdk({
accessToken: '043dab7447450772example1214b552838003522',
})
client.getCurrentUser().then(viewer =>
console.log(`Welcome back ${viewer.username}!`)
)
API
Allthings SDK module
restSdk()
client.createAgent()
client.createAgentPermissions()
client.createApp()
client.createIdLookup()
client.createGroup()
client.getGroupById()
client.updateGroupById()
client.createProperty()
client.getPropertyById()
client.updatePropertyById()
client.createRegistrationCode()
client.createUnit()
client.getUnitById()
client.createUser()
client.createUserPermission()
client.deleteUserPermission()
client.getUsers()
client.getCurrentUser()
client.getUserById()
client.getUserPermissions()
client.updateUserById()
client.createUtilisationPeriod()
client.getUtilisationPeriodById()
client.updateUtilisationPeriodById()
client.delete()
client.get()
client.post()
client.patch()
restSdk(configurationOptions?): Client
Create an client instance of the SDK.
const allthings = require('@allthings/sdk')
const client = allthings.restSdk(configurationOptions)
client.createAgent()
Create a new agent. This is a convenience function around creating a user and adding that user to a property-manager's team.
const appId = '575027e58178f56a008b4568'
const propertyManagerId = '5a818c07ef5f2f00441146a2'
const username = 'mr.example@allthings.test'
const agent = await client.createAgent(
appId,
propertyManagerId,
username,
{ email: 'mr.example@allthings.test', locale: 'en_US' }
)
export type MethodCreateAgent = (
appId: string,
propertyManagerId: string,
username: string,
data: PartialUser & {
readonly email: string
readonly locale: EnumLocale
},
) => UserResult
// Describes the API wrapper's resulting interface
export interface InterfaceAllthingsRestApi {
readonly delete: MethodHttpDelete
readonly get: MethodHttpGet
readonly post: MethodHttpPost
readonly patch: MethodHttpPatch
// Agent
/**
* Create a new agent. This is a convenience function around
* creating a user and adding that user to a property-manager's team
*/
readonly createAgent: MethodCreateAgent
/**
* Create agent permissions. This is a convenience function around
* creating two user permission's: one "admin" and the other "pinboard"
*/
readonly createAgentPermissions: MethodCreateAgentPermissions
// App
/**
* Create a new App.
*/
readonly createApp: MethodCreateApp
// ID Lookup
/**
* Map one or more externalId's to API ObjectId's within the scope of a specified App
*/
readonly createIdLookup: MethodCreateIdLookup
// Group
/**
* Create a new group within a property
*/
readonly createGroup: MethodCreateGroup
/**
* Get a group by it's ID
*/
readonly getGroupById: MethodGetGroupById
/**
* Update a group by it's ID
*/
readonly updateGroupById: MethodUpdateGroupById
// Property
/**
* Create a new property
*/
readonly createProperty: MethodCreateProperty
/**
* Get a property by it's ID
*/
readonly getPropertyById: MethodGetPropertyById
/**
* Update a property by it's ID
*/
readonly updatePropertyById: MethodUpdatePropertyById
// Registration Code
/**
* Create a new registration code
*/
readonly createRegistrationCode: MethodCreateRegistrationCode
// Unit
/**
* Create a unit within a group
*/
readonly createUnit: MethodCreateUnit
/**
* Get a unit by it's ID
*/
readonly getUnitById: MethodGetUnitById
/**
* Update a unit by it's ID
*/
readonly updateUnitById: MethodUpdateUnitById
// User
/**
* Create a new User.
*/
readonly createUser: MethodCreateUser
/**
* Give a user a permission/role on an given object of specified type
*/
readonly createUserPermission: MethodCreateUserPermission
/**
* Delete a user a permission/role on an given object of specified type
*/
readonly deleteUserPermission: MethodDeleteUserPermission
/**
* Get a list of users
*/
readonly getUsers: MethodGetUsers
/**
* Get the current user from active session
*/
readonly getCurrentUser: MethodGetCurrentUser
/**
* Get a user by their ID
*/
readonly getUserById: MethodGetUserById
/**
* Get a list of user's permissions
*/
readonly getUserPermissions: MethodGetUserPermissions
/**
* Update a user by their ID
*/
readonly updateUserById: MethodUpdateUserById
// Utilisation Period
/**
* Create a new utilisation period within a Unit
*/
readonly createUtilisationPeriod: MethodCreateUtilisationPeriod
/**
* Get a utilisation period by it's ID
*/
readonly getUtilisationPeriodById: MethodGetUtilisationPeriodById
/**
* Update a utilisation period by it's ID
*/
readonly updateUtilisationPeriodById: MethodUpdateUtilisationPeriodById
}