Home Reference Source Repository
public class | source

OlapicUsersHandler

Extends:

OlapicEntitiesHandler → OlapicUsersHandler

The entities handler for the Olapic users in DevKit. It's basically a set of static methods used to create and obtain users from the API or DevKit itself.

Static Method Summary

Static Public Methods
public static

It parses a raw API JSON information and returns a user entity.

public static

Gets an Olapic user linked to an Instagram account for an Olapic customer.

public static

Gets an Olapic user by its unique ID.

public static

Gets an Olapic user by its API url.

public static

Gets a user url to upload content to Olapic.

Inherited Summary

From class OlapicEntitiesHandler
public static get

A quick shortcut to get access to the DevKit singleton.

public static

This will be used when creating an entity to parse any list of action forms and returns them with a better format.

public static

This will be used when creating an entity to parse any list of linked entities and returns them with a better format.

Static Public Methods

public static entityFromJSON(json: Object): OlapicUserEntity source

It parses a raw API JSON information and returns a user entity.

Params:

NameTypeAttributeDescription
json Object

The raw API JSON object to parse.

Return:

OlapicUserEntity

The entity created from the JSON information.

Example:

let JSONInfo = {
    metadata: {},
    data: {
        name: 'Admin',
    },
};
let user = OlapicUsersHandler.entityFromJSON(JSONInfo);
// It will log 'Admin'
console.log(user.get('name'));

public static getInstagramUserForCustomer(customer: OlapicCustomerEntity, username: string): Promise<OlapicUserEntity, Error> source

Gets an Olapic user linked to an Instagram account for an Olapic customer.

Params:

NameTypeAttributeDescription
customer OlapicCustomerEntity

The customer owner of the user.

username string

The instagram username.

Return:

Promise<OlapicUserEntity, Error>

The user entity or an Error object if something goes wrong.

Example:

OlapicUsersHandler.getInstagramUserForCustomer(customerEntity, 'olapic')
.then((user) => {
    console.log('User: ', user);
});

public static getUserByID(ID: String): Promise<OlapicUserEntity, Error> source

Gets an Olapic user by its unique ID.

Params:

NameTypeAttributeDescription
ID String

The user ID.

Return:

Promise<OlapicUserEntity, Error>

The user entity or an Error object if something goes wrong.

Example:

OlapicUsersHandler.getUserByID(12)
.then((user) => {
    console.log('User: ', user);
});

public static getUserByUrl(url: String): Promise<OlapicUserEntity, Error> source

Gets an Olapic user by its API url.

Params:

NameTypeAttributeDescription
url String

The Olapic API url for the user.

Return:

Promise<OlapicUserEntity, Error>

The user entity or an Error object if something goes wrong.

Example:

OlapicUsersHandler.getUserByUrl('http://...')
.then((user) => {
    console.log('User: ', user);
});

public static getUserUploadUrl(user: OlapicUserEntity): String source

Gets a user url to upload content to Olapic.

Params:

NameTypeAttributeDescription
user OlapicUserEntity

The user from which the url will be created.

Return:

String

The upload url for the user.