UNPKG

@sap-cloud-sdk/odata-v4

Version:

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

28 lines 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ODataBatchRequestBuilder = void 0; const util_1 = require("@sap-cloud-sdk/util"); const internal_1 = require("@sap-cloud-sdk/odata-common/internal"); const de_serializers_1 = require("../de-serializers"); const response_data_accessor_1 = require("./response-data-accessor"); /** * Create a batch request to invoke multiple requests as a batch. The batch request builder accepts retrieve requests, i.e. {@link GetAllRequestBuilder | getAll} and {@link GetByKeyRequestBuilder | getByKey} requests and change sets, which in turn can contain {@link CreateRequestBuilder | create}, {@link UpdateRequestBuilder | update} or {@link DeleteRequestBuilder | delete} requests. * The retrieve and change sets will be executed in order, while the order within a change set can vary. */ class ODataBatchRequestBuilder extends internal_1.BatchRequestBuilder { /** * Execute the given request and return the according promise. Please notice: The sub-requests may fail even the main request is successful. * @param destination - Targeted destination or DestinationFetchOptions on which the request is performed. * @returns Promise resolving to the requested data. */ async execute(destination) { return this.executeRaw(destination) .then(response => (0, internal_1.parseBatchResponse)(response)) .then(parsedResponse => (0, internal_1.deserializeBatchResponse)(parsedResponse, this.getEntityToApiMap(), response_data_accessor_1.responseDataAccessor, (0, de_serializers_1.entityDeserializer)(this.deSerializers))) .catch(error => { throw new util_1.ErrorWithCause('Batch request failed!', error); }); } } exports.ODataBatchRequestBuilder = ODataBatchRequestBuilder; //# sourceMappingURL=batch-request-builder.js.map