define("share/assert/js/restclient",[],function(require,exports){function a(){function b(b,d){var f={locale:e.locale,format:e.format,appkey:e.appkey,access_token:c};for(var g in d)f[g]=d[g];var h;return $.ajax({type:b,async:!1,url:e.restUrl,data:f,dataType:f.format,success:function(a){h=a},error:function(e){log(e.responseJSON),"401"==e.status&&"106"==e.responseJSON.code&&(c="",h=a._request(b,d))}}),h}var _self=this,c="",d=!1,e={appkey:"Hb0YhmOo",appsecret:"R7odNVS0KPtgXJ1TKQbHAxFP6EHdSW5d",username:"",password:"",grantType:"client_credentials",locale:"zh_CN",format:"json",tokenUrl:AppRemoteSvcCfg.UserSvcToken,restUrl:AppRemoteSvcCfg.ResSvcUrl};this.reqAccessToken=function(a,b,d){$.ajax({type:"POST",async:!1,cache:!1,url:e.tokenUrl,data:{client_id:e.appkey,client_secret:e.appsecret,grant_type:e.grantType,username:a,password:b},dataType:"json",success:function(a){c=a.access_token,d(a.access_token)},error:function(){d("")}})},this.userLogin=function(a,b){$.ajax({type:"POST",async:!1,cache:!1,url:e.restUrl,data:{method:"core.user.login",version:"version",format:"json",key:"loginName",value:a,password:b,appkey:"Hb0YhmOo",access_token:c},dataType:"json",success:function(){},error:function(){}})},this.init=function(a){if(!d){for(var b in a)void 0!=e[b]&&(e[b]=a[b]);d=!0}},this.post=function(a){return _self._request("POST",a)},this.get=function(a){return _self._request("GET",a)},this._request=function(a,d){return""==c&&_self.reqAccessToken(),b(a,d)}}exports.RestClient=new a});