ipdigital-sdk

2.0.2 • Public • Published

IPDigital SDK

Installation browser

File can be found in the dist folder.

<script src="/dist/ipdigital.js" type="text/javascript"></script>

Installation Node.js

npm install ipdigital-sdk

import IPDigital from 'ipdigital-sdk';

Usage

try {
  const ipd = await IPDigital({
    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 ipd.listPlayers();

  console.log(players);
  // [{
  //   token: String
  //   name: String
  //   allowedUsers: [
  //     '1234567890' // user id
  //   ],
  //   lastTimeOnline: Datetime
  //   _id: String
  //   online: Boolean
  //   subscriptionValidUntil: Datetime,
  //   numberOfCampaigns: Number,
  // }]
} catch (err) {
  console.error(err);
}

listCampaigns()

Returns an array with all the campaigns.

try {
  const campaigns = await ipd.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 ipd.listCampaignsForPlayer(playerId);

  console.log(campaigns);
  // [
  //   {
  //     _id: String
  //     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"
  //     },
  //     campaign: {
  //       _id: String
  //       title: String
  //     },
  //     player: String // player id
  //     order: Number // Order to play campaign in
  //     type: String // Type of campaign, possible values: 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 ipd.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: String // Type of campaign, possible values: 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: "00:00", // Device schedule, outside of these times the device will be offline
  //         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",
  //         sundayStart: "00:00",
  //         sundayFinish: "24:00"
  //       },
  //       token: String // unique token of player
  //       name: String
  //       backgroundcolor: String // Background color of screen, 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: String // possible values: active|expired
  //       subscriptionRenewalStatus: String // possible values:  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 ipd.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 ipd.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 ipd.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 ipd.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 ipd.setTags(playerId, tags, action);

  console.log(result);

  // {
  //   status: 'ok',
  // }
} catch (err) {
  console.error(err);
}

Package Sidebar

Install

npm i ipdigital-sdk

Weekly Downloads

2

Version

2.0.2

License

GPL

Unpacked Size

15.1 kB

Total Files

4

Last publish

Collaborators

  • signagesolutions