@odata2ts/odata-service
Version:
Main runtime dependency of odata2ts for generated odata client services
58 lines • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollectionServiceV2 = void 0;
const tslib_1 = require("tslib");
const odata_query_objects_1 = require("@odata2ts/odata-query-objects");
const ServiceStateHelperV2_js_1 = require("./ServiceStateHelperV2.js");
class CollectionServiceV2 {
constructor(client, basePath, name, qModel, options) {
this.__base = new ServiceStateHelperV2_js_1.ServiceStateHelperV2(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.convertV2ModelResponse)(result, qResponseType);
});
}
/**
* Update the whole collection.
*
* @param models set of primitive values
* @param requestConfig
*/
update(models, requestConfig) {
const { client, qModel, path, getDefaultHeaders } = this.__base;
return client.put(path, qModel.convertToOData(models), requestConfig, getDefaultHeaders());
}
/**
* 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.
*/
query(queryFn, requestConfig) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { client, qResponseType, getDefaultHeaders, applyQueryBuilder } = this.__base;
const response = yield client.get(applyQueryBuilder(queryFn), requestConfig, getDefaultHeaders());
return (0, odata_query_objects_1.convertV2CollectionResponse)(response, qResponseType);
});
}
}
exports.CollectionServiceV2 = CollectionServiceV2;
//# sourceMappingURL=CollectionServiceV2.js.map