1.2.0 • Published 5 months ago
signagesolutions-sdk v1.2.0
SignageSolutions SDK
Installation browser
File can be found in the dist folder.
<script src="/dist/signagesolutions-browser.js" type="text/javascript"></script>
Installation Node.js
npm install signagesolutions-sdk
import SignageSolutions from 'signagesolutions-sdk';
Usage
try {
const ss = await SignageSolutions({
apiKey: 'your_api_key',
});
// Your logic
} catch (err) {
console.error(err);
}
API Methods
listPlayers()
Returns an array with players and all the data.
try {
const players = await ss.listPlayers();
console.log(players);
// [{
// token: String
// name: String
// allowedUsers: [
// '1234567890' // user id
// ],
// lastTimeOnline: Datetime
// _id: String
// online: Boolean
// subscriptionValidUntil: Datetime,
// numberOfCampaigns: Number,
// status: String // 'no_data' | 'no_campaigns' | 'player_schedule' | 'campaign_schedule' | 'downloading' | 'playing'
// info: {
// location: {
// latitude: Number | null
// longitude: Number | null
// updated: Datetime | null
// }
// },
// }]
} catch (err) {
console.error(err);
}
getPlayer(playerId)
try {
const player = await ss.getPlayer('1234567890');
// {
// "info": {
// "location": {
// "latitude": Number | null,
// "longitude": Number| null,
// "updated": Datetime | null
// },
// "network": {
// "wlan": {
// "ip": String
// "mac": String
// "ssid": String
// "bssid": String
// "strength": Number
// },
// "ethernet": {
// "ip": String
// "mac": String
// }
// },
// "systemVersion": String
// "os": String
// "osVersion": String
// "brand": String
// "modelName": String
// "sdkVersion": String
// "serial": String
// "appVersion": String
// "rooted": Boolean,
// "campaignStatus": String
// "campaignStatusSince": String
// "timezone": String
// "freeDiskSpace": Number
// "totalDiskSpace": Number
// "totalMemory": Number
// },
// "schedule": {
// "mondayStart": String
// "mondayFinish": String
// "tuesdayStart": String
// "tuesdayFinish": String
// "wednesdayStart": String
// "wednesdayFinish": String
// "thursdayStart": String
// "thursdayFinish": String
// "fridayStart": String
// "fridayFinish": String
// "saturdayStart": String
// "saturdayFinish": String
// "sundayStart": String
// "sundayFinish": String
// },
// "_id": String
// "token": String
// "name": String
// "allowedUsers": [],
// "subscriptionValidUntil": Datetime,
// "lastTimeOnline": Datetime,
// "tags": [
// {
// "_id": String
// "title": String
// "tagType": String
// }
// ],
// "isBlocked": Boolean,
// "invoiceReference": String
// "screenOrientation": 0 | 180,
// "updatedAt": Datetime,
// "online": Boolean
// }
console.log(players);
} catch (err) {
console.error(err);
}
listCampaigns()
Returns an array with all the campaigns.
try {
const campaigns = await ss.listCampaigns();
console.log(campaigns);
// {
// campaigns: [{
// title: String
// readyForPublication: Boolean // used in smart publishing to determine if campaign should be used
// _id: String
// tags: [{
// titleInsensitive: String
// tagType: String
// description: String
// _id: String
// }],
// }]
// }
} catch (err) {
console.error(err);
}
listCampaignsForPlayer(playerId)
Returns an array with campaigns of given player, returns all the campaign data.
try {
const playerId = '1234567890';
const campaigns = await ss.listCampaignsForPlayer(playerId);
console.log(campaigns);
// [
// {
// _id: String
// schedule: {
// dateStart: String // Start date of schedule, empty string means no start date
// dateEnd: String // End date of schedule, empty string means no end date
// mondayStart: String
// mondayFinish: String
// tuesdayStart: String
// tuesdayFinish: String
// wednesdayStart: String
// wednesdayFinish: String
// thursdayStart: String
// thursdayFinish: String
// fridayStart: String
// fridayFinish: String
// saturdayStart: String
// saturdayFinish: String
// sundayStart: String
// sundayFinish: String
// },
// campaign: {
// _id: String
// title: String
// },
// player: String // player id
// order: Number
// type: String // background | normal | priority
// }
// ]
} catch (err) {
console.error(err);
}
listPlayersForCampaign(campaignId)
Returns an array with players of given campaign, returns all the player data.
try {
const campaignId = '1234567890';
const players = await ss.listPlayersForCampaign(campaignId);
console.log(players);
// [
// {
// schedule: {
// dateStart: "", // Start date of schedule, empty string means no start date
// dateEnd: "", // End date of schedule, empty string means no end date
// mondayStart: "00:00" // Start time of campaign on monday
// mondayFinish: "24:00" // End time of campaign on monday
// tuesdayStart: "00:00",
// tuesdayFinish: "24:00",
// wednesdayStart: "00:00",
// wednesdayFinish: "24:00",
// thursdayStart: "00:00",
// thursdayFinish: "24:00",
// fridayStart: "00:00",
// fridayFinish: "24:00",
// saturdayStart: "00:00",
// saturdayFinish: "24:00",
// sundayStart: "00:00",
// sundayFinish: "24:00"
// },
// order: Number // Order to play campaign in
// type: background | normal | priority
// _id: String
// createdAt: Datetime
// updatedAt: Datetime
// player: {
// screenshotConfig: {
// enabled: Boolean
// delay: Number // in seconds, defaults to 3600
// deleteAfter: Number // Amount of days to keep screenshots, defaults to 30
// },
// info: {
// network: {
// wlan: {
// ip: String
// mac: String
// },
// ethernet: {
// ip: String
// mac: String
// }
// },
// androidVersion: String
// androidSDK: String
// },
// schedule: {
// mondayStart: String
// mondayFinish: String
// tuesdayStart: String
// tuesdayFinish: String
// wednesdayStart: String
// wednesdayFinish: String
// thursdayStart: String
// thursdayFinish: String
// fridayStart: String
// fridayFinish: String
// saturdayStart: String
// saturdayFinish: String
// sundayStart: String
// sundayFinish: String
// },
// token: String
// name: String
// backgroundcolor: String // defaults to "ffffff",
// remarks: String
// nameInsensitive: String
// user: String // user id of owner
// organization: String // organization id of owner
// allowedUsers: [],
// subscriptionStartDate: Datetime
// subscriptionValidUntil: Datetime
// subscriptionBilledUntil: Datetime
// subscriptionStatus: active | expired
// subscriptionRenewalStatus: String // forbidden | ask | cancelled | renew | always-renew
// reboot: Boolean // when true the player will reboot every day at "rebootHour"
// rebootHour: String // first 2 chars of 24 time anotation, defaults to "00"
// lastTimeOnline: Datetime
// tags: [],
// _id: String
// online: Boolean
// outOfSync: Boolean // when player is online but hasn't received an update in a hour
// createdAt: Datetime
// updatedAt: Datetime
// }
// }
// ]
} catch (err) {
console.error(err);
}
assignCampaignToPlayers(campaignId, data)
Assigns a campaign to one or more players.
const campaignId = '1234567890';
const data = {
players: [], // player id's
};
// All (optional) default values
const data = {
players: ["1234567890"], // player id's
silentUpdate: false, // true will not tell player to update the current content
values: {
schedule: {
sundayStart: "00:00", sundayFinish: "24:00",
mondayStart: "00:00", mondayFinish: "24:00",
tuesdayStart: "00:00", tuesdayFinish: "24:00",
wednesdayStart: "00:00", wednesdayFinish: "24:00",
thursdayStart: "00:00", thursdayFinish: "24:00",
fridayStart: "00:00", fridayFinish: "24:00",
saturdayStart: "00:00", saturdayFinish: "24:00",
},
geo: { latitude: 1, longitude: 1, radius: -1 }
type: "normal" // possible values: background|normal|priority
order: 0
}
};
try {
const result = await ss.assignCampaignToPlayers(campaignId, data);
console.log(result);
// {
// status: 'ok',
// }
} catch (err) {
console.error(err);
}
removeCampaignFromPlayer(campaignId, playerId, silentUpdate)
Remove a campaign from a player.
const campaignId = '1234567890';
const playerId = '1234567890';
const silentUpdate = false; // true will not tell player to update the current content
try {
const result = await ss.removeCampaignFromPlayer(campaignId, playerId, silentUpdate);
console.log(result);
// {
// status: 'ok',
// }
} catch (err) {
console.error(err);
}
setOrder(playerId, campaigns, silentUpdate)
Set the order of campaigns on a player, list the campaigns in order of appearance.
const playerId = '1234567890';
const campaignsIds = ['1234567890', '2345678901'];
const silentUpdate = false; // true will not tell player to update the current content
try {
const result = await ss.setOrder(playerId, campaignsIds, silentUpdate);
console.log(result);
// {
// status: 'ok',
// }
} catch (err) {
console.error(err);
}
notifyUpdate(playerId)
Tell player to check for new content
try {
const playerId = '1234567890';
const result = await ss.notifyUpdate(playerId);
console.log(result);
// {
// status: 'ok',
// }
} catch (err) {
console.error(err);
}
setTags(playerId, tags, action)
Set the tags on a player. Only available when tagging is enabled by organisation. If tag doesn't exists in the list it will be created.
try {
const playerId = '1234567890';
const tags = ['tag1', 'tag2']; // lowercased tag names
const action = 'add'; // possible values: add|remove|set
const result = await ss.setTags(playerId, tags, action);
console.log(result);
// {
// status: 'ok',
// }
} catch (err) {
console.error(err);
}