-
Notifications
You must be signed in to change notification settings - Fork 4
/
kiva.min.js
1 lines (1 loc) · 1.48 KB
/
kiva.min.js
1
(function(t,e){var n=1,i=1,s=1,a="api.kivaws.org",r="zip.kiva.org",o="/v",u="/v";e.kiva={ver:n,kVer:i,zVer:s,kivaSrc:"http://"+a+o+i,zipSrc:"http://"+r+u+s};var c=Function;kiva.Object=function(){},kiva.Object.extend=function(e){var n=function(){},i=e&&e.name?new c("return function "+e.name+" () {}")():function(){};return n.prototype=this.prototype,i.prototype=new n,t.extend(i.prototype,e),t.extend(i,this),i.__proto__=this.prototype,i.__super__=this,i},kiva.Object.create=function(e){var n=this,i=new n;return t.extend(i,e)},kiva.Request=kiva.Object.extend({name:"Request",kivaSrc:kiva.kivaSrc,zipSrc:kiva.zipSrc,content:{},_status:"",buildUrl:function(e){var n,i,s,a=[this.kivaSrc,this.name.toLowerCase()];if(e){if(t.isArray(e)?n=e:"number"==typeof e?n=[e]:(n=e.ids,i=e.action,s=e.entity),n&&!t.isArray(n))throw'Error: "ids" must be an array';i?(n&&a.push(n[0]),a.push(i)):n&&(n=n.join(","),a.push(n)),s&&a.push(s)}return a.join("/")+".json"},status:function(t){return t&&this._status!=t&&(this._status=t),this._status},load:function(e){this.content=t.extend(this.content,e),this.status("loaded",e)},fetch:function(e){var n=this,i=e.params||{};return this.status("fetching"),this.jqXhr=t.getJSON(this.buildUrl(e),i).progress(function(){n.status("progress")}).fail(function(){n.status("failed")}).done(function(t){n.load(t[n.name.toLowerCase()])}),this}}),kiva.Lenders=kiva.Request.extend({name:"Lenders"}),kiva.Loans=kiva.Request.extend({name:"Loans"}),kiva.Teams=kiva.Request.extend({name:"Teams"})})(jQuery,this);