/
function-import-request-builder.ts
44 lines (42 loc) · 1.61 KB
/
function-import-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
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import { FunctionImportParameters, RequestMethodType } from '../../common';
import { oDataUri } from '../uri-conversion';
import { ActionFunctionImportRequestBuilderBase } from '../../common/request-builder/action-function-import-request-builder-base';
import { ODataFunctionImportRequestConfig } from '../../common/request/odata-function-import-request-config';
/**
* Create OData request to execute a function import.
* @typeparam ParametersT - Type of the function import parameters
* @typeparam ReturnT - Type of the function import return value
*/
export class FunctionImportRequestBuilder<
// reuse
ParametersT,
ReturnT
> extends ActionFunctionImportRequestBuilderBase<ParametersT, ReturnT> {
/**
* Creates an instance of FunctionImportRequestBuilder.
* @param method - HTTP method to be used for the request
* @param defaultServicePath - Default path for the service the function belongs to
* @param functionImportName - The name of the function import.
* @param responseTransformer - Transformation function for the response
* @param parameters - Parameters to be set in the function
*/
constructor(
method: RequestMethodType,
defaultServicePath: string,
functionImportName: string,
readonly responseTransformer: (data: any) => ReturnT,
parameters: FunctionImportParameters<ParametersT>
) {
super(
responseTransformer,
new ODataFunctionImportRequestConfig(
method,
defaultServicePath,
functionImportName,
parameters,
oDataUri
)
);
}
}