-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathatomicmarket.js
1 lines (1 loc) · 4.11 KB
/
atomicmarket.js
1
var atomicmarket;(()=>{"use strict";var t={307:function(t,e,s){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const a=n(s(843));function i(t,e){var s;const n={};for(const t of e){const e=null!==(s=t.type)&&void 0!==s?s:"data";"number"==typeof t.value?n[e+":number."+t.key]=String(t.value):"boolean"==typeof t.value?n[e+":bool."+t.key]=t.value?"true":"false":n[e+"."+t.key]=t.value}return Object.assign({},t,n)}e.default=class{constructor(t,e,n){this.endpoint=t,this.namespace=e,n.fetch?this.fetchBuiltin=n.fetch:this.fetchBuiltin=s.g.fetch}async getSales(t={},e=1,s=100,n=[]){return await this.fetchEndpoint("/v1/sales",Object.assign({page:e,limit:s},i(t,n)))}async countSales(t,e=[]){return await this.countEndpoint("/v1/sales",i(t,e))}async getSale(t){return await this.fetchEndpoint("/v1/sales/"+t,{})}async getSaleLogs(t,e=1,s=100,n="desc"){return await this.fetchEndpoint("/v1/sales/"+t+"/logs",{page:e,limit:s,order:n})}async getAuctions(t={},e=1,s=100,n=[]){return await this.fetchEndpoint("/v1/auctions",Object.assign({page:e,limit:s},i(t,n)))}async countAuctions(t,e=[]){return await this.countEndpoint("/v1/auctions",i(t,e))}async getAuction(t){return await this.fetchEndpoint("/v1/auctions/"+t,{})}async getAuctionLogs(t,e=1,s=100,n="desc"){return await this.fetchEndpoint("/v1/auctions/"+t+"/logs",{page:e,limit:s,order:n})}async getBuyoffers(t={},e=1,s=100,n=[]){return await this.fetchEndpoint("/v1/buyoffers",Object.assign({page:e,limit:s},i(t,n)))}async countBuyoffers(t,e=[]){return await this.countEndpoint("/v1/buyoffers",i(t,e))}async getBuyoffer(t){return await this.fetchEndpoint("/v1/buyoffers/"+t,{})}async getBuyofferLogs(t,e=1,s=100,n="desc"){return await this.fetchEndpoint("/v1/buyoffers/"+t+"/logs",{page:e,limit:s,order:n})}async getMarketplaces(){return await this.fetchEndpoint("/v1/marketplaces",{})}async getMarketplace(t){return await this.fetchEndpoint("/v1/marketplaces/"+t,{})}async getConfig(){return await this.fetchEndpoint("/v1/config",{})}async getPriceHistory(t={}){return await this.fetchEndpoint("/v1/prices/sales",t)}async getPriceHistoryByDays(t={}){return await this.fetchEndpoint("/v1/prices/sales/days",t)}async getTemplatePriceStats(t={}){return await this.fetchEndpoint("/v1/prices/templates",t)}async getAssetPrices(t,e=[]){return await this.fetchEndpoint("/v1/prices/assets",Object.assign({},i(t,e)))}async getAssets(t={},e=1,s=100,n=[]){return await this.fetchEndpoint("/v1/assets",Object.assign({page:e,limit:s},i(t,n)))}async getAsset(t){return await this.fetchEndpoint("/v1/assets/"+t,{})}async getTransfers(t={},e=1,s=100){return await this.fetchEndpoint("/v1/transfers",Object.assign({page:e,limit:s},t))}async getOffers(t={},e=1,s=100){return await this.fetchEndpoint("/v1/offers",Object.assign({page:e,limit:s},t))}async getOffer(t){return await this.fetchEndpoint("/v1/offers/"+t,{})}async fetchEndpoint(t,e){let s,n;const i=this.fetchBuiltin,r=Object.keys(e).map((t=>{let s=e[t];return!0===s&&(s="true"),!1===s&&(s="false"),t+"="+encodeURIComponent(s)})).join("&");try{s=await i(this.endpoint+"/"+this.namespace+t+(r.length>0?"?"+r:"")),n=await s.json()}catch(t){throw new a.default(t.message,500)}if(200!==s.status)throw new a.default(n.message,s.status);if(!n.success)throw new a.default(n.message,s.status);return n.data}async countEndpoint(t,e){const s=await this.fetchEndpoint(t+"/_count",e);return parseInt(s,10)}}},843:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class s extends Error{constructor(t,e){super(t),this.message=t,this.status=e,this.isApiError=!0}}e.default=s},432:function(t,e,s){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.AtomicMarketApi=void 0;const a=n(s(307));e.AtomicMarketApi=a.default}},e={};function s(n){var a=e[n];if(void 0!==a)return a.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,s),i.exports}s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();var n=s(432);atomicmarket=n})();