-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathget-all-request-builder.ts
59 lines (56 loc) · 1.75 KB
/
get-all-request-builder.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { variadicArgumentToArray } from '@sap-cloud-sdk/util';
import { EntityV4 } from '../entity';
import { entityDeserializerV4 } from '../entity-deserializer';
import {
EntityIdentifiable,
Constructable,
Filterable,
and,
ODataGetAllRequestConfig,
Expandable,
GetAllRequestBuilderBase,
toFilterableList,
OneToManyLink
} from '../../odata-common';
import { oDataUriV4 } from '../uri-conversion';
import { responseDataAccessorV4 } from './response-data-accessor';
export class GetAllRequestBuilderV4<EntityT extends EntityV4>
extends GetAllRequestBuilderBase<EntityT>
implements EntityIdentifiable<EntityT> {
readonly _entity: EntityT;
/**
* Creates an instance of GetAllRequestBuilder.
*
* @param entityConstructor - Constructor of the entity to create the request for
*/
constructor(entityConstructor: Constructable<EntityT>) {
super(
entityConstructor,
new ODataGetAllRequestConfig(entityConstructor, oDataUriV4),
entityDeserializerV4,
responseDataAccessorV4
);
}
expand(expands: Expandable<EntityT>[]): this;
expand(...expands: Expandable<EntityT>[]): this;
expand(
first: undefined | Expandable<EntityT> | Expandable<EntityT>[],
...rest: Expandable<EntityT>[]
): this {
this.requestConfig.expands = variadicArgumentToArray(first, rest);
return this;
}
// TODO: Reconsider the OneToManyLink here
/**
* Add filter statements to the request.
*
* @param expressions - Filter expressions to restrict the response
* @returns The request builder itself, to facilitate method chaining
*/
filter(
...expressions: (Filterable<EntityT> | OneToManyLink<EntityT, any>)[]
): this {
this.requestConfig.filter = and(toFilterableList(expressions));
return this;
}
}