UNPKG

@c8y/client

Version:

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

71 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeatureService = void 0; const core_1 = require("../core"); /** * This class allows reading a feature toggles for current tenant. */ class FeatureService extends core_1.Service { constructor() { super(...arguments); this.baseUrl = ''; this.listUrl = 'features'; } /** * Retrieve list of feature toggles with values for current tenant. * * **Example** * ```typescript * * const filter = { * pageSize: 1000, * withTotalPages: true * }; * * (async () => { * const {data, res, paging} = await featureService.list(filter); * })(); * ``` */ async list(filter = {}) { return super.list(filter); } /** * Retrieve a specific feature toggle with value for current tenant. * * **Example** * ```typescript * * (async () => { * const featureToggleKey = 'my-custom-feature'; * const {data, res} = await featureService.detail(featureToggleKey); * })(); * ``` */ async detail(key) { return super.detail(key); } /** * Update a specific feature toggle value for current tenant. * * **Example** * ```typescript * (async () => { * const featureToggleKey = 'my-custom-feature'; * const {data, res} = await featureService.updateFeature({ * key: featureToggleKey, * active: true, * }); * ``` */ async updateFeature(feature) { const url = `${this.listUrl}/${feature['key']}/by-tenant`; const method = 'PUT'; const body = JSON.stringify(feature); const headers = { 'content-type': 'application/json', accept: 'application/json' }; const res = await this.fetch(url, this.changeFetchOptions({ method, body, headers }, url)); return { res, data: null }; } } exports.FeatureService = FeatureService; //# sourceMappingURL=FeatureService.js.map