@meteraprotocol/sdk
Version:
SDK to interact with Metera's API & a UI component that will create orders into the Metera Protocol
3 lines • 6.53 kB
JavaScript
import x from'axios';var y=Object.defineProperty;var I=(r,e)=>{for(var s in e)y(r,s,{get:e[s],enumerable:!0});};var l="http://localhost:3003".replace(/\/+$/,"");var A=class{constructor(e,s=l,o=x){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";}},P={};var u="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 d=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||""},R=function(r){return r.pathname+r.search+r.hash},g=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 _={_24h:"24h",_7d:"7d",_30d:"30d",All:"all"},q=function(r){return {ordersCreatePost:async(e,s={})=>{let o="/orders/create",n=new URL(o,u),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",d(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:R(n),options:a}},ordersSubmitPost:async(e,s={})=>{f("ordersSubmitPost","ordersSubmitPostRequest",e);let o="/orders/submit",n=new URL(o,u),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",d(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:R(n),options:a}},portfoliosGet:async(e={})=>{let s="/portfolios",o=new URL(s,u),n;r&&(n=r.baseOptions);let t={method:"GET",...n,...e},a={};d(o,{});let p=n&&n.headers?n.headers:{};return t.headers={...a,...p,...e.headers},{url:R(o),options:t}},portfoliosPricePost:async(e,s={})=>{f("portfoliosPricePost","portfoliosPricePostRequest",e);let o="/portfolios/price",n=new URL(o,u),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",d(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:R(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,u),t;r&&(t=r.baseOptions);let a={method:"GET",...t,...s},i={};d(n,{});let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},{url:R(n),options:a}},swapCreatePost:async(e,s={})=>{f("swapCreatePost","swapCreatePostRequest",e);let o="/swap/create",n=new URL(o,u),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",d(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:R(n),options:a}},swapSubmitPost:async(e,s={})=>{f("swapSubmitPost","swapSubmitPostRequest",e);let o="/swap/submit",n=new URL(o,u),t;r&&(t=r.baseOptions);let a={method:"POST",...t,...s},i={},p={};i["Content-Type"]="application/json",d(n,p);let c=t&&t.headers?t.headers:{};return a.headers={...i,...c,...s.headers},a.data=h(e,a,r),{url:R(n),options:a}}}},m=function(r){let e=q(r);return {async ordersCreatePost(s,o){let n=await e.ordersCreatePost(s,o),t=r?.serverIndex??0,a=P["SDKApi.ordersCreatePost"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)},async ordersSubmitPost(s,o){let n=await e.ordersSubmitPost(s,o),t=r?.serverIndex??0,a=P["SDKApi.ordersSubmitPost"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)},async portfoliosGet(s){let o=await e.portfoliosGet(s),n=r?.serverIndex??0,t=P["SDKApi.portfoliosGet"]?.[n]?.url;return (a,i)=>g(o,x,l,r)(a,t||i)},async portfoliosPricePost(s,o){let n=await e.portfoliosPricePost(s,o),t=r?.serverIndex??0,a=P["SDKApi.portfoliosPricePost"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)},async portfoliosStateIdGet(s,o){let n=await e.portfoliosStateIdGet(s,o),t=r?.serverIndex??0,a=P["SDKApi.portfoliosStateIdGet"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)},async swapCreatePost(s,o){let n=await e.swapCreatePost(s,o),t=r?.serverIndex??0,a=P["SDKApi.swapCreatePost"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)},async swapSubmitPost(s,o){let n=await e.swapSubmitPost(s,o),t=r?.serverIndex??0,a=P["SDKApi.swapSubmitPost"]?.[t]?.url;return (i,p)=>g(n,x,l,r)(i,a||p)}}},H=function(r,e,s){let o=m(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 m(this.configuration).ordersCreatePost(e,s).then(o=>o(this.axios,this.basePath))}ordersSubmitPost(e,s){return m(this.configuration).ordersSubmitPost(e,s).then(o=>o(this.axios,this.basePath))}portfoliosGet(e){return m(this.configuration).portfoliosGet(e).then(s=>s(this.axios,this.basePath))}portfoliosPricePost(e,s){return m(this.configuration).portfoliosPricePost(e,s).then(o=>o(this.axios,this.basePath))}portfoliosStateIdGet(e,s){return m(this.configuration).portfoliosStateIdGet(e,s).then(o=>o(this.axios,this.basePath))}swapCreatePost(e,s){return m(this.configuration).swapCreatePost(e,s).then(o=>o(this.axios,this.basePath))}swapSubmitPost(e,s){return m(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")}};
export{I as a,_ as b,q as c,m as d,H as e,b as f,C as g};//# sourceMappingURL=chunk-S7BPVYZK.js.map
//# sourceMappingURL=chunk-S7BPVYZK.js.map