import { ErrorWithCause } from '@sap-cloud-sdk/util' ; import { Destination , DestinationFetchOptions } from '@sap-cloud-sdk/connectivity' ; import { deserializeBatchResponse , parseBatchResponse , BatchRequestBuilder } from '@sap-cloud-sdk/odata-common/internal' ; import { DeSerializers } from '../de-serializers/de-serializers' ; import { entityDeserializer } from '../de-serializers' ; import { BatchResponse } from '../batch-response' ; import { responseDataAccessor } from './response-data-accessor' ; /**
 * Create a batch request to invoke multiple requests as a batch. The batch request builder accepts retrieve requests, i. e. [[GetAllRequestBuilder | getAll]] and [[GetByKeyRequestBuilder | getByKey]] requests and change sets, which in turn can contain [[CreateRequestBuilder | create]], [[UpdateRequestBuilder | update]] or [[DeleteRequestBuilder | delete]] requests.
 * The retrieve and change sets will be executed in order, while the order within a change set can vary.
 */ export class ODataBatchRequestBuilder < DeSerializersT extends DeSerializers > extends BatchRequestBuilder < DeSerializersT > { param destination param options returns async execute ( destination ) { return this . executeRaw ( destination ) . then ( response => parseBatchResponse ( response ) ) . then ( parsedResponse => deserializeBatchResponse ( parsedResponse , this . getEntityToApiMap ( ) , responseDataAccessor , entityDeserializer ( this . deSerializers ! ) ) ) . catch ( error => { throw new ErrorWithCause ( 'Batch request failed!' , error ) ; } ) ; } }