node-swallowjs
Version:
epp portal
1 lines • 3.23 kB
JavaScript
;!function(a,b){if("function"==typeof define&&define.amd)define(["exports","http","querystring"],b);else if("undefined"!=typeof exports)b(exports,require("http"),require("querystring"));else{var c={exports:{}};b(c.exports,a.http,a.querystring),a.eppAPI=c.exports}}(this,function(a,b,c){function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(a,"__esModule",{value:!0});var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(){function a(e,f,g){function h(a,d,e){var f="swallow_epp_sessionid",g="";return function(h,i,j){var k=JSON.stringify(i),l={host:a,port:d,path:e+"/api/"+h,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8","Content-Length":k.length,Cookie:f+"="+g}},m=b.request(l,function(a){var b="";a.on("data",function(a){b+=a}),a.on("end",function(){if(200===a.statusCode){var d=a.headers["set-cookie"];for(var e in d){var h=c.parse(d[e],/;\s*/);h[f]&&(g=h[f])}var i=JSON.parse(b);j(i.code,i.data)}else j()})});m.on("error",j),m.write(k),m.end()}}function i(a){return function(b,c,d){var e=new XMLHttpRequest,f=0;e.onreadystatechange=function(a){if(f!==this.readyState)switch(f=this.readyState,this.readyState){case 4:200===this.status?d(this.response.code,this.response.data):d()}},e.open("POST",a+"/api/"+b,!0),e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify(c)),e.responseType="json"}}d(this,a),this.post="function"==typeof require?h(f,g,e):i(e)}return e(a,[{key:"login",value:function(a,b,c){this.post("login",{Username:a,Password:b},c)}},{key:"check",value:function(a,b,c){this.post("check",{obj:a,name:b},c)}},{key:"info",value:function(a,b,c){this.post("info",{obj:a,name:b},c)}},{key:"create",value:function(a,b,c){this.post("create",{obj:a,json:b},c)}},{key:"delete",value:function(a,b,c){this.post("delete",{obj:a,name:b},c)}},{key:"renew",value:function(a,b,c){this.post("renew",{name:a,y:b},c)}},{key:"transfer",value:function(a,b,c){this.post("transfer",{op:a,json:b},c)}},{key:"update",value:function(a,b,c){this.post("update",{obj:a,json:b},c)}},{key:"restore",value:function(a,b,c){this.post("restore",{op:a,json:b},c)}},{key:"list",value:function(a,b,c,d){this.post("list",{obj:a,page:b,where:c},d)}},{key:"show",value:function(a){for(var b=arguments.length,c=Array(b>1?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];var e=c.pop(),f=c[0];this.post("show",{obj:a,name:f},e)}},{key:"load",value:function(a,b,c){this.post("load",{obj:a,name:b},c)}},{key:"pdns",value:function(a,b,c,d){this.post("pdns",{action:a,domain:b,record:c},d)}},{key:"sendVerifyCode",value:function(a,b){this.post("sendVerifyCode",{email:a},b)}},{key:"compVerifyCode",value:function(a,b,c){this.post("compVerifyCode",{email:a,verifyCode:b},c)}},{key:"resultRegistrant",value:function(a,b){this.post("resultRegistrant",{contactId:a},b)}},{key:"uploadRegistrant",value:function(a,b,c){this.post("uploadRegistrant",{contactId:a,json:b},c)}},{key:"logout",value:function(a){this.post("logout",{},a)}}]),a}();a.default=f});