notbank
Version:
The Notbank for Node.js
3 lines (2 loc) • 43.9 kB
JavaScript
var NotbankSdk=(()=>{var er=Object.create;var $=Object.defineProperty,tr=Object.defineProperties,rr=Object.getOwnPropertyDescriptor,or=Object.getOwnPropertyDescriptors,ir=Object.getOwnPropertyNames,Le=Object.getOwnPropertySymbols,nr=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable;var ye=i=>{throw TypeError(i)};var Ge=(i,e,t)=>e in i?$(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,N=(i,e)=>{for(var t in e||(e={}))ke.call(e,t)&&Ge(i,t,e[t]);if(Le)for(var t of Le(e))sr.call(e,t)&&Ge(i,t,e[t]);return i},ee=(i,e)=>tr(i,or(e));var cr=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var mr=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Fe=(i,e)=>{for(var t in e)$(i,t,{get:e[t],enumerable:!0})},We=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ir(e))!ke.call(i,o)&&o!==t&&$(i,o,{get:()=>e[o],enumerable:!(r=rr(e,o))||r.enumerable});return i};var Be=(i,e,t)=>(t=i!=null?er(nr(i)):{},We(e||!i||!i.__esModule?$(t,"default",{value:i,enumerable:!0}):t,i)),ur=i=>We($({},"__esModule",{value:!0}),i);var ge=(i,e,t)=>e.has(i)||ye("Cannot "+t);var T=(i,e,t)=>(ge(i,e,"read from private field"),t?t.call(i):e.get(i)),E=(i,e,t)=>e.has(i)?ye("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),C=(i,e,t,r)=>(ge(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),a=(i,e,t)=>(ge(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,o)=>{var n=R=>{try{u(t.next(R))}catch(Pe){o(Pe)}},s=R=>{try{u(t.throw(R))}catch(Pe){o(Pe)}},u=R=>R.done?r(R.value):Promise.resolve(R.value).then(n,s);u((t=t.apply(i,e)).next())});var Vt=mr((Su,Ht)=>{"use strict";Ht.exports=WebSocket});var fr={};Fe(fr,{NotbankClient:()=>Ie,models:()=>De});var De={};Fe(De,{AccountType:()=>He,ActionType:()=>Ve,ArgentinaBankAccountKind:()=>Ye,BrazilBankAccountKind:()=>Ke,ChangeReason:()=>$e,ChileBankAccountKind:()=>Qe,ColombiaBankAccountKind:()=>Xe,DepositFeeMessages:()=>Ze,DepositStatus:()=>ze,Direction:()=>et,FeeCalcType:()=>Dt,FeeProductType:()=>tt,FeeType:()=>qt,InstrumentStateArgument:()=>rt,InstrumentType:()=>ot,MakerTaker:()=>it,NotbankError:()=>O,OrderFlag:()=>nt,OrderSide:()=>st,OrderState:()=>ct,OrderTypeInt:()=>mt,OrderTypeStr:()=>ut,PegPriceType:()=>at,PeruBankAccountKind:()=>Je,PixType:()=>St,ProductType:()=>pt,ReferenceType:()=>Rt,ReportFlavor:()=>Tt,ReportFrequency:()=>lt,ReportRequestStatus:()=>Et,ReportWriterResultStatus:()=>dt,RiskType:()=>Ot,SessionStatus:()=>ht,SideType:()=>ft,SubscriptionResponse:()=>Ue,SupportedCountry:()=>je,TimeInForce:()=>_t,TradeDirection:()=>vt,TradeSide:()=>Ct,TransactionReferenceTypes:()=>At,TransactionTypes:()=>It,UnsubscribeLevel2ErrorCode:()=>Pt,UnsubscribeTradesError:()=>gt,UnsubscriptionResponse:()=>be,WithdrawErrorCode:()=>Nt,WithdrawFeeMessages:()=>bt,WithdrawTemplateType:()=>Ut,orderbookFromRaw:()=>Ne});var He=(t=>(t.ASSET="Asset",t.LIABILITY="Liability",t))(He||{});var Ve=(r=>(r[r.NEW=0]="NEW",r[r.UPDATE=1]="UPDATE",r[r.DELETION=2]="DELETION",r))(Ve||{});var Ye=(u=>(u.CORRIENTE="corriente",u.VISTA="vista",u.AHORRO="ahorro",u.ELECTRONIC_CHECKBOOK="electronic_checkbook",u.AR_CBU="ar_cbu",u.AR_CVU="ar_cvu",u.AR_ALIAS="ar_alias",u))(Ye||{}),Ke=(u=>(u.BR_CORRIENTE_FISICA="br_corriente_fisica",u.BR_SIMPLE_FISICA="br_simple_fisica",u.BR_CORRIENTE_JURIDICA="br_corriente_juridica",u.BR_POUPANCA_FISICA="br_poupanca_fisica",u.BR_POUPANCA_JURIDICA="br_poupanca_juridica",u.BR_CAIXA_FACIL="br_caixa_facil",u.BR_PIX="br_pix",u))(Ke||{}),Qe=(o=>(o.CORRIENTE="corriente",o.VISTA="vista",o.AHORRO="ahorro",o.ELECTRONIC_CHECKBOOK="electronic_checkbook",o))(Qe||{}),Je=(t=>(t.CORRIENTE="corriente",t.AHORRO="ahorro",t))(Je||{}),Xe=(t=>(t.CORRIENTE="corriente",t.AHORRO="ahorro",t))(Xe||{});var $e=(d=>(d.UNKNOWN="Unknown",d.NEWINPUTACCEPTED="NewInputAccepted",d.NEWINPUTREJECTED="NewInputRejected",d.OTHERREJECTED="OtherRejected",d.EXPIRED="Expired",d.TRADE="Trade",d.SYSTEMCANCELED_NOMOREDMARKET="SystemCanceled_NoMoreMarket",d.SYSTEMCANCELED_BELOWMINIMUM="SystemCanceled_BelowMinimum",d.SYSTEMCANCELED_PRICECOLLAR="SystemCanceled_PriceCollar",d.SYSTEMCANCELED_MARGINFAILED="SystemCanceled_MarginFailed",d.USERMODIFIED="UserModified",d))($e||{});var je=(n=>(n.AR="AR",n.BR="BR",n.CL="CL",n.PE="PE",n.CO="CO",n))(je||{});var Ze=(r=>(r.Success="Fee calculated successfully",r.InvalidRequest="Invalid Request",r.AccountOrProductNotFound="Account or Product not found",r))(Ze||{});var ze=(o=>(o.New="New",o.Pending="Pending",o.FullyProcessed="FullyProcessed",o.Error="Error",o))(ze||{});var et=(r=>(r[r.NoChange=0]="NoChange",r[r.Uptick=1]="Uptick",r[r.DownTick=2]="DownTick",r))(et||{});var tt=(t=>(t.BASE_PRODUCT="BaseProduct",t.SINGLE_PRODUCT="SingleProduct",t))(tt||{});var rt=(t=>(t.BOTH="BOTH",t.INACTIVE="INACTIVE",t))(rt||{});var ot=(t=>(t.UNKNOWN="Unknown",t.STANDARD="Standard",t))(ot||{});var it=(r=>(r[r.Unknown=0]="Unknown",r[r.Maker=1]="Maker",r[r.Taker=2]="Taker",r))(it||{});var nt=(s=>(s.NoAccountRiskCheck="NoAccountRiskCheck",s.AddedToBook="AddedToBook",s.RemovedFromBook="RemovedFromBook",s.PostOnly="PostOnly",s.Liquidation="Liquidation",s.ReverseMarginPosition="ReverseMarginPosition",s))(nt||{});var st=(t=>(t[t.Buy=0]="Buy",t[t.Sell=1]="Sell",t))(st||{});var ct=(s=>(s.Unknown="Unknown",s.Working="Working",s.Rejected="Rejected",s.Canceled="Canceled",s.Expired="Expired",s.FullyExecuted="Fully Executed",s))(ct||{});var mt=(R=>(R[R.Unknown=0]="Unknown",R[R.Market=1]="Market",R[R.Limit=2]="Limit",R[R.StopMarket=3]="StopMarket",R[R.StopLimit=4]="StopLimit",R[R.TrailingStopMarket=5]="TrailingStopMarket",R[R.TrailingStopLimit=6]="TrailingStopLimit",R[R.BlockTrade=7]="BlockTrade",R))(mt||{}),ut=(R=>(R.Unknown="Unknown",R.Market="Market",R.Limit="Limit",R.StopMarket="StopMarket",R.StopLimit="StopLimit",R.TrailingStopMarket="TrailingStopMarket",R.TrailingStopLimit="TrailingStopLimit",R.BlockTrade="BlockTrade",R))(ut||{});var at=(o=>(o[o.Last=1]="Last",o[o.Bid=2]="Bid",o[o.Ask=3]="Ask",o[o.Midpoint=4]="Midpoint",o))(at||{});var St=(n=>(n.CPF="CPF",n.CNPJ="CNPJ",n.EMAIL="Email",n.PHONE="Phone",n.OTRO="Otro",n))(St||{});var pt=(o=>(o.UNKNOWN="Unknown",o.NATIONAL_CURRENCY="NationalCurrency",o.CRYPTO_CURRENCY="CryptoCurrency",o.CONTRACT="Contract",o))(pt||{});var Rt=(e=>(e.Withdraw="Withdraw",e))(Rt||{});var Tt=(s=>(s.TradeActivity="TradeActivity",s.TransactionActivity="TransactionActivity",s.ProductDelta="ProductDelta",s.ProfitAndLoss="ProfitAndLoss",s.Transaction="Transaction",s.Treasury="Treasury",s))(Tt||{});var lt=(s=>(s.OnDemand="OnDemand",s.Hourly="Hourly",s.Daily="Daily",s.Weekly="Weekly",s.Monthly="Monthly",s.Annually="Annually",s))(lt||{});var Et=(d=>(d.Submitted="Submitted",d.Validating="Validating",d.Scheduled="Scheduled",d.InProgress="InProgress",d.Completed="Completed",d.Aborting="Aborting",d.Aborted="Aborted",d.UserCancelled="UserCancelled",d.SysRetired="SysRetired",d.Pending="Pending",d.UserCancelPending="UserCancelPending",d))(Et||{});var dt=(n=>(n.NotStarted="NotStarted",n.NotComplete="NotComplete",n.ErrorComplete="ErrorComplete",n.SuccessComplete="SuccessComplete",n.Cancelled="Cancelled",n))(dt||{});var Ot=(n=>(n.UNKNOWN="Unknown",n.NORMAL="Normal",n.NO_RISK_CHECK="NoRiskCheck",n.NO_TRADING="NoTrading",n.CREDIT="Credit",n))(Ot||{});var ht=(s=>(s.UNKNOWN="Unknown",s.RUNNING="Running",s.PAUSED="Paused",s.STOPPED="Stopped",s.STARTING="Starting",s.RUNNING_POST_ONLY="RunningPostOnly",s))(ht||{});var ft=(t=>(t.BUY="Buy",t.SELL="Sell",t))(ft||{});var _t=(u=>(u[u.Unknown=0]="Unknown",u[u.GTC=1]="GTC",u[u.OPG=2]="OPG",u[u.IOC=3]="IOC",u[u.FOK=4]="FOK",u[u.GTX=5]="GTX",u[u.GTD=6]="GTD",u))(_t||{});var vt=(r=>(r[r.NoChange=0]="NoChange",r[r.Uptick=1]="Uptick",r[r.DownTick=2]="DownTick",r))(vt||{});var Ct=(o=>(o[o.Buy=0]="Buy",o[o.Sell=1]="Sell",o[o.Short=2]="Short",o[o.Unknown=3]="Unknown",o))(Ct||{});var At=(S=>(S.Trade="Trade",S.Deposit="Deposit",S.Withdraw="Withdraw",S.Transfer="Transfer",S.OrderHold="OrderHold",S.WithdrawHold="WithdrawHold",S.DepositHold="DepositHold",S.MarginHold="MarginHold",S.ManualHold="ManualHold",S.ManualEntry="ManualEntry",S.MarginAcquisition="MarginAcquisition",S.MarginRelinquish="MarginRelinquish",S.MarginInterestNetting="MarginInterestNetting",S.MarginOperatorTransferToMarginAccount="MarginOperatorTransferToMarginAccount",S.MarginOperatorTransferToAssetAccount="MarginOperatorTransferToAssetAccount",S.MarginUserTransfer="MarginUserTransfer",S.MarginPositionReverseTrade="MarginPositionReverseTrade",S.AffiliateRebate="AffiliateRebate",S.DistributionEntry="DistributionEntry",S.TransferHold="TransferHold",S.AirDrop="AirDrop",S))(At||{});var It=(S=>(S.Fee="Fee",S.Trade="Trade",S.Other="Other",S.Reverse="Reverse",S.Hold="Hold",S.Rebate="Rebate",S.MarginAcquisition="MarginAcquisition",S.MarginRelinquishByTrade="MarginRelinquishByTrade",S.MarginInterestTransfer="MarginInterestTransfer",S.MarginOperatorTransferToMarginAccount="MarginOperatorTransferToMarginAccount",S.MarginOperatorTransferToAssetAccount="MarginOperatorTransferToAssetAccount",S.MarginUserTransfer="MarginUserTransfer",S.MarginRelinquishByTransfer="MarginRelinquishByTransfer",S.MarginRelinquishByReverseTrade="MarginRelinquishByReverseTrade",S.Distribution="Distribution",S.Payment="Payment",S.OperatorLend="OperatorLend",S.OperatorReceived="OperatorReceived",S.Rebalance="Rebalance",S.Commission="Commission",S.AirDrop="AirDrop",S))(It||{});var Pt=(s=>(s[s.SUCCESS=0]="SUCCESS",s[s.NOT_AUTHORIZED=20]="NOT_AUTHORIZED",s[s.INVALID_REQUEST=100]="INVALID_REQUEST",s[s.OPERATION_FAILED=101]="OPERATION_FAILED",s[s.SERVER_ERROR=102]="SERVER_ERROR",s[s.RESOURCE_NOT_FOUND=104]="RESOURCE_NOT_FOUND",s))(Pt||{});var gt=(n=>(n[n.NotAuthorized=20]="NotAuthorized",n[n.InvalidRequest=100]="InvalidRequest",n[n.OperationFailed=101]="OperationFailed",n[n.ServerError=102]="ServerError",n[n.ResourceNotFound=104]="ResourceNotFound",n))(gt||{});var Nt=(s=>(s[s.NoError=0]="NoError",s[s.NotAuthorized=20]="NotAuthorized",s[s.InvalidRequest=100]="InvalidRequest",s[s.OperationFailed=101]="OperationFailed",s[s.ServerError=102]="ServerError",s[s.ResourceNotFound=104]="ResourceNotFound",s))(Nt||{});var bt=(r=>(r.Success="Fee calculated successfully",r.InvalidRequest="Invalid Request",r.AccountOrProductNotFound="Account or Product not found",r))(bt||{});var Ut=(r=>(r.ToExternalBitcoinAddress="ToExternalBitcoinAddress",r.ToInternalAccount="ToInternalAccount",r.ToBankAccount="ToBankAccount",r))(Ut||{});var Dt=(t=>(t.Flat="Flat",t.Percentage="Percentage",t))(Dt||{}),qt=(n=>(n.Flat="Flat",n.MakerFee="MakerFee",n.TakerFee="TakerFee",n.PeggedProductFee="PeggedProductFee",n.AffiliateFee="AffiliateFee",n))(qt||{});function Ne(i){return{timestamp:i.timestamp,bids:i.bids.map(e=>({quantity:e[0],price:e[1]})),asks:i.asks.map(e=>({quantity:e[0],price:e[1]}))}}var j=class j extends Error{constructor(e,t){super("Notbank Error. "+e),this.code=t}};j.Factory=class{static createFromApResponse(t){var r="";return t.errorcode&&(r+=`(code=${t.errorcode})`),t.errormsg&&(r+=" "+t.errormsg+"."),t.detail&&(r+=" "+t.detail+"."),new j(r,t.errorcode||t.statusCode)}static createFromNbResponse(t){var r="";return t.message&&(r+=t.message,t.message.endsWith(".")||(r+=".")),t.detail&&(r+=" "+t.detail,t.detail.endsWith(".")||(r+=".")),new j(r,-1)}};var O=j;var be=class{};var Ue=class{};var Mt=Be(cr("crypto"));function ar(i){return Math.floor(Math.random()*i)}function te(){return ar(1e6).toString()}function re(i,e,t,r){var o=r+t+i;let n=Mt.default.createHmac("sha256",e);return n.update(o),n.digest("hex")}var M,xt,wt,Z=class Z{static handle(e){return m(this,null,function*(){var o,n;if(e.status>=400||e.status<200)throw new Error(`http error (${e.status}) not a successfull response. ${yield a(o=Z,M,wt).call(o,e)}`);var t=yield a(n=Z,M,xt).call(n,e);if(!t)throw new O("http error. (status="+e.status+")",-1);var r=t;if((r==null?void 0:r.result)===!1&&(r==null?void 0:r.errorcode)!=null)throw O.Factory.createFromApResponse(r);return t})}};M=new WeakSet,xt=function(e){return m(this,null,function*(){try{return yield e.json()}catch(t){return null}})},wt=function(e){return m(this,null,function*(){try{return yield e.text()}catch(t){return null}})},E(Z,M);var oe=Z;var ne,Lt,se=class se{static handle(e,t){return m(this,null,function*(){var n;try{var r=yield a(n=se,ne,Lt).call(n,e);if(!r)throw new O("http error. (status="+e.status+")",-1);var o=r;if((o==null?void 0:o.status)==="success")return t?r:o.data;throw O.Factory.createFromNbResponse(o)}catch(s){throw s}})}};ne=new WeakSet,Lt=function(e){return m(this,null,function*(){try{return yield e.json()}catch(t){return null}})},E(se,ne);var ie=se;var b,ce=class{constructor(){E(this,b);C(this,b,null)}updateSessionToken(e){C(this,b,e)}request(e){let t=["POST","DELETE"].includes(e.requestType);var r=t?e.url:this.getUrlWithSearchParams(e.url,e.params),o=t?e.params:null,n={method:e.requestType,headers:this.getHeaders(e.extraHeaders)};return o&&(n.body=JSON.stringify(o)),fetch(r,n)}getHeaders(e){var t={"Content-type":"application/json",charset:"UTF-8"};return T(this,b)&&(t.aptoken=T(this,b)),e?N(N({},t),e):t}getUrlWithSearchParams(e,t){return t?e+"?"+new URLSearchParams(t):e}};b=new WeakMap;var U,x,me=class{constructor(e){E(this,U);E(this,x);C(this,U,new ce),C(this,x,"https://"+e)}nbRequest(e,t,r,o=!1){return m(this,null,function*(){let n=this.getNbUrl(e);var s=yield T(this,U).request({url:n,requestType:t,params:r});return yield ie.handle(s,o)})}apRequest(e,t,r,o){return m(this,null,function*(){let n=this.getApUrl(e);var s=yield T(this,U).request({url:n,requestType:t,params:r,extraHeaders:o});return yield oe.handle(s)})}authenticateUser(e){return m(this,null,function*(){var t=yield this.apRequest("AuthenticateUser","GET",null,e);T(this,U).updateSessionToken(t.SessionToken)})}subscribe(e,t,r,o,n){throw new Error("Method not implemented.")}unsubscribe(e,t,r,o,n){throw new Error("Method not implemented.")}setResponseHandler(e){throw new Error("Method not implemented.")}setResponseHandlers(e){throw new Error("Method not implemented.")}getApUrl(e){return T(this,x)+"/ap/"+e}getNbUrl(e){return T(this,x)+"/api/nb/"+e}connect(){return Promise.resolve()}close(){return Promise.resolve()}};U=new WeakMap,x=new WeakMap;function c(i,e){return ee(N({},i),{OMSId:e})}var w=class{constructor(e){this.OMS_ID=1;this.connection=e}getAccountTransactions(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountTransactions","POST",t)}getAccountPositions(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountPositions","POST",t)}getAccountInstrumentStatistics(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountInstrumentStatistics","POST",t)}getAccountInfo(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountInfo","POST",t)})}};var L=class{constructor(e){this.connection=e}webAuthenticateUser(e){return m(this,null,function*(){return yield this.connection.apRequest("WebAuthenticateUser","NONE",e)})}logOut(){return m(this,null,function*(){return yield this.connection.apRequest("LogOut","POST")})}};var G=class{constructor(e){this.OMS_ID=1;this.connection=e}getDepositFee(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetDepositFee","POST",t)}getWithdrawFee(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetWithdrawFee","POST",t)}getOMSWithdrawFees(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOMSWithdrawFees","POST",t)}getOMSDepositFees(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOMSDepositFees","POST",t)})}getAccountFees(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountFees","POST",t)})}getOrderFee(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderFee","POST",t)})}};var k=class{constructor(e){this.OMS_ID=1;this.connection=e,this.instrumentCache={}}getInstruments(e={}){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstruments","POST",t)}getInstrument(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstrument","POST",t)}getInstrumentBySymbol(e){return m(this,null,function*(){if(!(e.symbol in this.instrumentCache)){var t=yield this.getInstruments();t.map(r=>this.instrumentCache[r.Symbol]=r)}if(e.symbol in this.instrumentCache)return Promise.resolve(this.instrumentCache[e.symbol]);throw new O("no instrument found for symbol "+e.symbol,-1)})}getInstrumentVerificationLevelConfigs(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetInstrumentVerificationLevelConfig","POST",t)})}};var y=class{constructor(e){this.OMS_ID=1;this.connection=e,this.productCache={}}getProduct(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetProduct","POST",t)}getProducts(){return m(this,arguments,function*(e={}){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetProducts","POST",t)})}getProductBySymbol(e){return m(this,null,function*(){if(!(e.symbol in this.productCache)){var t=yield this.getProducts();t.map(r=>this.productCache[r.Product]=r)}if(e.symbol in this.productCache)return Promise.resolve(this.productCache[e.symbol]);throw new O("no product found for symbol "+e.symbol,-1)})}getVerificationLevelConfig(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return yield this.connection.apRequest("GetVerificationLevelConfig","POST",t)})}};var F=class{constructor(e){this.OMS_ID=1;this.connection=e}generateTradeActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateTradeActivityReport","POST",t)}generateTransactionActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateTransactionActivityReport","POST",t)}generateProductDeltaActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GenerateProductDeltaActivityReport","POST",t)}generatePnLActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GeneratePnLActivityReport","POST",t)}scheduleTradeActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleTradeActivityReport","POST",t)}scheduleTransactionActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleTransactionActivityReport","POST",t)}scheduleProductDeltaActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleProductDeltaActivityReport","POST",t)}scheduleProfitAndLossActivityReport(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ScheduleProfitAndLossActivityReport","POST",t)}cancelUserReport(e){return this.connection.apRequest("CancelUserReport","POST",e)}getUserReportWriterResultRecords(e){return this.connection.apRequest("GetUserReportWriterResultRecords","POST",e)}getUserReportTickets(e){return this.connection.apRequest("GetUserReportTickets","POST",e)}removeUserReportTicket(e){return this.connection.apRequest("RemoveUserReportTicket","POST",e.UserReportTicketId)}getUserReportTicketsByStatus(e){return this.connection.apRequest("GetUserReportTicketsByStatus","POST",e)}downloadDocument(e){return this.connection.apRequest("DownloadDocument","POST",e)}downloadDocumentSlice(e){return this.connection.apRequest("DownloadDocumentSlice","POST",e)}};var W=class{constructor(e){this.connection=e}ping(){return this.connection.apRequest("Ping","POST")}healthCheck(){return this.connection.apRequest("HealthCheck","POST")}};function ue(i,e){return i.map(t=>ee(N({},t),{OMSId:e}))}function ae(i){return{TradeId:i[0],InstrumentId:i[1],Quantity:i[2],Price:i[3],Order1:i[4],Order2:i[5],Tradetime:i[6],Direction:i[7],TakerSide:i[8],BlockTrade:i[9]==1,OrderClientId:i[10]}}var B=class{constructor(e){this.OMS_ID=1;this.connection=e}sendOrderList(e){let t=ue(e,this.OMS_ID);return this.connection.apRequest("SendOrderList","POST",t)}sendCancelList(e){let t=ue(e,this.OMS_ID);return this.connection.apRequest("SendCancelList","POST",t)}sendCancelReplaceList(e){let t=ue(e,this.OMS_ID);return this.connection.apRequest("SendCancelReplaceList","POST",t)}modifyOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("ModifyOrder","POST",t)}cancelAllOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelAllOrders","POST",t)}getOrderStatus(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderStatus","POST",t)})}getOrdersHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrdersHistory","POST",t)}getTradesHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetTradesHistory","POST",t)}getOrderHistoryByOrderId(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderHistoryByOrderId","POST",t)}getTickerHistory(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetTickerHistory","POST",t)).map(o=>({EndDateTime:o[0],High:o[1],Low:o[2],Open:o[3],Close:o[4],Volume:o[5],Bid:o[6],Ask:o[7],InstrumentId:o[8],BeginDateTime:o[9]}))})}getLastTrades(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetLastTrades","POST",t)).map(o=>ae(o))})}getLevel1Summary(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetLevel1Summary","POST",t)})}getLevel1SummaryMin(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetLevel1SummaryMin","POST",t)).map(o=>({InstrumentId:o[0],InstrumentSymbol:o[1].toString(),LastTradedPx:o[2],Rolling24HrPxChange:o[3],Rolling24HrPxChangePercent:o[4],Rolling24HrVolume:o[5]}))})}getOpenTradeReports(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOpenTradeReports","POST",t)}getOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrders","POST",t)}getOrderHistory(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOrderHistory","POST",t)}sendOrder(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.apRequest("SendOrder","POST",t)})}cancelReplaceOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelReplaceOrder","POST",t)}cancelOrder(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("CancelOrder","POST",t)}getOpenOrders(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetOpenOrders","POST",t)}getAccountTrades(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetAccountTrades","POST",t)}getSummary(){return this.connection.apRequest("Summary","POST")}getTicker(){return this.connection.apRequest("Ticker","POST")}getOrderBook(e){return m(this,null,function*(){let t=yield this.connection.apRequest("OrderBook","POST",e);return Ne(t)})}getOrderBookRaw(e){return this.connection.apRequest("OrderBook","POST",e)}getTrades(e){return this.connection.apRequest("Trades","POST",e)}getL2Snapshot(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return(yield this.connection.apRequest("GetL2Snapshot","POST",t)).map(o=>({MDUpdateID:o[0],NumberOfUniqueAccounts:o[1],ActionDateTime:o[2],ActionType:o[3],LastTradePrice:o[4],NumberOfOrders:o[5],Price:o[6],ProductPairCode:o[7],Quantity:o[8],Side:o[9]}))})}getLevel1(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetLevel1","POST",t)}getEnums(){return this.connection.apRequest("GetEnums","POST")}};var H=class{constructor(e){this.OMS_ID=1;this.connection=e}getUserAccounts(e){let t=c(e,this.OMS_ID);return this.connection.apRequest("GetUserAccounts","POST",t)}getUserDevices(e){return this.connection.apRequest("GetUserDevices","POST",e)}getUserInfo(e){return this.connection.apRequest("GetUserInfo","POST",e)}getUserPermissions(e){return this.connection.apRequest("GetUserPermissions","POST",e)}};var V,Se,Y=class{constructor(e){E(this,V);this.connection=e}getBanks(e){return a(this,V,Se).call(this,"banks","GET",e)}AddClientBankAccount(e){return this.connection.nbRequest("bank-accounts","POST",e)}getClientBankAccount(e){return this.connection.nbRequest("bank-accounts/"+e.bankAccountId,"GET")}getClientBankAccounts(e){return a(this,V,Se).call(this,"bank-accounts","GET",e)}deleteClientBankAccount(e){return this.connection.nbRequest("bank-accounts/"+e.bankAccountId,"DELETE")}getNetworksTemplates(e){return this.connection.nbRequest("wallet/crypto/withdrawal/templates","GET",e)}getDepositAddresses(e){return this.connection.nbRequest("wallet/crypto","GET",e)}createDepositAddress(e){return this.connection.nbRequest("wallet/crypto","POST",e)}getWhitelistedAddresses(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses","GET",e)}addWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses","POST",e)}confirmWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId+"/verification","POST",{sms_code:e.sms_code,account_id:e.account_id})}resendVerificationCodeWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId+"/verification","GET",{account_id:e.account_id})}deleteWhitelistedAddress(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/"+e.whitelistedAddressId,"DELETE",{account_id:e.account_id,otp:e.otp})}updateOneStepWithdraw(e){return this.connection.nbRequest("wallet/crypto/whitelist-addresses/one-step/status","POST",e)}createCryptoWithdraw(e){return this.connection.nbRequest("wallet/crypto/withdrawal","POST",e)}createFiatDeposit(e){return m(this,null,function*(){let t=yield this.connection.nbRequest("wallet/fiat/deposit","POST",e);return t==null?void 0:t.url})}getOwnersFiatWithdraw(e){return this.connection.nbRequest("wallet/fiat/withdrawal/owners","GET",e)}createFiatWithdraw(e){return m(this,null,function*(){let t=yield this.connection.nbRequest("wallet/fiat/withdrawal","POST",e);return t==null?void 0:t.withdrawal_id})}confirmFiatWithdraw(e){return this.connection.nbRequest("wallet/fiat/withdrawal/"+e.withdrawal_id,"POST",{attempt_code:e.attempt_code})}transferFunds(e){return this.connection.nbRequest("wallet/transfer-funds","POST",e)}getTransactions(e){return a(this,V,Se).call(this,"wallet/transactions","GET",e)}};V=new WeakSet,Se=function(e,t,r){return this.connection.nbRequest(e,t,r,!0)};var K=class{constructor(e){this.connection=e}getQuotes(e){return this.connection.nbRequest("quotes","GET",e)}createDirectQuote(e){return m(this,null,function*(){return(yield this.connection.nbRequest("quotes/direct","POST",e)).id})}createInverseQuote(e){return m(this,null,function*(){return(yield this.connection.nbRequest("quotes/inverse","POST",e)).id})}getQuote(e){return this.connection.nbRequest("quotes/"+e.quote_id,"GET",e)}executeQuote(e){return this.connection.nbRequest("quotes/"+e.quote_id,"POST",e)}};var Sr="api.notbank.exchange",h,pe=class{constructor(e){E(this,h);let t=e||Sr;C(this,h,new me(t))}authenticateUser(e){var t=te(),r=re(e.ApiPublicKey,e.ApiSecretKey,e.UserId,t);return T(this,h).authenticateUser({APIKey:e.ApiPublicKey,Signature:r,UserId:e.UserId,Nonce:t})}newAccountService(){return new w(T(this,h))}newAuthService(){return new L(T(this,h))}newFeeService(){return new G(T(this,h))}newInstrumentService(){return new k(T(this,h))}newProductService(){return new y(T(this,h))}newReportService(){return new F(T(this,h))}newSystemService(){return new W(T(this,h))}newTradingService(){return new B(T(this,h))}newUserService(){return new H(T(this,h))}newWalletService(){return new Y(T(this,h))}newQuoteService(){return new K(T(this,h))}};h=new WeakMap;var Re=class{constructor(e=1e4,t=5e3){this.pingIntervalMillis=e,this.pingTimeoutMillis=t}startPing(e,t){this.stop(),this.interval=setInterval(()=>m(this,null,function*(){try{yield Promise.race([e.apRequest("Ping","NONE"),new Promise((r,o)=>setTimeout(o,this.pingTimeoutMillis))])}catch(r){yield t.reconnect();return}}),this.pingIntervalMillis),this.interval.unref()}stop(){this.interval&&clearTimeout(this.interval)}};var Te=class{constructor(){this.authenticateFn=null}updateAuthentication(e){this.authenticateFn=e}removeAuthentication(){this.authenticateFn=null}makeAuthentication(e){this.authenticateFn!==null&&this.authenticateFn(e)}};var Ee,p,qe,Me,xe,we,Gt,A,kt,le,yt,Rr,Ft,Wt,l=class l{static get(e,t=null,r=null){var o,n;return e+a(o=l,p,qe).call(o,t)+a(n=l,p,qe).call(n,r)}static getFromMessageFrame(e){var t,r,o;return(o=(r=(t=T(this,Ee))[e.n])==null?void 0:r.call(t,e.n,e.o))!=null?o:e.n}};Ee=new WeakMap,p=new WeakSet,qe=function(e){return e!=null?"_"+e:""},Me=function(e,t){var o;let r=a(o=l,p,le).call(o,t,8);return r==null?e:e+"_"+r},xe=function(e,t){var r;return e+"_"+a(r=l,p,yt).call(r,t)},we=function(e,t){var o;let r=a(o=l,p,le).call(o,t,7);return r==null?e:e+"_"+r},Gt=function(e,t){var o;let r=a(o=l,p,le).call(o,t,1);return r==null?e:e+"_"+r},A=function(e,t){var o;let r=a(o=l,p,Ft).call(o,t);return r!=null||(r=a(this,p,Wt).call(this,t),r!=null)?e+"_"+r:e},kt=function(e,t){let r=JSON.parse(t),o=e+"_"+r.AccountId;if(r.InstrumentId)return o+"_"+r.InstrumentId},le=function(e,t){let r=JSON.parse(e);return r.length==0||r[0].length<=t?null:r[0][t]},yt=function(e){return JSON.parse(e).InstrumentId},Rr=function(e){return JSON.parse(e).Instrument},Ft=function(e){return JSON.parse(e).AccountId},Wt=function(e){return JSON.parse(e).Account},E(l,p),E(l,Ee,{SubscribeLevel1:a(l,p,xe),Level1UpdateEvent:a(l,p,xe),SubscribeLevel2:a(l,p,we),Level2UpdateEvent:a(l,p,we),SubscribeTicker:a(l,p,Me),TickerDataUpdateEvent:a(l,p,Me),SubscribeTrades:a(l,p,Gt),SubscribeOrderStateEvents:a(l,p,kt),TransactionEvent:a(l,p,A),WithdrawTicketUpdateEvent:a(l,p,A),AccountPositionEvent:a(l,p,A),OrderTradeEvent:a(l,p,A),OrderStateEvent:a(l,p,A),DepositTicketUpdateEvent:a(l,p,A),AccountInfoUpdateEvent:a(l,p,A),CancelOrderRejectEvent:a(l,p,A),DepositEvent:a(l,p,A)});var I=l;var Oe,Bt,de=class{constructor(){E(this,Oe);this.currentSubscriptions=[]}saveSubscription(e){this.currentSubscriptions.push(e)}removeSubscription(e){for(let r=0;r<e.length;r++)for(let o=0;o<this.currentSubscriptions.length;o++){var t=a(this,Oe,Bt).call(this,this.currentSubscriptions[o],e[r]);if(t){this.currentSubscriptions.splice(o,1);return}}}makeSubscriptions(e){this.currentSubscriptions.forEach(t=>e.subscribe(t.endpoint,t.firstIdentifier,t.secondIdentifier,t.message,t.subscriptionHandlers))}};Oe=new WeakSet,Bt=function(e,t){var r=I.get(e.endpoint,e.firstIdentifier,e.secondIdentifier);return r===t};var Qt=Be(Vt());var D,q,Q,he=class{constructor(){E(this,D);E(this,q);E(this,Q);C(this,D,{}),C(this,q,{}),C(this,Q,2)}putCallback(e){var t=T(this,Q);return T(this,q)[t]=e,C(this,Q,T(this,Q)+2),t}popCallback(e){let t=T(this,q)[e];return delete T(this,q)[e],t!=null?t:r=>null}addSubscriptionCallback(e,t){T(this,D)[e]=t}getSubscriptionCallback(e){return T(this,D)[e]||null}removeSubscriptionCallback(e){e.map(t=>delete T(this,D)[t])}};D=new WeakMap,q=new WeakMap,Q=new WeakMap;var Yt=(u=>(u[u.UNDEFINED=-1]="UNDEFINED",u[u.NOT_AN_ERROR=0]="NOT_AN_ERROR",u[u.NOT_AUTHORIZED=20]="NOT_AUTHORIZED",u[u.INVALID_RESPONSE=100]="INVALID_RESPONSE",u[u.OPERATION_FAILED=101]="OPERATION_FAILED",u[u.SERVER_ERROR=102]="SERVER_ERROR",u[u.RESOURCE_NOT_FOUND=104]="RESOURCE_NOT_FOUND",u))(Yt||{}),Kt=Yt;var Tr=i=>{},lr="api.notbank.exchange",v,Jt,Xt,fe,$t,jt,J=class{constructor(e){E(this,v);this.domain=(e==null?void 0:e.domain)||lr,this.callbackManager=new he,this.hooks=(e==null?void 0:e.websocketHooks)||{},this.peekMessageIn=(e==null?void 0:e.peekMessageIn)||(t=>{}),this.peekMessageOut=(e==null?void 0:e.peekMessageOut)||(t=>{})}nbRequest(e,t,r){throw new Error("websocket client does not support nb methods.")}connect(){return m(this,null,function*(){return this.websocket=new Qt.default("wss://"+this.domain+"/wsgateway"),this.websocket.onopen=e=>{var t,r;return(r=(t=this.hooks).onOpen)==null?void 0:r.call(t,e)},this.websocket.onclose=e=>{var t,r;return(r=(t=this.hooks).onClose)==null?void 0:r.call(t,e)},this.websocket.onerror=e=>{var t,r;return(r=(t=this.hooks).onError)==null?void 0:r.call(t,e)},this.websocket.addEventListener("message",e=>{let t=JSON.parse(e.data);a(this,v,Xt).call(this,t)}),this.websocket.addEventListener("message",e=>{var t,r;return(r=(t=this.hooks).onMessage)==null?void 0:r.call(t,e)}),new Promise((e,t)=>this.websocket.addEventListener("open",r=>e()))})}close(){return this.websocket.close()}get readyState(){return this.websocket.readyState}apRequest(e,t,r){return a(this,v,fe).call(this,e,r,0)}subscribe(e,t,r,o,n){return m(this,null,function*(){return n.map(s=>this.callbackManager.addSubscriptionCallback(I.get(s.eventName,t,r),s.eventHandler)),a(this,v,fe).call(this,e,o,0)})}unsubscribe(e,t,r,o,n){return m(this,null,function*(){return this.callbackManager.removeSubscriptionCallback(n.map(s=>I.get(s,t,r))),yield a(this,v,fe).call(this,e,o,0)})}closeConnection(){this.websocket.socket.close()}authenticateUser(e){return m(this,null,function*(){yield this.apRequest("AuthenticateUser","NONE",e)})}};v=new WeakSet,Jt=function(e){return I.getFromMessageFrame(e)},Xt=function(e){this.peekMessageIn(e);let t=this.callbackManager.popCallback(e.i);if(t!=null&&(t(e),dr(e)))return;let r=a(this,v,Jt).call(this,e),o=this.callbackManager.getSubscriptionCallback(r);if(o!=null){o(e);return}},fe=function(e,t,r=0){return new Promise((o,n)=>{a(this,v,jt).call(this,e,JSON.stringify(t)||"{}",r,a(this,v,$t).call(this,n,o))})},$t=function(e,t){return r=>{try{var o=JSON.parse(r.o)}catch(s){e(Er(r.o));return}if(r.m===5){e(O.Factory.createFromApResponse(o));return}var n=o;if((n==null?void 0:n.result)===!1&&(n==null?void 0:n.errormsg)!=null){e(O.Factory.createFromApResponse(o));return}t(o)}},jt=function(e,t,r,o=Tr){let n=this.callbackManager.putCallback(o),s={m:r,i:n,n:e,o:t};this.peekMessageOut(s),this.websocket.send(JSON.stringify(s))};function Er(i){return O.Factory.createFromApResponse({result:!1,errormsg:i,errorcode:Kt.UNDEFINED,statusCode:-1,detail:""})}function dr(i){if(i.m===5)return!0;try{return i.o.result==!1}catch(t){return!1}}var X,Zt,zt,_e=class{constructor(e){E(this,X);this.closeRequested=!1,this.reconnecting=!1,this.connectionConfiguration=e.connectionConfiguration,this.pinger=new Re,this.resubscriber=new de,this.reauther=new Te,this.connection=null}getResubscriber(){return this.resubscriber}getReauther(){return this.reauther}getConnection(){if(this.reconnecting)throw new O("unable to make notbank request. websocket reconnecting",-1);return this.connection}reconnect(){return m(this,null,function*(){this.reconnecting||this.closeRequested||(this.reconnecting=!0,this.closeCurrentConnection(),this.connection=a(this,X,zt).call(this),yield a(this,X,Zt).call(this),this.reauther.makeAuthentication(this.connection),this.resubscriber.makeSubscriptions(this.connection),this.pinger.startPing(this.connection,this),this.reconnecting=!1)})}closeCurrentConnection(){var t;this.pinger.stop();var e=(t=this.connection)==null?void 0:t.close();return e}close(){this.closeRequested=!0;var e=this.closeCurrentConnection();return e}};X=new WeakSet,Zt=function(){return m(this,null,function*(){for(;!this.closeRequested;)try{yield Promise.race([this.connection.connect(),new Promise((e,t)=>setTimeout(t,1e4))]);return}catch(e){}})},zt=function(){var e,t;return new J({domain:this.connectionConfiguration.domain,peekMessageIn:this.connectionConfiguration.peekMessageIn,peekMessageOut:this.connectionConfiguration.peekMessageOut,websocketHooks:{onMessage:(e=this.connectionConfiguration.websocketHooks)==null?void 0:e.onMessage,onOpen:(t=this.connectionConfiguration.websocketHooks)==null?void 0:t.onOpen,onError:r=>{var o,n;this.reconnecting||(n=(o=this.connectionConfiguration.websocketHooks)==null?void 0:o.onError)==null||n.call(o,r)},onClose:r=>{var o,n;this.reconnecting||!this.closeRequested||(n=(o=this.connectionConfiguration.websocketHooks)==null?void 0:o.onClose)==null||n.call(o,r)}}})};var ve=class{constructor(e){this.restarter=e.restarter}apRequest(e,t,r){return e==="LogOut"&&this.restarter.getReauther().removeAuthentication(),this.restarter.getConnection().apRequest(e,t,r)}nbRequest(e,t,r,o){throw new Error("websocket client does not support nb methods.")}authenticateUser(e){return m(this,null,function*(){yield this.restarter.getConnection().authenticateUser(e),this.restarter.getReauther().updateAuthentication(t=>t.authenticateUser(e))})}subscribe(e,t,r,o,n){return m(this,null,function*(){yield this.restarter.getConnection().subscribe(e,t,r,o,n),this.restarter.getResubscriber().saveSubscription({endpoint:e,firstIdentifier:t,secondIdentifier:r,message:o,subscriptionHandlers:n})})}unsubscribe(e,t,r,o,n){return m(this,null,function*(){yield this.restarter.getConnection().unsubscribe(e,t,r,o,n),this.restarter.getResubscriber().removeSubscription(n)})}get readyState(){return this.restarter.getConnection().readyState}connect(){return this.restarter.reconnect()}close(){return this.restarter.close()}};function P(i,e){return e==null?null:g(i,e)}function g(i,e){return{eventName:i,eventHandler:t=>e(Or(t.o))}}function Or(i){return JSON.parse(i)}var Ce=class{constructor(e){this.OMS_ID=1;this.connection=e}subscribeLevel1(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeLevel1",e.InstrumentId||null,null,o,[g("SubscribeLevel1",t),g("Level1UpdateEvent",r)])}unsubscribeLevel1(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);yield this.connection.unsubscribe("UnsubscribeLevel1",e.InstrumentId||null,null,t,["SubscribeLevel1","UnsubscribeLevel1"])})}subscribeLevel2(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeLevel2",e.InstrumentId,null,o,[g("SubscribeLevel2",t),g("Level2UpdateEvent",r)])}unsubscribeLevel2(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeLevel2",e.InstrumentId||null,null,t,[I.get("SubscribeLevel2",e.InstrumentId)])}subscribeTrades(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeTrades",e.InstrumentId,null,r,[g("SubscribeTrades",o=>t(ae(o)))])}unsubscribeTrades(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeTrades",e.InstrumentId,null,t,["SubscribeTrades"])}subscribeTicker(e,t,r){let o=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeTicker",e.InstrumentId||null,null,o,[g("SubscribeTicker",t),g("TickerDataUpdateEvent_"+e.InstrumentId,r)])}unsubscribeTicker(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeTicker",e.InstrumentId||null,null,t,["SubscribeTicker"])}subscribeAccountEvents(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeAccountEvents",e.AccountId,null,r,[P("WithdrawTicketUpdateEvent",t.withdrawTicketUpdateEventHandler||null),P("OrderTradeEvent",t.orderTradeEventHandler||null),P("OrderStateEvent",t.orderStateEventHandler||null),P("DepositTicketUpdateEvent",t.depositTicketUpdateEventHandler||null),P("AccountPositionEvent",t.accountPositionEventHandler||null),P("AccountInfoUpdateEvent",t.accountInfoUpdateEventHandler||null),P("CancelOrderRejectEvent",t.cancelOrderRejectEventHandler||null),P("DepositEvent",t.depositEventHandler||null),P("TransactionEvent",t.transactionEventHandler||null)].filter(o=>o!=null))}unsubscribeAccountEvents(e){return m(this,null,function*(){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeAccountEvents",e.AccountId,null,t,["WithdrawTicketUpdateEvent","OrderTradeEvent","OrderStateEvent","DepositTicketUpdateEvent","AccountPositionEvent","AccountInfoUpdateEvent","CancelOrderRejectEvent","DepositEvent","TransactionEvent"])})}subscribeOrderStateEvents(e,t){let r=c(e,this.OMS_ID);return this.connection.subscribe("SubscribeOrderStateEvents",e.AccountId,e.InstrumentId||null,r,[g("OrderStateEvent",t)])}unsubscribeOrderStateEvents(e){let t=c(e,this.OMS_ID);return this.connection.unsubscribe("UnsubscribeOrderStateEvents",e.AccountId,e.InstrumentId||null,t,["SubscribeOrderStateEvents"])}};var Ae=class{constructor(e){var t=e!=null&&e.withReconnect?new ve({restarter:new _e({connectionConfiguration:e||{}})}):new J(e);this.serviceConnection=t,this.getReadyState=()=>t.readyState}connect(){return this.serviceConnection.connect()}close(){return this.serviceConnection.close()}get isConnecting(){return this.getReadyState()===WebSocket.CONNECTING}get isConnected(){return this.getReadyState()===WebSocket.OPEN}get isClosing(){return this.getReadyState()===WebSocket.CLOSING}get isClosed(){return this.getReadyState()===WebSocket.CLOSED}authenticateUser(e){return m(this,null,function*(){var t=te(),r=re(e.ApiPublicKey,e.ApiSecretKey,e.UserId,t);yield this.serviceConnection.authenticateUser({APIKey:e.ApiPublicKey,Signature:r,UserId:e.UserId,Nonce:t})})}newAccountService(){return new w(this.serviceConnection)}newAuthService(){return new L(this.serviceConnection)}newFeeService(){return new G(this.serviceConnection)}newInstrumentService(){return new k(this.serviceConnection)}newProductService(){return new y(this.serviceConnection)}newReportService(){return new F(this.serviceConnection)}newSystemService(){return new W(this.serviceConnection)}getSubscriptionService(){return new Ce(this.serviceConnection)}newTradingService(){return new B(this.serviceConnection)}newUserService(){return new H(this.serviceConnection)}newWalletService(){return new Y(this.serviceConnection)}newQuoteService(){return new K(this.serviceConnection)}};var hr="api.notbank.exchange",z=class z{constructor(e){this.accountService=e.accountService,this.authService=e.authService,this.feeService=e.feeService,this.instrumentService=e.instrumentService,this.productService=e.productService,this.reportService=e.reportService,this.getSubscriptionService=()=>e.getSubscriptionService(),this.systemService=e.systemService,this.tradingService=e.tradingService,this.userService=e.userService,this.walletService=e.walletService,this.quoteService=e.quoteService,this.authenticateUser=e.authenticate,this.connect=e.connect,this.close=e.close}getAccountService(){return this.accountService}getAuthService(){return this.authService}getFeeService(){return this.feeService}getInstrumentService(){return this.instrumentService}getProductService(){return this.productService}getReportService(){return this.reportService}getSystemService(){return this.systemService}getTradingService(){return this.tradingService}getUserService(){return this.userService}getWalletService(){return this.walletService}getQuoteService(){return this.quoteService}};z.Factory=class{static createRestClient(t=hr){var r=new pe(t);return new z({accountService:r.newAccountService(),authService:r.newAuthService(),feeService:r.newFeeService(),instrumentService:r.newInstrumentService(),productService:r.newProductService(),reportService:r.newReportService(),getSubscriptionService:()=>{throw new O("NotbankError. subcription service only exists for websocket connection",-1)},systemService:r.newSystemService(),tradingService:r.newTradingService(),userService:r.newUserService(),walletService:r.newWalletService(),quoteService:r.newQuoteService(),authenticate:o=>r.authenticateUser(o),connect:()=>Promise.resolve(null),close:()=>Promise.resolve(null)})}static createWebsocketClient(t){var r=new Ae(t);return new z({accountService:r.newAccountService(),authService:r.newAuthService(),feeService:r.newFeeService(),instrumentService:r.newInstrumentService(),productService:r.newProductService(),reportService:r.newReportService(),getSubscriptionService:()=>r.getSubscriptionService(),systemService:r.newSystemService(),tradingService:r.newTradingService(),userService:r.newUserService(),walletService:r.newWalletService(),quoteService:r.newQuoteService(),authenticate:o=>r.authenticateUser(o),connect:()=>r.connect(),close:()=>r.close()})}};var Ie=z;return ur(fr);})();
//# sourceMappingURL=bundle.min.js.map