danielweinmann/unlock

View on GitHub
public/moip-assinaturas.min.js

Summary

Maintainability
A
0 mins
Test Coverage
(function(){var r,s,t,i;i=function(a){return 10>a?"0"+a:a};Date.prototype._toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+i(this.getUTCMonth()+1)+"-"+i(this.getUTCDate())+"T"+i(this.getUTCHours())+":"+i(this.getUTCMinutes())+":"+i(this.getUTCSeconds())+"."+i(this.getUTCMilliseconds())+"Z":null};Date.prototype.toJSON||(Date.prototype.toJSON=Date.prototype._toJSON);String.prototype._toJSON=Number.prototype._toJSON=Boolean.prototype._toJSON=function(){return this.valueOf()};
String.prototype.toJSON||(String.prototype.toJSON=String.prototype._toJSON);Number.prototype.toJSON||(Number.prototype.toJSON=Number.prototype._toJSON);Boolean.prototype.toJSON||(Boolean.prototype.toJSON=Boolean.prototype._toJSON);var g=function(){};g.prototype.parse=function(a){var e,c,b,f,h,d,g,i,n,o,m,l,v;if(a){c=null;b=" ";h={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};f=function(q){throw new SyntaxError(""+q+" at character #"+c+"("+b+"); for text: "+a);};d=function(q){q&&q!==
b&&f("Expected '"+q+"' instead of '"+b);return b=a.charAt(c++)};g=function(){var a;a="";if(b==="-"){a="-";d("-")}for(;b>="0"&&b<="9";){a=a+b;d()}if(b===".")for(a=a+".";d()&&b>="0"&&b<="9";)a=a+b;if(b==="e"||b==="E"){a=a+b;d();if(b==="-"||b==="+"){a=a+b;d()}for(;b>="0"&&b<="9";){a=a+b;d()}}a=+a;if(isFinite(a))return a;f("Bad number")};o=function(){var a,c,e,k;k="";if(b==='"')for(;d();){if(b==='"'){d();return k}if(b==="\\"){d();if(b==="u"){for(e=c=0;e<4;++e){a=parseInt(d(),16);if(!isFinite(a))break;
c=c*(16+a)}k=k+String.fromCharCode(c)}else if(typeof h[b]==="string")k=k+h[b];else break}else k=k+b}f("Bad string")};l=function(){for(;b&&b<=" ";)d()};v=function(){switch(b){case "t":d("t");d("r");d("u");d("e");true;break;case "f":d("f");d("a");d("l");d("s");d("e");false;break;case "n":d("n");d("u");d("l");d("l");null}f("Unexpected #{ch}")};e=function(){var a;a=[];if(b==="["){d("[");l();if(b==="]"){d("]");return a}for(;b;){a.push(m());l();if(b==="]"){d("]");return a}d(",");l()}}f("Bad array")};i=
function(){var a,c;c={};if(b==="{"){d("{");l();if(b==="}"){d("}");return c}for(;b;){a=o();l();d(":");Object.hasOwnProperty.call(c,a)&&f("Duplicate key '"+a);c[a]=m();l();if(b==="}"){d("}");return c}d(",");l()}}f("Bad object")};m=function(){l();switch(b){case "{":return i();case "[":return e();case '"':return o();case "-":return g;default:return b>="0"&&b<="9"?g():v()}};n=m();l();b&&f("Syntax error");return n}};g.prototype.stringify=function(a,e,c){var b,f,h,d,g,i,n,o,m,l;e==null&&(e=null);c==null&&
(c=0);d=f="";b=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};g=function(a,b){return a>b?a:b};n=function(a,b){return a<b?a:b};if(typeof c==="number"){h=m=0;for(c=n(g(c,0),10);0<=c?m<c:m>c;h=0<=c?++m:--m)d=d+" "}else if(typeof c==="string"){m=g=0;for(n=n(c.length,10);0<=n?g<n:g>n;m=0<=n?++g:--g)d=d+c[m]}if(e&&typeof e!=="function"&&(typeof e!==
"object"||typeof e.length!=="number"))throw Error("JSON.stringify");o=function(a){b.lastIndex=0;return b.test(a)?'"'+a.replace(b,function(a){var b;b=i[a];return typeof b==="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}):'"'+a+'"'};l=function(a,b){var c,g,k,i,j;g=f;(j=b[a])&&(typeof j==="object"&&typeof j._toJSON==="function")&&(j=j._toJSON(a));typeof e==="function"&&(j=e.call(b,a,j));switch(typeof j){case "string":return o(j);case "number":return isFinite(j)?String(j):"null";case "boolean":case "null":return String(j);
case "object":if(!j)return"null";f=f+d;k=[];if(Object.prototype.toString.apply(j)==="[object Array]"){for(h in j)k.push(l(+h,j)||"null");i=k.length===0?"[]":f?"[\n"+f+k.join(",\n"+f)+"\n"+g+"]":"["+k.join(",")+"]"}else{if(e&&typeof e==="object")for(c in e){if(typeof e[c]==="string")(i=l(c,j))&&k.push(o(c)+(f?": ":":")+i)}else for(c in j)if(Object.prototype.hasOwnProperty.call(j,c))(i=l(c,j))&&k.push(o(c)+(f?": ":":")+i);i=k.length===0?"{}":f?"{\n"+f+k.join(",\n"+f)+"\n"+g+"}":"{"+k.join(",")+"}"}f=
g;return i}};return l("",{"":a})};this._JSON=new g;this.JSON||(this.JSON=this._JSON);var u=function(a){a==null&&(a={});this.fullname=a.fullname||"";this.email=a.email||"";this.code=a.code||"";this.cpf=a.cpf||"";this.birthdate_day=a.birthdate_day||"";this.birthdate_month=a.birthdate_month||"";this.birthdate_year=a.birthdate_year||"";this.phone_area_code=a.phone_area_code||"";this.phone_number=a.phone_number||"";this.billing_info=new t(a.billing_info)||new t;this.address=new r(a.address)||new r};u.prototype.to_json=
function(){return{code:this.code,email:this.email,fullname:this.fullname,cpf:this.cpf,phone_area_code:this.phone_area_code,phone_number:this.phone_number,birthdate_day:this.birthdate_day,birthdate_month:this.birthdate_month,birthdate_year:this.birthdate_year,billing_info:this.billing_info.to_json(),address:this.address.to_json()}};g=function(a){a==null&&(a={});this.customer=a.code||null;this.plan_code=a.plan_code||""};g.is_new_customer=!1;g.prototype.with_customer=function(a){this.customer=a;return this};
g.prototype.with_new_customer=function(a){this.customer=new u(a)||new u;this.is_new_customer=true;return this};g.prototype.with_plan_code=function(a){this.plan_code=a;return this};g.prototype.with_code=function(a){this.code=a;return this};g.prototype.to_json=function(){return{code:this.code,plan:{code:this.plan_code},customer:this.customer.to_json()}};var h=function(a){a==null&&(a={});this.fullname=a.fullname||"";this.credit_card_number=a.credit_card_number||"";this.expiration_month=a.expiration_month||
"";this.expiration_year=a.expiration_year||"";this.vault=a.vault||""};h.prototype.to_json=function(){return{credit_card:this.credit_card_to_json()}};h.prototype.credit_card_to_json=function(){return{holder_name:this.fullname,expiration_month:this.expiration_month,expiration_year:this.expiration_year,first_six_digits:this._six_first(),last_four_digits:this._last_four(),number:this.credit_card_number}};h.prototype._six_first=function(){return this.credit_card_number.substring(0,5)};h.prototype._last_four=
function(){return this.credit_card_number.substring(this.credit_card_number.length-4,this.credit_card_number.length)};t=h;h=function(a){a==null&&(a={});this.street=a.street||"";this.number=a.number||"";this.complement=a.complement||"";this.district=a.district||"";this.city=a.city||"";this.state=a.state||"";this.country=a.country||"";this.zipcode=a.zipcode||""};h.prototype.to_json=function(){return{street:this.street,number:this.number,complement:this.complement,district:this.district,city:this.city,
state:this.state,country:this.country,zipcode:this.zipcode}};r=h;var p=function(a){a==null&&(a={});this.errors=a.errors||[];this.alerts=a.alerts||[];this.code=a.code||"";this.message=a.message||"";this.amount=a.amount||"";this.plan=a.plan||{};this.status=a.status||"";this.invoice=a.invoice||{};this.next_invoice_date=a.next_invoice_date||{};this.customer=a.customer||{}};p.prototype.has_errors=function(){return this.error!==void 0||this.errors.length>0};p.prototype.has_alerts=function(){return this.alerts!==
void 0||this.alerts.length>0};p.prototype.add_errors=function(a){var e,c,b,f;f=[];c=0;for(b=a.length;c<b;c++){e=a[c];f.push(this.errors.push(e))}return f};p.prototype.add_alerts=function(a){var e,c,b,f;f=[];c=0;for(b=a.length;c<b;c++){e=a[c];f.push(this.alerts.push(e))}return f};h=function(a){this.hash=a;this.response};h.prototype.subscribe=function(a){this.subscription=a;this._request_subscribe();return this};h.prototype.callback=function(a){this.fn=a;return this};h.prototype._exec_callback=function(){return this.fn.call(this,
this.response)};h.prototype._request_subscribe=function(){var a,e,c=this;e={hash:this.hash,json:JSON.stringify(this.subscription.to_json())};a=this.subscription.is_new_customer?a="?new_customer=true":"?new_customer=false";return $.ajax({url:s+"/v1/subscriptions/jsonp"+a,type:"GET",dataType:"jsonp",data:e,scriptCharset:"utf8",success:function(a){return c.handle_data(a)}})};h.prototype.handle_data=function(a){this.response=new p(a);this._exec_callback();return this};h.prototype.create_customer=function(a){this._request_customer(a);
return this};h.prototype._request_customer=function(a){var e=this,a={hash:this.hash,json:JSON.stringify(a.to_json())};return $.ajax({url:s+"/v1/customers/jsonp?new_vault=true",type:"GET",dataType:"jsonp",data:a,scriptCharset:"utf8",success:function(a){return e.handle_data(a)}})};h.prototype.update_credit_card=function(a){this._request_update(a);return this};h.prototype._request_update=function(a){var e,c=this;e={hash:this.hash,json:JSON.stringify(a.billing_info.to_json())};return $.ajax({url:s+"/v1/customers/"+
a.code+"/billing_infos/jsonp",type:"GET",dataType:"jsonp",data:e,scriptCharset:"utf8",success:function(a){return c.handle_data(a)}})};window.MoipAssinaturas="undefined"!==typeof exports&&null!==exports?exports:h;window.Customer="undefined"!==typeof exports&&null!==exports?exports:u;window.Subscription="undefined"!==typeof exports&&null!==exports?exports:g;window.BillingInfo="undefined"!==typeof exports&&null!==exports?exports:t;window.Address="undefined"!==typeof exports&&null!==exports?exports:r;
window.Response="undefined"!==typeof exports&&null!==exports?exports:p;s="https://api.moip.com.br/assinaturas"}).call(this);