-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGetCollectionFeaturedItems.ts
25 lines (22 loc) · 1.21 KB
/
GetCollectionFeaturedItems.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
import { ROOT_COLLECTION_ID } from '../models/Collection'
import { CollectionFeaturedItem } from '../models/CollectionFeaturedItem'
export class GetCollectionFeaturedItems implements UseCase<CollectionFeaturedItem[]> {
private collectionsRepository: ICollectionsRepository
constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}
/**
* Returns a CollectionFeaturedItem array containing the featured items of the requested collection, given the collection identifier or alias.
*
* @param {number | string} [collectionIdOrAlias = ':root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId)
* If this parameter is not set, the default value is: ':root'
* @returns {Promise<CollectionFeaturedItem[]>}
*/
async execute(
collectionIdOrAlias: number | string = ROOT_COLLECTION_ID
): Promise<CollectionFeaturedItem[]> {
return await this.collectionsRepository.getCollectionFeaturedItems(collectionIdOrAlias)
}
}