- Source:
Extends
- ApiBase
Methods
(async) create(categoryObj) → {Promise}
Create a Category.
Parameters:
Name | Type | Description |
---|---|---|
categoryObj |
Entity.CategoryEntity | A Category entity instance. |
- Source:
Returns:
- Type
- Promise
Example
const catData = new CannedIO.entity.category(
null, // id
'my new category', // label
'#ff00ff' // color
);
CannedIO.api.category
.create(catData)
.then(newCat => console.log('success:', newCat.toJSON()))
.catch(error => console.log('something is wrong:', error));
(async) get(categoryId) → {Promise}
Get a Category by ID.
Parameters:
Name | Type | Description |
---|---|---|
categoryId |
string | Category UUID. |
- Source:
Returns:
- Type
- Promise
Example
CannedIO.api.category
.get(categoryId)
.then(cat => console.log('success:', cat.toJSON()))
.catch(error => console.log('something is wrong:', error));
(async) list() → {Promise}
Get all active categories.
- Source:
Returns:
- Type
- Promise
Example
CannedIO.api.category
.list()
.then(list => console.log('I got', list.length, 'categories.'))
.catch(error => console.log('something is wrong:', error));
(async) remove(categoryId) → {Promise}
Remove a category by ID.
Parameters:
Name | Type | Description |
---|---|---|
categoryId |
string | category UUID. |
- Source:
Returns:
- Type
- Promise
Example
CannedIO.api.category
.remove(categoryId)
.then(cat => console.log('success:', cat.toJSON()))
.catch(error => console.log('something is wrong:', error));
(async) update(categoryObj) → {Promise}
Update a Category.
Parameters:
Name | Type | Description |
---|---|---|
categoryObj |
Entity.CategoryEntity | Category entity instance. |
- Source:
Returns:
- Type
- Promise
Example
// update an existing category (you can use a new instance as well).
myCat.label = 'my updated category';
myCat.color = '#00ff00';
CannedIO.api.category
.update(myCat)
.then(updatedCat => console.log('success:', updatedCat.toJSON()))
.catch(error => console.log('something is wrong:', error));