UNPKG

@meteraprotocol/sdk

Version:

SDK to interact with Metera's API & a UI component that will create orders into the Metera Protocol

3 lines 6.89 kB
'use strict';var x=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var x__default=/*#__PURE__*/_interopDefault(x);var q=Object.defineProperty;var I=(r,e)=>{for(var s in e)q(r,s,{get:e[s],enumerable:!0});};var O={};I(O,{Configuration:()=>C,PortfoliosPricePostRequestPeriodEnum:()=>T,SDKApi:()=>b,SDKApiAxiosParamCreator:()=>y,SDKApiFactory:()=>G,SDKApiFp:()=>P});var l="http://localhost:3003".replace(/\/+$/,"");var A=class{constructor(e,s=l,o=x__default.default){this.basePath=s;this.axios=o;e&&(this.configuration=e,this.basePath=e.basePath??s);}configuration},S=class extends Error{constructor(s,o){super(o);this.field=s;this.name="RequiredError";}},u={};var d="https://example.com",f=function(r,e,s){if(s==null)throw new S(e,`Required parameter ${e} was null or undefined when calling ${r}.`)};function w(r,e,s=""){e!=null&&(typeof e=="object"?Array.isArray(e)?e.forEach(o=>w(r,o,s)):Object.keys(e).forEach(o=>w(r,e[o],`${s}${s!==""?".":""}${o}`)):r.has(s)?r.append(s,e):r.set(s,e));}var R=function(r,...e){let s=new URLSearchParams(r.search);w(s,e),r.search=s.toString();},h=function(r,e,s){let o=typeof r!="string";return (o&&s&&s.isJsonMime?s.isJsonMime(e.headers["Content-Type"]):o)?JSON.stringify(r!==void 0?r:{}):r||""},g=function(r){return r.pathname+r.search+r.hash},m=function(r,e,s,o){return (n=e,t=s)=>{let a={...r.options,url:(n.defaults.baseURL?"":o?.basePath??t)+r.url};return n.request(a)}};var T={_24h:"24h",_7d:"7d",_30d:"30d",All:"all"},y=function(r){return {ordersCreatePost:async(e,s={})=>{let o="/orders/create",n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",R(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:g(n),options:a}},ordersSubmitPost:async(e,s={})=>{f("ordersSubmitPost","ordersSubmitPostRequest",e);let o="/orders/submit",n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",R(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:g(n),options:a}},portfoliosGet:async(e={})=>{let s="/portfolios",o=new URL(s,d),n;r&&(n=r.baseOptions);let t={method:"GET",...n,...e},a={};R(o,{});let p=n&&n.headers?n.headers:{};return t.headers={...a,...p,...e.headers},{url:g(o),options:t}},portfoliosPricePost:async(e,s={})=>{f("portfoliosPricePost","portfoliosPricePostRequest",e);let o="/portfolios/price",n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",R(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:g(n),options:a}},portfoliosStateIdGet:async(e,s={})=>{f("portfoliosStateIdGet","id",e);let o="/portfolios/state/{id}".replace("{id}",encodeURIComponent(String(e))),n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"GET",...t,...s},i={};R(n,{});let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},{url:g(n),options:a}},swapCreatePost:async(e,s={})=>{f("swapCreatePost","swapCreatePostRequest",e);let o="/swap/create",n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",R(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:g(n),options:a}},swapSubmitPost:async(e,s={})=>{f("swapSubmitPost","swapSubmitPostRequest",e);let o="/swap/submit",n=new URL(o,d),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",R(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:g(n),options:a}}}},P=function(r){let e=y(r);return {async ordersCreatePost(s,o){let n=await e.ordersCreatePost(s,o),t=r?.serverIndex??0,a=u["SDKApi.ordersCreatePost"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)},async ordersSubmitPost(s,o){let n=await e.ordersSubmitPost(s,o),t=r?.serverIndex??0,a=u["SDKApi.ordersSubmitPost"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)},async portfoliosGet(s){let o=await e.portfoliosGet(s),n=r?.serverIndex??0,t=u["SDKApi.portfoliosGet"]?.[n]?.url;return (a,i)=>m(o,x__default.default,l,r)(a,t||i)},async portfoliosPricePost(s,o){let n=await e.portfoliosPricePost(s,o),t=r?.serverIndex??0,a=u["SDKApi.portfoliosPricePost"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)},async portfoliosStateIdGet(s,o){let n=await e.portfoliosStateIdGet(s,o),t=r?.serverIndex??0,a=u["SDKApi.portfoliosStateIdGet"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)},async swapCreatePost(s,o){let n=await e.swapCreatePost(s,o),t=r?.serverIndex??0,a=u["SDKApi.swapCreatePost"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)},async swapSubmitPost(s,o){let n=await e.swapSubmitPost(s,o),t=r?.serverIndex??0,a=u["SDKApi.swapSubmitPost"]?.[t]?.url;return (i,p)=>m(n,x__default.default,l,r)(i,a||p)}}},G=function(r,e,s){let o=P(r);return {ordersCreatePost(n,t){return o.ordersCreatePost(n,t).then(a=>a(s,e))},ordersSubmitPost(n,t){return o.ordersSubmitPost(n,t).then(a=>a(s,e))},portfoliosGet(n){return o.portfoliosGet(n).then(t=>t(s,e))},portfoliosPricePost(n,t){return o.portfoliosPricePost(n,t).then(a=>a(s,e))},portfoliosStateIdGet(n,t){return o.portfoliosStateIdGet(n,t).then(a=>a(s,e))},swapCreatePost(n,t){return o.swapCreatePost(n,t).then(a=>a(s,e))},swapSubmitPost(n,t){return o.swapSubmitPost(n,t).then(a=>a(s,e))}}},b=class extends A{ordersCreatePost(e,s){return P(this.configuration).ordersCreatePost(e,s).then(o=>o(this.axios,this.basePath))}ordersSubmitPost(e,s){return P(this.configuration).ordersSubmitPost(e,s).then(o=>o(this.axios,this.basePath))}portfoliosGet(e){return P(this.configuration).portfoliosGet(e).then(s=>s(this.axios,this.basePath))}portfoliosPricePost(e,s){return P(this.configuration).portfoliosPricePost(e,s).then(o=>o(this.axios,this.basePath))}portfoliosStateIdGet(e,s){return P(this.configuration).portfoliosStateIdGet(e,s).then(o=>o(this.axios,this.basePath))}swapCreatePost(e,s){return P(this.configuration).swapCreatePost(e,s).then(o=>o(this.axios,this.basePath))}swapSubmitPost(e,s){return P(this.configuration).swapSubmitPost(e,s).then(o=>o(this.axios,this.basePath))}};var C=class{apiKey;username;password;accessToken;basePath;serverIndex;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.serverIndex=e.serverIndex,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor;}isJsonMime(e){let s=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(s.test(e)||e.toLowerCase()==="application/json-patch+json")}}; exports.api=O;//# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map