import OlapicCustomersHandler from 'OlapicDevKit-ES6/src/core/entities/customer/customer.handler.js'
OlapicCustomersHandler
Extends:
The entities handler for the Olapic customers in DevKit.
Static Method Summary
Static Public Methods | ||
public static |
createUserForCustomer(customer: OlapicCustomerEntity, name: String, email: String): Promise<OlapicUserEntity, Error> Creates a new user to upload media for a customer. |
|
public static |
entityFromJSON(json: Object): OlapicCustomerEntity It parses a raw API JSON information and returns a customer entity. |
|
public static |
Gets an Olapic customer by its unique ID. |
|
public static |
Gets an Olapic customer by its API url. |
|
public static |
getUserFromCustomer(customer: OlapicCustomerEntity): Promise<OlapicUserEntity, Error> Gets a user to upload media for a customer. |
|
public static |
searchCategoryFromCustomer(customer: OlapicCustomerEntity, tag: String): Promise<OlapicCategoryEntity, Error> Searchs for a customer category based on its tag key. |
|
public static |
searchStreamFromCustomer(customer: OlapicCustomerEntity, tag: String): Promise<OlapicStreamEntity, Error> Searchs for a customer stream based on its tag key. |
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 createUserForCustomer(customer: OlapicCustomerEntity, name: String, email: String): Promise<OlapicUserEntity, Error> source
Creates a new user to upload media for a customer.
Params:
Name | Type | Attribute | Description |
customer | OlapicCustomerEntity | The customer entity for which the user will be created. |
|
name | String | The new user name. |
|
String | The new user email address. |
Return:
Promise<OlapicUserEntity, Error> | A promise with the user entity or an |
Example:
OlapicCustomersHandler.createUserForCustomer(customerEntity, 'myName', '[email protected]')
.then((user) => {
console.log(user.get('name'));
});
public static entityFromJSON(json: Object): OlapicCustomerEntity source
It parses a raw API JSON information and returns a customer entity.
Params:
Name | Type | Attribute | Description |
json | Object | The raw API JSON object to parse. |
Example:
let JSONInfo = {
metadata: {},
data: {
name: 'Olapic Customer',
},
};
let customer = OlapicCustomersHandler.entityFromJSON(JSONInfo);
// It will log 'Olapic Customer'
console.log(customer.get('name'));
public static getCustomerByID(ID: Number): Promise<OlapicCustomerEntity, Error> source
Gets an Olapic customer by its unique ID.
Params:
Name | Type | Attribute | Description |
ID | Number | The customer ID. |
Return:
Promise<OlapicCustomerEntity, Error> | The customer entity or an |
Example:
OlapicCustomersHandler.getCustomerByID(12)
.then((customer) => {
console.log('Customer: ', customer);
});
public static getCustomerByUrl(url: String): Promise<OlapicCustomerEntity, Error> source
Gets an Olapic customer by its API url.
Params:
Name | Type | Attribute | Description |
url | String | The Olapic API url for the customer. |
Return:
Promise<OlapicCustomerEntity, Error> | The customer entity or an |
Example:
OlapicCustomersHandler.getCustomerByUrl('http://...')
.then((customer) => {
console.log('Customer: ', customer);
});
public static getUserFromCustomer(customer: OlapicCustomerEntity): Promise<OlapicUserEntity, Error> source
Gets a user to upload media for a customer.
Params:
Name | Type | Attribute | Description |
customer | OlapicCustomerEntity | The customer entity for which the user will be obtained. |
Return:
Promise<OlapicUserEntity, Error> | A promise with the user entity or an |
Example:
OlapicCustomersHandler.getUserFromCustomer(customerEntity)
.then((user) {
console.log(user.get('name'));
});
public static searchCategoryFromCustomer(customer: OlapicCustomerEntity, tag: String): Promise<OlapicCategoryEntity, Error> source
Searchs for a customer category based on its tag key.
Params:
Name | Type | Attribute | Description |
customer | OlapicCustomerEntity | The customer owner of the category. |
|
tag | String | The category tag key. |
Return:
Promise<OlapicCategoryEntity, Error> | A promise with the catgory entity or an
|
Example:
OlapicCustomersHandler.searchCategoryFromCustomer(customerEntity, 'shoes')
.then((category) => {
console.log(category.get('name'));
});
public static searchStreamFromCustomer(customer: OlapicCustomerEntity, tag: String): Promise<OlapicStreamEntity, Error> source
Searchs for a customer stream based on its tag key.
Params:
Name | Type | Attribute | Description |
customer | OlapicCustomerEntity | The customer owner of the stream. |
|
tag | String | The stream tag key. |
Return:
Promise<OlapicStreamEntity, Error> | A promise with the stream entity or an |
Example:
OlapicCustomersHandler.searchStreamFromCustomer(customerEntity, 'shoes').then((stream) => {
console.log(stream.get('name'));
});