import {QelosSDKOptions} from '../types'; import BaseSDK from '../base-sdk'; export interface ICustomConfiguration { key: string; public: boolean; kind?: string; description?: string; metadata: T } export default class QlManageConfigurations extends BaseSDK { private relativePath = '/api/configurations'; constructor(options: QelosSDKOptions) { super(options); } getList(key: string, extra?: Partial) { return this.callJsonApi(this.relativePath, extra); } getConfiguration(key: string, extra?: Partial) { return this.callJsonApi>(`${this.relativePath}/${key}`, extra); } create(config: ICustomConfiguration, extra?: Partial) { return this.callJsonApi>(this.relativePath, { method: 'post', headers: {'content-type': 'application/json'}, body: JSON.stringify(config), ...(extra || {}), }); } update(key: string, changes: Partial>, extra?: Partial): Promise> { return this.callJsonApi>(`${this.relativePath}/${key}`, { method: 'put', headers: {'content-type': 'application/json'}, body: JSON.stringify(changes), ...(extra || {}), }); } remove(key: string, extra?: Partial) { return this.callJsonApi(`${this.relativePath}/${key}`, { method: 'delete', ...(extra || {}), }); } }