function rApiJs(responseFormObj){ if (typeof responseFormObj !== "object") { this.responseForm = { "meta": { "status": "ERROR" }, "data": { "message": "rApi_jsonError" } }; return; } this.responseForm = responseFormObj; } rApiJs.prototype.isSuccess = function() { if(this.responseForm.meta.status=="SUCCESS"){ return true; }else{ return false; } }; rApiJs.prototype.isNotSuccess = function() { if(this.responseForm.meta.status!="SUCCESS"){ return true; }else{ return false; } }; rApiJs.prototype.isError = function() { if(this.responseForm.meta.status=="ERROR" || this.responseForm.meta.status=="AUTH_ERROR" || this.responseForm.meta.status=="VALIDATE_ERROR") { return true; } else { return false; } }; rApiJs.prototype.getDataAll = function () { if (typeof this.responseForm["data"] === 'undefined') { return false; } else { return this.responseForm["data"]; } }; rApiJs.prototype.getData = function (keyName) { if (!keyName) { return this.getDataAll(); } if (typeof this.responseForm["data"] === 'undefined') { return false; } if (typeof this.responseForm["data"][keyName] === 'undefined') { return false; } else { return this.responseForm["data"][keyName]; } }; rApiJs.prototype.getDataAnonymous = function () { if (typeof this.responseForm["data"]["ANONYMOUS_DATA"] === 'undefined') { return false; } else { return this.responseForm["data"]["ANONYMOUS_DATA"]; } }; rApiJs.prototype.getMeta = function (keyName) { if (typeof this.responseForm["meta"] === 'undefined') { return false; } if (!keyName) { return this.responseForm["meta"]; } if (typeof this.responseForm["meta"][keyName] === 'undefined') { return false; } else { return this.responseForm["meta"][keyName]; } }; rApiJs.prototype.getErrorList = function () { if (typeof this.responseForm["errors"] === 'undefined') { return false; } else { return this.responseForm["errors"]; } }; rApiJs.prototype.getErrorMessageText = function (separator) { var textArray = []; var errorList = this.getErrorList(); if (Array.isArray(errorList)) { for (var i = 0; i < errorList.length; i++) { var val = errorList[i]; textArray.push(val.message_text+"["+val.identifir+"]"); } } return textArray.join(separator); }; rApiJs.prototype.consoleErrorinfo = function() { var errorList = this.getErrorList(); if(!errorList){ return false; }else{ $.each(errorList, function (i, val) { console.log("error_code:"+val["error_code"]+"_"+val["identifir"]+val["message_text"]); }); } };