UNPKG

@sap-cloud-sdk/odata-common

Version:

SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.

47 lines (46 loc) 2.47 kB
import { MethodRequestBuilder } from './request-builder-base'; import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity'; import type { HttpResponse } from '@sap-cloud-sdk/http-client'; import type { ODataRequestConfig, BatchReference, WithBatchReference } from '../request'; import type { DeSerializers } from '../de-serializers'; /** * Create OData request to execute an action or function. * @template DeSerializersT - Type of the (de-)serializers. * @template ReturnT - Type of the function return value. * @template RequestConfigT - Type of the request config. */ export declare abstract class OperationRequestBuilderBase<DeSerializersT extends DeSerializers, ReturnT, RequestConfigT extends ODataRequestConfig> extends MethodRequestBuilder<RequestConfigT> implements WithBatchReference { readonly responseTransformer: (data: any) => ReturnT; readonly _deSerializers: DeSerializersT; private _batchReference; /** * Base class for function and action request builder. * @param responseTransformer - Transformation function for the response. * @param requestConfig - Request config for an action or function. * @param _deSerializers - (De-)serializers used for transformation. */ protected constructor(responseTransformer: (data: any) => ReturnT, requestConfig: RequestConfigT, _deSerializers: DeSerializersT); /** * Execute request. * @param destination - Destination or DestinationFetchOptions to execute the request against. * @param dataAccessor - A function to modify the received response data. * @returns A promise resolving to the requested return type. */ execute(destination: HttpDestinationOrFetchOptions, dataAccessor?: (data: any) => any): Promise<ReturnT>; /** * Execute request and return an {@link @sap-cloud-sdk/http-client!HttpResponse}. * @param destination - Destination or DestinationFetchOptions to execute the request against. * @returns A promise resolving to an {@link @sap-cloud-sdk/http-client!HttpResponse}. */ executeRaw(destination: HttpDestinationOrFetchOptions): Promise<HttpResponse>; /** * Gets identifier for the batch request. * @returns Batch request identifier. */ getBatchReference(): BatchReference; /** * Sets user-defined identifier for the batch reference. * @param id - User-defined batch request identifier. */ setBatchId(id: string): void; }