UNPKG

zcrmsdk

Version:
91 lines (76 loc) 2.51 kB
const Choice = require("../../../../../../utils/util/choice").MasterModel; const Constants = require("../../../../../../utils/util/constants").MasterModel; const SDKException = require("../exception/sdk_exception").MasterModel; class CallBack{ url; method; keyModified = new Map(); /** * The method to get the url * @returns {String} A String representing the url */ getUrl() { return this.url; } /** * The method to set the value to url * @param {String} url A String representing the url */ setUrl(url) { if((url != null) && (!(Object.prototype.toString.call(url) == "[object String]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: url EXPECTED TYPE: String", null, null); } this.url = url; this.keyModified.set("url", 1); } /** * The method to get the method * @returns {Choice} An instance of Choice */ getMethod() { return this.method; } /** * The method to set the value to method * @param {Choice} method An instance of Choice */ setMethod(method) { if((method != null) && (!(method instanceof Choice))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: method EXPECTED TYPE: Choice", null, null); } this.method = method; this.keyModified.set("method", 1); } /** * The method to check if the user has modified the given key * @param {String} key A String representing the key * @returns {number} A number representing the modification */ isKeyModified(key) { if((key != null) && (!(Object.prototype.toString.call(key) == "[object String]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: key EXPECTED TYPE: String", null, null); } if(this.keyModified.has(key)) { return this.keyModified.get(key); } return null; } /** * The method to mark the given key as modified * @param {String} key A String representing the key * @param {number} modification A number representing the modification */ setKeyModified(key, modification) { if((key != null) && (!(Object.prototype.toString.call(key) == "[object String]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: key EXPECTED TYPE: String", null, null); } if((modification != null) && (!(Object.prototype.toString.call(modification) == "[object Number]"))) { throw new SDKException(Constants.DATA_TYPE_ERROR, "KEY: modification EXPECTED TYPE: number", null, null); } this.keyModified.set(key, modification); } } module.exports = { MasterModel : CallBack, CallBack : CallBack }