import OlapicUsersHandler from 'olapic-devkit/src/core/entities/user/user.handler.js'
OlapicUsersHandler
Extends:
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 |
entityFromJSON(json: Object): OlapicUserEntity It parses a raw API JSON information and returns a user entity. |
|
public static |
getInstagramUserForCustomer(customer: OlapicCustomerEntity, username: string): Promise<OlapicUserEntity, Error> Gets an Olapic user linked to an Instagram account for an Olapic customer. |
|
public static |
getUserByID(ID: String): Promise<OlapicUserEntity, Error> Gets an Olapic user by its unique ID. |
|
public static |
getUserByUrl(url: String): Promise<OlapicUserEntity, Error> Gets an Olapic user by its API url. |
|
public static |
getUserUploadUrl(user: OlapicUserEntity): String Gets a user url to upload content to Olapic. |
Inherited Summary
From class OlapicEntitiesHandler | ||
public static get |
DevKit: OlapicDevKit: * A quick shortcut to get access to the DevKit singleton. |
|
public static |
getFormsFromObject(obj: Object): Object This will be used when creating an entity to parse any list of action forms and returns them with a better format. |
|
public static |
getResourcesFromObject(obj: Object): Object 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:
Name | Type | Attribute | Description |
json | Object | The raw API JSON object to parse. |
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:
Name | Type | Attribute | Description |
customer | OlapicCustomerEntity | The customer owner of the user. |
|
username | string | The instagram username. |
Return:
Promise<OlapicUserEntity, Error> | The user entity or an |
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:
Name | Type | Attribute | Description |
ID | String | The user ID. |
Return:
Promise<OlapicUserEntity, Error> | The user entity or an |
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:
Name | Type | Attribute | Description |
url | String | The Olapic API url for the user. |
Return:
Promise<OlapicUserEntity, Error> | The user entity or an |
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:
Name | Type | Attribute | Description |
user | OlapicUserEntity | The user from which the url will be created. |