OpenPlatform / 05. API
Updated: 05. November 2018
Author: Peter Širka

05. API

Service Account

OpenPlatform supports common access token for so-called Service Account. Service Account has Super Admin privileges, so it can read apps, users and modify them.

Access Token in x-token header:

x-token    : k9l055zsuuehyta0fz2ua51kfua99fiq8z704bpw
  • if the token is valid the request will be authorized
  • auth mechanism contains a simple protection for attacks of brute force

Allowed API:

You can found all endpoints in controllers/api.js file declared in authorize group.

Events

The events below can be captured on server-side.

Events for Apps

ON('apps.create', function(app) {
    // New app is created
});

ON('apps.update', function(app) {
    // App is updated
});

ON('apps.remove', function(app) {
    // App is removed
});

ON('apps.sync', function(app) {
       // App meta (openplatform.json) is downloaded and synchronized 
});

ON('apps.refresh', function(app) {
    // Some app/apps are refreshed
    // @app {Application} Optional
});

ON('apps.backup', function(users) {
    // All apps will be stored in JSON file on HDD
});

Events for Users

ON('users.notify', function(user, app) {
     // Received some notification 
    // @user {Object} user instance
    // @app {Object} app instance
});

ON('users.badge', function(user, app) {
     // Received badge 
    // @user {Object} user instance
    // @app {Object} app instance
});

ON('users.create', function(user) {
     // New user is created
    // @user {Object} user instance
});

ON('users.update', function(user, type) {
     // User is updated
    // @user {Object} user instance
    // @type {String} optional, can contain "account"
});

ON('users.refresh', function(user) {
    // Some user/users are refreshed
    // @user {Application} Optional
});

ON('users.unread', function(user) {
   // User will obtain email notification about unread notifications/badges 
});

ON('users.backup', function(users) {
    // All users will be stored in JSON file on HDD
});

ON('users.meta', function(meta) {
    // Internal codelist has been changed
    meta.companies;    // Array
    meta.customers;    // Array
    meta.localities;   // Array
    meta.groups;       // Array
    meta.roles;        // Array
    meta.languages;    // Array
    meta.ou;           // Array
});