@plasma-platform/service-collections
v3.5.0
Published
Collections Service api
Downloads
15
Readme
Full documentation
install:npm i @plasma-platform/service-collections -S
Short documentation
Table of Contents
- CollectionsService
CollectionsService
- See: //api.templatemonster.com/collection/v2/
collections Micro Service API that you may adopt for your needs
Parameters
url
string service urltoken
(string | null) user access tocken if available (optional, defaultnull
)
messages
Object with class service messages
Type: Object
getCollectionById
Get collection information specified by collection_id
Parameters
id
string collection id
Examples
Read collection info
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
const collection = await collections.getCollectionById('hgm1t2ltgyi7dim9nvo0');
})();
Returns Collection collection object
getColectionItemsById
Get list of collection items of collection specified by collection_id
Examples
Read collection items list
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
const items = await collections.getColectionItemsById('mfsgxst31slvddqz0miv');
})();
Returns object array of items
getCollectionsOfUser
Get list of collections of user
Parameters
Examples
Get Favorites Collection
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
const items = await collections.getCollectionsOfUser();
})();
Returns object collections
postCollection
Add new collection
Parameters
name
string collection name
Examples
Create collection
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
const item = await collections.postCollection('Favorites');
})();
Returns Collection collection object
postItem
Add new collection item
Parameters
Examples
Favorite item
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
const item = await collections.postItem('mfsgxst31slvddqz0miv', 'template-67020');
})();
Returns object record in the collection
deleteItem
Delete Collection Item
Parameters
id
number id of the record in the collection
Examples
Remove from collection
(async () => {
const collections = new CollectionsService('//api.templatemonster.com/collection/v2/');
await collections.deleteItem(2342);
})();
getCollections
Get list of collections
Parameters
params
object object of params.
Examples
(async () => {
const service = new CollectionsService(serviceUrl);
const collections = await service.getCollections(params);
})();
Returns object collection list & pagination
getMyCollections
Get my list of collections
Parameters
params
object object of params.
Examples
(async () => {
const service = new CollectionsService(serviceUrl);
const collections = await service.getCollections(params);
})();
Returns object collection list & pagination
mergeCollections
Collection - Merge Collections
Parameters
targetCollectionId
string Target collection unique ID.sourceCollectionId
string Source collection unique ID.
Examples
(async () => {
const service = new CollectionsService(serviceUrl);
const collections = await service.mergeCollections(targetCollectionId, sourceCollectionId);
})();
Returns object collection data