UNPKG

@odata2ts/odata-service

Version:

Main runtime dependency of odata2ts for generated odata client services

61 lines 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CollectionServiceV4 = void 0; const tslib_1 = require("tslib"); const odata_query_objects_1 = require("@odata2ts/odata-query-objects"); const ServiceStateHelperV4_js_1 = require("./ServiceStateHelperV4.js"); class CollectionServiceV4 { constructor(client, basePath, name, qModel, options) { this.__base = new ServiceStateHelperV4_js_1.ServiceStateHelperV4(client, basePath, name, qModel, options); } getPath() { return this.__base.path; } /** * Add a new item to the collection. * * @param model primitive value * @param requestConfig */ add(model, requestConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { client, qModel, path, getDefaultHeaders, qResponseType } = this.__base; const result = yield client.post(path, qModel.convertToOData(model), requestConfig, getDefaultHeaders()); return (0, odata_query_objects_1.convertV4ModelResponse)(result, qResponseType); }); } /** * Update the whole collection. * * @param models set of primitive values * @param requestConfig */ update(models, requestConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { client, qModel, path, getDefaultHeaders, qResponseType } = this.__base; const result = yield client.put(path, qModel.convertToOData(models), requestConfig, getDefaultHeaders()); return (0, odata_query_objects_1.convertV4ModelResponse)(result, qResponseType); }); } /** * Delete the whole collection. */ delete(requestConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { client, path } = this.__base; return client.delete(path, requestConfig); }); } /** * Query collection of primitive values. */ query(queryFn, requestConfig) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { client, getDefaultHeaders, applyQueryBuilder, qResponseType } = this.__base; const response = yield client.get(applyQueryBuilder(queryFn), requestConfig, getDefaultHeaders()); return (0, odata_query_objects_1.convertV4CollectionResponse)(response, qResponseType); }); } } exports.CollectionServiceV4 = CollectionServiceV4; //# sourceMappingURL=CollectionServiceV4.js.map