-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathodata-function-import-request-config.ts
48 lines (45 loc) · 1.45 KB
/
odata-function-import-request-config.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
import {
ODataUri,
FunctionImportParameter,
FunctionImportParameters,
ODataFunctionImportRequestConfig,
RequestMethodType
} from '../../odata-common';
export class ODataFunctionImportRequestConfigV4<
ParametersT
> extends ODataFunctionImportRequestConfig<ParametersT> {
/**
* Creates an instance of ODataFunctionImportRequestConfig.
*
* @param method - HTTP method for the request
* @param defaultServicePath - Default path of the service
* @param functionImportName - The name of the function import.
* @param parameters - Object containing the parameters with a value and additional meta information
* @param oDataUri - ODataUri conversion interface at runtime either v2 or v4
*/
constructor(
method: RequestMethodType,
defaultServicePath: string,
functionImportName: string,
parameters: FunctionImportParameters<ParametersT>,
oDataUri: ODataUri
) {
super(method, defaultServicePath, functionImportName, parameters, oDataUri);
}
resourcePath(): string {
return `${this.functionImportName}(${Object.values(this.parameters)
.map(
(parameter: FunctionImportParameter<ParametersT>) =>
`${parameter.originalName}=${this.oDataUri.convertToUriFormat(
parameter.value,
parameter.edmType
)}`
)
.join(',')})`;
}
queryParameters(): Record<string, any> {
return this.prependDollarToQueryParameters({
format: 'json'
});
}
}