"use strict";(function(){"use strict";global.Promise=require("bluebird");var e=require("co");var r=require("./jsUtil");var o=require("./Logger");var t=o.getLogger("maccRequest");var n=require("util");var c="";var s="";var u="";function a(o,a,i,h,g,f){console.log(f.token,"oooooooooooooooooooooo");if(f.token==undefined){f.token="111"}return e(regeneratorRuntime.mark(function d(){var e,l,k,p;return regeneratorRuntime.wrap(function x(d){while(1){switch(d.prev=d.next){case 0:e=3;l=0;console.log("enter !!!");case 3:if(!(e===3||e===4)){d.next=33;break}console.log(c,o+f.token,a,i,h,g,"hhhhhhhhhhhhhhhhhhhh");d.next=7;return r.commonRequest2(c,o+f.token,a,i,h,g);case 7:k=d.sent;t.debug("result:",k);e=k.code;if(!(e===0)){d.next=14;break}return d.abrupt("return",k);case 14:if(!(e==3||e==4)){d.next=28;break}l++;if(!(l>1)){d.next=20;break}k.code=7;d.next=26;break;case 20:d.next=22;return r.commonGet2(c,n.format("/service/api/login?appid=0001&account=%s&password=%s",s,u));case 22:p=d.sent;t.debug("tokenResult",p,"host:",c);if(p.code!=0){k.code=7;k.msg=p.msg!=undefined?p.msg:""}f.token=p.access_token;case 26:d.next=29;break;case 28:k.code=7;case 29:if(!(k.code==7)){d.next=31;break}return d.abrupt("return",k);case 31:d.next=3;break;case 33:t.error("cannot reach here: code:",e);case 34:case"end":return d.stop()}}},d,this)})).catch(function(e){t.error(e.toString());return{code:6,msg:e.toString()}})}exports.setConfig=function(e,r,o){c=e;s=r;u=o};exports.get=function(e,r,o,t){return a(e,"GET",{},o,t,r)};exports.post=function(e,r,o,t,n){return a(e,"POST",r,t,n,o)};exports.put=function(e,r,o,t,n){return a(e,"PUT",r,t,n,o)};exports.delete=function(e,r,o,t){console.log("route_____:",e,"info___",r);return a(e,"DELETE",{},o,t,r)};exports.getHost=function(){return c}})();