;import refRequest = require("./jamsrequest"); var jamsrequest = new refRequest.JAMSRequest; import jamshelper = require("./jamshelper"); var helper = new jamshelper.Helper(); export class Variable { // #region Properties id: string; name: string; value: string; // #endregion // #region Constructor constructor() { } // #endregion // #region Action Methods getvariables(callback: any, configuration: any = {}) { jamsrequest.performRequestUrl("variable", "GET", cb => { callback(cb); }, {}, configuration); } getvariable(callback: any, configuration: any = {}, name: string = "", id: string = "") { var variable = this.getvariablevalue(name, id); // // Commented code because a NodeJS update is flagging the if statement // as an error because it is always true // //if (variable !== {}) { jamsrequest.performRequestUrl("variable", "GET", cb => { callback(cb); }, variable, configuration); //} else { // callback({ "message": "NoneFound" }); //} } putvariable(callback: any, configuration: any = {}, value: any, name: string = "", id: string = "") { jamsrequest.performRequestUrl("variable", "PUT", cb => { callback(cb); }, value, configuration); } setvariable(callback: any, name: string, value: any, configuration: any = {}) { if (!helper.isNullOrEmpty(name)) { var encodedname = encodeURIComponent(name); jamsrequest.performRequestUrl(`variable/setvalue?name=${ encodedname }`, "POST", valresult => { callback(valresult); }, value, configuration); } else { callback({ "message": "NoneFound" }); } } // #endregion // #region Helper Method getvariablevalue(name: string = "", id: string = "") { var hasvarid = !helper.isNullOrEmpty(this.id); var hasvarname = !helper.isNullOrEmpty(this.name); var hasparamvarid = !helper.isNullOrEmpty(id); var hasparamvarname = !helper.isNullOrEmpty(name); var returnvariable = {"name" : "", "id": ""}; if (hasparamvarname) { returnvariable.name = name;// = { "name": name }; } else { if (hasvarname) { returnvariable.name = this.name; //= = { "name": this.name }; } else { if (hasparamvarid) { returnvariable.id = id; //{ "id": id }; } else { if (hasvarid) { returnvariable.id = this.id; // { "id": this.id }; } } } } return returnvariable; } // #endregion }