-
Notifications
You must be signed in to change notification settings - Fork 1
/
SearchContent.ts
29 lines (27 loc) · 1.17 KB
/
SearchContent.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
26
27
28
29
import { plainToClass } from "class-transformer";
import { ChainObject } from "../../../models/ChainObject";
import { ContentSummary } from "../../../models/ContentSummary";
import { ObjectType } from "../../../models/ObjectType";
import { SearchContentOrder } from "../../../models/order/SearchContentOrder";
import { assertThrow } from "../../../utils/Utils";
import { ApiGroup } from "../ApiGroup";
import { BaseRequest } from "./BaseRequest";
export class SearchContent extends BaseRequest<ContentSummary[]> {
constructor(
searchTerm: string,
order: SearchContentOrder = SearchContentOrder.CreatedDesc,
user: string,
regionCode: string,
type: string,
startId: ChainObject = ObjectType.Null.genericId(),
limit: number = 100,
) {
super(
ApiGroup.Database,
"search_content",
[searchTerm, order, user, regionCode, type, startId.objectId, limit],
(value: object[]) => plainToClass(ContentSummary, value),
);
assertThrow(startId.objectType === ObjectType.ContentObject || startId.objectType === ObjectType.Null, () => "not a valid content object id");
}
}