UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

75 lines 2.23 kB
import { __awaiter } from "tslib"; import { Service } from '../core'; export class SystemOptionsService extends 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); * })(); * ``` */ detail(option) { const _super = Object.create(null, { detail: { get: () => super.detail } }); return __awaiter(this, void 0, void 0, function* () { return _super.detail.call(this, 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); * })(); * ``` */ list() { return __awaiter(this, arguments, void 0, function* (filter = {}) { const headers = { 'content-type': 'application/json' }; const url = this.listUrl; const res = yield this.fetch(url, { headers, params: filter }); const json = yield res.json(); const data = json[this.propertyName]; return { res, data }; }); } getDetailUrl(option) { return `${this.listUrl}/${option.category}/${option.key}`; } onBeforeCreate(obj) { return obj; } } //# sourceMappingURL=SystemOptionsService.js.map