UNPKG

@cloudonix.io/cloudonix-cli

Version:
95 lines (85 loc) 3.4 kB
/** * ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ███╗ ██╗██╗██╗ ██╗ * ██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗██╔═══██╗████╗ ██║██║╚██╗██╔╝ * ██║ ██║ ██║ ██║██║ ██║██║ ██║██║ ██║██╔██╗ ██║██║ ╚███╔╝ * ██║ ██║ ██║ ██║██║ ██║██║ ██║██║ ██║██║╚██╗██║██║ ██╔██╗ * ╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝╚██████╔╝██║ ╚████║██║██╔╝ ██╗ * ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ * * Project: cloudonix-cli | lib/DnidsApi.js * Creator: Nir Simionovich <nirs@cloudonix.io> | 2019-08-27 */ const Client = require('../helpers/Client'); const Api = require('./Api'); class DnidsApi extends Api { static async get(dnid) { try { var queryPath = (typeof dnid != 'undefined') ? this._modelQueryPath + "/" + dnid : this._modelQueryPath; var response = await this._modelHttpConnector.httpConnector.get(queryPath); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async create(applicationConfig) { try { var queryPath = this._modelQueryPath; var response = await this._modelHttpConnector.httpConnector.post(queryPath, applicationConfig); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async update(dnid, applicationConfig) { try { var queryPath = this._modelQueryPath + '/' + dnid; var trunkConfigObject = applicationConfig; var response = await this._modelHttpConnector.httpConnector.put(queryPath, trunkConfigObject); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async revoke(dnid) { try { var queryPath = this._modelQueryPath + "/" + dnid; var response = await this._modelHttpConnector.httpConnector.delete(queryPath); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } } module.exports = DnidsApi;