@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
71 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemOptionsService = void 0;
const index_js_1 = require("../core/index.js");
class SystemOptionsService extends index_js_1.Service {
constructor() {
super(...arguments);
this.baseUrl = 'tenant/system';
this.listUrl = 'options';
this.propertyName = 'options';
}
/**
* Gets the details of given system option.
*
* @param {string|number|IIdentified} option System option object with mandantory fragments.
*
* @returns Response wrapped in [[IResult]]
*
* **Example**
* ```typescript
*
* const option: ISystemOption = {
* category: 'alarm.type.mapping',
* key: 'temp_to_high'
* };
*
* (async () => {
* const {data, res} = await systemOptionsService.detail(option);
* })();
* ```
*/
async detail(option) {
return super.detail(option);
}
/**
* Gets the list of system options filtered by parameters.
*
* @returns Response wrapped in [[IResultList]]
*
* @param {object} filter Object containing filters for querying system options.
*
* **Example**
* ```typescript
*
* const filter: object = {
* pageSize: 100,
* withTotalPages: true
* };
*
* (async () => {
* const {data, res, paging} = await systemOptionsService.list(filter);
* })();
* ```
*/
async list(filter = {}) {
const headers = { 'content-type': 'application/json' };
const url = this.listUrl;
const res = await this.fetch(url, { headers, params: filter });
const json = await res.json();
const data = json[this.propertyName];
return { res, data };
}
getDetailUrl(option) {
return `${this.listUrl}/${option.category}/${option.key}`;
}
onBeforeCreate(obj) {
return obj;
}
}
exports.SystemOptionsService = SystemOptionsService;
//# sourceMappingURL=SystemOptionsService.js.map