@black-mirror/sdk
v0.3.0
Published
The black mirror SDK for the API.
Downloads
60
Readme
Black mirror SDK
The black mirror SDK allows the developers to use the SDK and let it handle the requests instead of making the API calls.
Getting started
To install the package, run the command:
npm install --save @black-mirror/sdk
Sdk
To import the sdk
import * as sdk from '@black-mirror/sdk';
Get the settings
This will get the settings from the server.
api.settings.retrieve();
It will return as a promise that resolve to:
const result = {
id: 1,
type: 'settings',
attributes: {
timezone: 'America\/Toronto',
hour12: true,
interval_ms: 1000
}
}
Updates the settings
This will update the settings on the server and send a broadcast to all the subscribed websockets.
api.settings.update({
timezone: 'America/Toronto',
hour12: false,
interval_ms: 500
});
It will return as a promise that resolve to:
const result = {
id: 1,
type: "settings",
attributes: {
timezone: "America\/Toronto",
hour12: false,
interval_ms: 500
}
}
Get the timezones
This will get the settings from the server.
api.settings.timezones();
The first result will return a promise with:
const result = [
'Africa\/Abidjan',
'Africa\/Accra',
'Africa\/Addis_Ababa',
'Africa\/Algiers',
'Africa\/Asmara',
'Africa\/Bamako',
'Africa\/Bangui',
// ...
]
You can also search the timezones with:
api.settings.timezones('toro');
It will return a promise that resolves to:
const result = [
'America\/Toronto'
]