extra-life-ts
Version:
A typed wrapper for the Extra Life API
2 lines • 3.78 kB
JavaScript
;var x=Object.create;var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,b=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var d=(t,e,n)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,G=(t,e)=>{for(var n in e||(e={}))O.call(e,n)&&d(t,n,e[n]);if(u)for(var n of u(e))P.call(e,n)&&d(t,n,e[n]);return t};var A=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},l=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of T(e))!O.call(t,s)&&s!==n&&m(t,s,{get:()=>e[s],enumerable:!(i=v(e,s))||i.enumerable});return t};var h=(t,e,n)=>(n=t!=null?x(b(t)):{},l(e||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),B=t=>l(m({},"__esModule",{value:!0}),t);var r=(t,e,n)=>new Promise((i,s)=>{var p=c=>{try{y(n.next(c))}catch(g){s(g)}},f=c=>{try{y(n.throw(c))}catch(g){s(g)}},y=c=>c.done?i(c.value):Promise.resolve(c.value).then(p,f);y((n=n.apply(t,e)).next())});var z={};A(z,{getParticipant:()=>$,getParticipantActivity:()=>I,getParticipantBadges:()=>M,getParticipantDonations:()=>U,getParticipantDonors:()=>E,getParticipantIncentives:()=>j,getParticipantMilestones:()=>q,getTeam:()=>F,getTeamActivity:()=>_,getTeamBadges:()=>k,getTeamDonations:()=>N,getTeamDonors:()=>X,getTeamParticipants:()=>L});module.exports=B(z);var w=h(require("cross-fetch"));function o(t){return new Promise((e,n)=>r(this,null,function*(){(0,w.default)(t).then(i=>r(this,null,function*(){i.status>=400&&n(new Error(`Request failed: ${i.status} - ${i.statusText}`));try{let s=i.headers.get("num-records"),p=yield i.json();e(G({data:p},s?{totalRecords:parseInt(s)}:{}))}catch(s){}}))}))}var D=require("qss"),R="https://www.extra-life.org/api",a=({type:t,id:e,resource:n,opts:i})=>{let s=`${R}/${t}/${e}`;if(n&&(s+=`/${n}`),Object.keys(i!=null?i:{}).length){let p=(0,D.encode)({limit:i!=null&&i.limit?i.limit:100,page:i==null?void 0:i.page,orderBy:i==null?void 0:i.orderBy,where:(i==null?void 0:i.where)&&`${i.where.fieldName} ${i.where.operator} ${i.where.term}`},"?");s+=p}return s};var $=t=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t}))}),I=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"activity",opts:e}))}),M=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"badges",opts:e}))}),U=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"donations",opts:e}))}),E=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"donors",opts:e}))}),j=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"incentives",opts:e}))}),q=(t,e)=>r(void 0,null,function*(){return yield o(a({type:"participants",id:t,resource:"milestones",opts:e}))});var F=t=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams"}))}),L=(t,e)=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams",resource:"participants",opts:e}))}),_=(t,e)=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams",resource:"activity",opts:e}))}),k=(t,e)=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams",resource:"badges",opts:e}))}),N=(t,e)=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams",resource:"donations",opts:e}))}),X=(t,e)=>r(void 0,null,function*(){return yield o(a({id:t,type:"teams",resource:"donors",opts:e}))});0&&(module.exports={getParticipant,getParticipantActivity,getParticipantBadges,getParticipantDonations,getParticipantDonors,getParticipantIncentives,getParticipantMilestones,getTeam,getTeamActivity,getTeamBadges,getTeamDonations,getTeamDonors,getTeamParticipants});
//# sourceMappingURL=index.js.map