lombongo-api-client 0.0.113 → 0.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/base.js CHANGED
@@ -1 +1 @@
1
- import t from"axios";class s{constructor(t){this.client=t,this.endpoint="/accounts"}async getAccounts(){return await this.client.request("get",this.endpoint)}async createAoaAccount(){return await this.client.request("post",this.endpoint,{currency:"aoa"},{})}async createEurAccount(){return await this.client.request("post",this.endpoint,{currency:"eur"},{})}}class i{constructor(t){this.observers=[],this.authState={authenticated:!1},this.client=t}_notifyObservers(){for(const t of this.observers)t(this.authState)}listObservers(){for(const t of this.observers)console.log(t)}onAuthStateChange(t){this.observers.push(t)}isAuthenticated(){return Boolean(this.client.token)}async signOut(){const t=this.client.lombongoIdBaseUrl,s=this.client.getToken();s&&await this.client.request("post","/users/logout",{token:s},{},t),delete this.client.token,this.authState.authenticated=!1,this.authState.user=void 0,this.authState.token=void 0,this._notifyObservers()}async createUser(t){const s=this.client.lombongoIdBaseUrl,i=(await this.client.request("post","/users",t,{},s)).data;return t.password&&delete t.password,this.authState={authenticated:!0,user:i.user,token:i.token},this._notifyObservers(),i}async login(t){const s=this._loginFactory(t),i=(await s(t)).data;return this.authState={authenticated:!0,user:{id:i.user.id,email:i.user.email,username:i.user.username},token:i.token},this._notifyObservers(),i}async verifyToken(t){const s=this.client.lombongoIdBaseUrl;return await this.client.request("post","/token",{token:t},{},s)}async checkUsernameAvailability(t){const s=this.client.lombongoIdBaseUrl,i=`/users/${t}/check-availability`;return await this.client.request("get",i,{},{},s)}async _loginWithEmailAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{email:t,password:s},{},i)}async _loginWithUsernameAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{username:t,password:s},{},i)}_loginFactory(t){if(!("email"in t)&&!("username"in t))throw new Error("Login credentials must include either an email or a username.");return async t=>{if(t.email)return this._loginWithEmailAndPassword(t.email,t.password);if(t.username)return this._loginWithUsernameAndPassword(t.username,t.password);throw new Error("Invalid login credentials provided.")}}}class e{constructor(t){this.client=t,this.endpoint="/beneficiaries"}async getBeneficiaries(){return await this.client.request("get",this.endpoint)}async getBeneficiary(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}async getBeneficiariesByType(t){const s=`${this.endpoint}?type=${t}`;return await this.client.request("get",s)}async getMyOwnBeneficiaries(t){let s;return s=t?`${this.endpoint}/my-own?type=${t}`:`${this.endpoint}/my-own`,await this.client.request("get",s)}async createBeneficiary(t,s,i,e=!1){return await this.client.request("post",this.endpoint,{name:t,iban:s,type:i,isMe:e})}}class n{constructor(t){this.client=t,this.endpoint="/commissions"}async get(){const t=`${this.endpoint}`;return await this.client.request("get",t)}async getHighCommission(){const t=`${this.endpoint}/high`;return await this.client.request("get",t)}}class r{constructor(t){this.client=t,this.endpoint="/current-commission"}async getCurrentCommission(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class a{constructor(t){this.client=t,this.endpoint="/cross-currency-transfer-types"}async getCrossCurrencyType(t,s){const i=`${this.endpoint}?origin_currency=${t}&final_currency=${s}`;return await this.client.request("get",i)}}class h{constructor(t){this.client=t,this.endpoint="/cross-currency-transfer-limits"}async getCrossCurrencyTransferLimits(){return await this.client.request("get",this.endpoint)}async getCrossCurrencyTransferLimitsById(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class c{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class o{constructor(t){this.client=t,this.endpoint="/fx-rates"}async getFxRates(){return await this.client.request("get",this.endpoint)}async getFxRate(t,s){return await this.client.request("post",this.endpoint,{originalCurrencyId:t,finalCurrencyId:s})}}class u{constructor(t){this.client=t,this.endpoint="/invitation-codes"}async generateNew(){return await this.client.request("post",this.endpoint)}async sendCodeTo(t,s){return await this.client.request("post",`${this.endpoint}/send`,{code:t,username:s})}async getMyInvitationCodes(){return await this.client.request("get",this.endpoint)}async redeemInvitationCode(t){return await this.client.request("get",`${this.endpoint}/${t}/redeem`)}}class y{constructor(t){this.client=t,this.endpoint="/liquidity-pools"}async getLiquidityPools(){return await this.client.request("get",this.endpoint)}async getLiquidityRatio(t){const s=`${this.endpoint}/${t}/liquidity-ratio`;return await this.client.request("get",s)}}class w{constructor(t,s){if(t<0)throw new Error("Amount cannot be negative");if(!Number.isInteger(t))throw new Error("Amount must be in smallest currency unit (cents)");this.amount=t,this.currencyCode=s.toUpperCase()}static fromDecimal(t,s){if(t<0)throw new Error("Amount cannot be negative");return new w(Math.round(100*t),s)}static fromCents(t,s){return new w(t,s)}static fromClientInput(t,s){return new w(t,s)}add(t){return this.ensureSameCurrency(t),new w(this.amount+t.amount,this.currencyCode)}subtract(t){if(this.ensureSameCurrency(t),this.amount<t.amount)throw new Error("Insufficient funds: cannot subtract larger amount");return new w(this.amount-t.amount,this.currencyCode)}multiply(t){if(t<0)throw new Error("Multiplication factor cannot be negative");return new w(Math.round(this.amount*t),this.currencyCode)}applyPercentage(t){if(t<0)throw new Error("Percentage cannot be negative");return this.multiply(t/100)}toDecimal(){return this.amount/100}toCents(){return this.amount}getCurrencyCode(){return this.currencyCode}isZero(){return 0===this.amount}equals(t){return this.amount===t.amount&&this.currencyCode===t.currencyCode}isGreaterThan(t){return this.ensureSameCurrency(t),this.amount>t.amount}toString(){return`${this.toDecimal().toFixed(2)} ${this.currencyCode}`}ensureSameCurrency(t){if(this.currencyCode!==t.currencyCode)throw new Error(`Cannot operate on different currencies: ${this.currencyCode} vs ${t.currencyCode}`)}}class g{constructor(t){this.client=t,this.endpoint="/transactions"}async get(){return await this.client.request("get",this.endpoint)}async getTransaction(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}async doCrossCurrency(t){const s=`${this.endpoint}/cross-currency`;return await this.client.request("post",s,t)}async doP2P(t){const s=`${this.endpoint}/p2p`;return await this.client.request("post",s,t)}async getFXConfig(t,s,i){const e=`${this.endpoint}/sepa/config`;return await this.client.request("post",e,{originalCurrencyId:t,finalCurrencyId:s,amount:i})}}class l{constructor(t){this.client=t,this.endpoint="/users"}async getInvitedStatus(){return(await this.client.request("get",`${this.endpoint}/me/check-if-invited`)).data}async verifyKyc(){const t=`${this.endpoint}/me/check-kyc-status`;return(await this.client.request("get",t)).data}}class m{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class d{constructor(t){this.client=t,this.endpoint="/offers"}async createOffer(t){return await this.client.request("post",this.endpoint,{...t})}async getOffers(){return await this.client.request("get",this.endpoint)}async getMyOffers(){const t=`${this.endpoint}/me`;return await this.client.request("get",t)}async getOffer(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class f{constructor(t){this.client=t,this.endpoint="/payment-methods"}async getPaymentMethods(){return await this.client.request("get",this.endpoint)}async getPaymentMethodsByCurrency(t){const s=`${this.endpoint}/currency/${t}`;return await this.client.request("get",s)}}class p{constructor(t){this.client=t,this.endpoint="/payments"}async getPaymentByTransactionId(t){const s=`${this.endpoint}?transaction_id=${t}`;return await this.client.request("get",s)}}class ${constructor(t){this.client=t,this.endpoint="/api/plaid/"}async createPaymentInitiationLinkToken(t){const s=this.endpoint+"create_link_token";return await this.client.request("post",s,{payment_id:t})}async createPaymentInitiation(t){const s=this.endpoint+"payment_initiation/payment/create";return await this.client.request("post",s,{amount:t})}}class C{constructor({baseUrl:t,token:C,lombongoIdBaseUrl:v}){this.unauthorizedListeners=[],this.baseUrl=t,this.token=C,this.lombongoIdBaseUrl=v,this.auth=new i(this),this.accounts=new s(this),this.beneficiaries=new e(this),this.commissions=new n(this),this.currencies=new c(this),this.currentCommision=new r(this),this.crossCurrencyTransferType=new a(this),this.crossCurrencyTransferLimits=new h(this),this.fxRates=new o(this),this.invitationCodes=new u(this),this.liquidityPools=new y(this),this.money=w,this.paymentMethods=new f(this),this.payments=new p(this),this.transactions=new g(this),this.users=new l(this),this.offers=new d(this),this.plaid=new $(this),this.veriff=new m(this),this.setupInterceptors()}static init(t){return C.instance?(t?.token&&(C.instance.token=t.token),t?.baseUrl&&(C.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(C.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),C.instance):(C.instance=new C(t),C.instance)}setupInterceptors(){t.interceptors.response.use((t=>t),(t=>(401===t.response?.status&&this.emit401Event(),Promise.reject(t))))}async request(s,i,e={},n={},r){const a=`${r||this.baseUrl}${i}`,h={...n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,...n.headers},method:s,url:a};return"GET"!==s.toUpperCase()&&Object.keys(e).length>0&&(h.data=e),await t(h)}setToken(t){this.token=t}getToken(){return this.token}onUnauthorized(t){this.unauthorizedListeners.push(t)}offUnauthorized(t){const s=this.unauthorizedListeners.indexOf(t);s>-1&&this.unauthorizedListeners.splice(s,1)}emit401Event(){for(const t of this.unauthorizedListeners)t()}}export{w as Money,C as default};
1
+ class t{constructor(t){this.client=t,this.endpoint="/accounts"}async getAccounts(){return await this.client.request("get",this.endpoint)}async createAoaAccount(){return await this.client.request("post",this.endpoint,{currency:"aoa"},{})}async createEurAccount(){return await this.client.request("post",this.endpoint,{currency:"eur"},{})}}class s{constructor(t){this.observers=[],this.authState={authenticated:!1},this.client=t}_notifyObservers(){for(const t of this.observers)t(this.authState)}listObservers(){for(const t of this.observers)console.log(t)}onAuthStateChange(t){this.observers.push(t)}isAuthenticated(){return Boolean(this.client.token)}async signOut(){const t=this.client.lombongoIdBaseUrl,s=this.client.getToken();s&&await this.client.request("post","/users/logout",{token:s},{},t),delete this.client.token,this.authState.authenticated=!1,this.authState.user=void 0,this.authState.token=void 0,this._notifyObservers()}async createUser(t){const s=this.client.lombongoIdBaseUrl,i=(await this.client.request("post","/users",t,{},s)).data;return t.password&&delete t.password,this.authState={authenticated:!0,user:i.user,token:i.token},this._notifyObservers(),i}async login(t){const s=this._loginFactory(t),i=(await s(t)).data;return this.authState={authenticated:!0,user:{id:i.user.id,email:i.user.email,username:i.user.username},token:i.token},this._notifyObservers(),i}async verifyToken(t){const s=this.client.lombongoIdBaseUrl;return await this.client.request("post","/token",{token:t},{},s)}async checkUsernameAvailability(t){const s=this.client.lombongoIdBaseUrl,i=`/users/${t}/check-availability`;return await this.client.request("get",i,{},{},s)}async _loginWithEmailAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{email:t,password:s},{},i)}async _loginWithUsernameAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{username:t,password:s},{},i)}_loginFactory(t){if(!("email"in t)&&!("username"in t))throw new Error("Login credentials must include either an email or a username.");return async t=>{if(t.email)return this._loginWithEmailAndPassword(t.email,t.password);if(t.username)return this._loginWithUsernameAndPassword(t.username,t.password);throw new Error("Invalid login credentials provided.")}}}class i{constructor(t){this.client=t,this.endpoint="/beneficiaries"}async getBeneficiaries(){return await this.client.request("get",this.endpoint)}async getBeneficiary(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}async getBeneficiariesByType(t){const s=`${this.endpoint}?type=${t}`;return await this.client.request("get",s)}async getMyOwnBeneficiaries(t){let s;return s=t?`${this.endpoint}/my-own?type=${t}`:`${this.endpoint}/my-own`,await this.client.request("get",s)}async createBeneficiary(t,s,i,e=!1){return await this.client.request("post",this.endpoint,{name:t,iban:s,type:i,isMe:e})}}class e{constructor(t){this.client=t,this.endpoint="/commissions"}async get(){const t=`${this.endpoint}`;return await this.client.request("get",t)}async getHighCommission(){const t=`${this.endpoint}/high`;return await this.client.request("get",t)}}class n{constructor(t){this.client=t,this.endpoint="/current-commission"}async getCurrentCommission(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class r{constructor(t){this.client=t,this.endpoint="/cross-currency-transfer-types"}async getCrossCurrencyType(t,s){const i=`${this.endpoint}?origin_currency=${t}&final_currency=${s}`;return await this.client.request("get",i)}}class a{constructor(t){this.client=t,this.endpoint="/cross-currency-transfer-limits"}async getCrossCurrencyTransferLimits(){return await this.client.request("get",this.endpoint)}async getCrossCurrencyTransferLimitsById(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class o{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class c{constructor(t){this.client=t,this.endpoint="/fx-rates"}async getFxRates(){return await this.client.request("get",this.endpoint)}async getFxRate(t,s){return await this.client.request("post",this.endpoint,{originalCurrencyId:t,finalCurrencyId:s})}}class h{constructor(t){this.client=t,this.endpoint="/invitation-codes"}async generateNew(){return await this.client.request("post",this.endpoint)}async sendCodeTo(t,s){return await this.client.request("post",`${this.endpoint}/send`,{code:t,username:s})}async getMyInvitationCodes(){return await this.client.request("get",this.endpoint)}async redeemInvitationCode(t){return await this.client.request("get",`${this.endpoint}/${t}/redeem`)}}class u{constructor(t){this.client=t,this.endpoint="/liquidity-pools"}async getLiquidityPools(){return await this.client.request("get",this.endpoint)}async getLiquidityRatio(t){const s=`${this.endpoint}/${t}/liquidity-ratio`;return await this.client.request("get",s)}}class y{constructor(t,s){if(t<0)throw new Error("Amount cannot be negative");if(!Number.isInteger(t))throw new Error("Amount must be in smallest currency unit (cents)");this.amount=t,this.currencyCode=s.toUpperCase()}static fromDecimal(t,s){if(t<0)throw new Error("Amount cannot be negative");return new y(Math.round(100*t),s)}static fromCents(t,s){return new y(t,s)}static fromClientInput(t,s){return new y(t,s)}add(t){return this.ensureSameCurrency(t),new y(this.amount+t.amount,this.currencyCode)}subtract(t){if(this.ensureSameCurrency(t),this.amount<t.amount)throw new Error("Insufficient funds: cannot subtract larger amount");return new y(this.amount-t.amount,this.currencyCode)}multiply(t){if(t<0)throw new Error("Multiplication factor cannot be negative");return new y(Math.round(this.amount*t),this.currencyCode)}applyPercentage(t){if(t<0)throw new Error("Percentage cannot be negative");return this.multiply(t/100)}toDecimal(){return this.amount/100}toCents(){return this.amount}getCurrencyCode(){return this.currencyCode}isZero(){return 0===this.amount}equals(t){return this.amount===t.amount&&this.currencyCode===t.currencyCode}isGreaterThan(t){return this.ensureSameCurrency(t),this.amount>t.amount}toString(){return`${this.toDecimal().toFixed(2)} ${this.currencyCode}`}ensureSameCurrency(t){if(this.currencyCode!==t.currencyCode)throw new Error(`Cannot operate on different currencies: ${this.currencyCode} vs ${t.currencyCode}`)}}class w{constructor(t){this.client=t,this.endpoint="/transactions"}async get(){return await this.client.request("get",this.endpoint)}async getTransaction(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}async doCrossCurrency(t){const s=`${this.endpoint}/cross-currency`;return await this.client.request("post",s,t)}async doP2P(t){const s=`${this.endpoint}/p2p`;return await this.client.request("post",s,t)}async getFXConfig(t,s,i){const e=`${this.endpoint}/sepa/config`;return await this.client.request("post",e,{originalCurrencyId:t,finalCurrencyId:s,amount:i})}}var l=(t=>(t.NOT_VERIFIED="NOT_VERIFIED",t.VERIFICATION_PENDING="VERIFICATION_PENDING",t.VERIFICATION_FAILED="VERIFICATION_FAILED",t.VERIFIED="VERIFIED",t))(l||{});class g{constructor(t){this.client=t,this.endpoint="/users"}async getInvitedStatus(){const t=await this.client.request("get",`${this.endpoint}/me/check-if-invited`);if(null===t.data||void 0===t.data)throw new Error(`Invalid response for invited status: ${t.status} ${t.statusText}`);if("boolean"==typeof t.data)return t.data;if("string"==typeof t.data){const s=t.data.trim().toLowerCase();if("true"===s)return!0;if("false"===s)return!1}throw new Error(`Invalid invited status received: "${t.data}". Expected boolean or "true"/"false" string.`)}async verifyKyc(){const t=`${this.endpoint}/me/check-kyc-status`,s=await this.client.request("get",t);if(null===s.data||void 0===s.data)throw new Error(`Invalid response for KYC status: ${s.status} ${s.statusText}`);const i="string"==typeof s.data?s.data.trim():String(s.data).trim(),e=Object.values(l);if(e.includes(i))return i;throw new Error(`Invalid KYC status received: "${i}". Expected one of: ${e.join(", ")}`)}}class f{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class d{constructor(t){this.client=t,this.endpoint="/offers"}async createOffer(t){return await this.client.request("post",this.endpoint,{...t})}async getOffers(){return await this.client.request("get",this.endpoint)}async getMyOffers(){const t=`${this.endpoint}/me`;return await this.client.request("get",t)}async getOffer(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class m{constructor(t){this.client=t,this.endpoint="/payment-methods"}async getPaymentMethods(){return await this.client.request("get",this.endpoint)}async getPaymentMethodsByCurrency(t){const s=`${this.endpoint}/currency/${t}`;return await this.client.request("get",s)}}class p{constructor(t){this.client=t,this.endpoint="/payments"}async getPaymentByTransactionId(t){const s=`${this.endpoint}?transaction_id=${t}`;return await this.client.request("get",s)}}class ${constructor(t){this.client=t,this.endpoint="/api/plaid/"}async createPaymentInitiationLinkToken(t){const s=this.endpoint+"create_link_token";return await this.client.request("post",s,{payment_id:t})}async createPaymentInitiation(t){const s=this.endpoint+"payment_initiation/payment/create";return await this.client.request("post",s,{amount:t})}}class C{constructor({baseUrl:l,token:C,lombongoIdBaseUrl:v}){this.unauthorizedListeners=[],this.baseUrl=l,this.token=C,this.lombongoIdBaseUrl=v,this.auth=new s(this),this.accounts=new t(this),this.beneficiaries=new i(this),this.commissions=new e(this),this.currencies=new o(this),this.currentCommision=new n(this),this.crossCurrencyTransferType=new r(this),this.crossCurrencyTransferLimits=new a(this),this.fxRates=new c(this),this.invitationCodes=new h(this),this.liquidityPools=new u(this),this.money=y,this.paymentMethods=new m(this),this.payments=new p(this),this.transactions=new w(this),this.users=new g(this),this.offers=new d(this),this.plaid=new $(this),this.veriff=new f(this),this.setupInterceptors()}static init(t){return C.instance?(t?.token&&(C.instance.token=t.token),t?.baseUrl&&(C.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(C.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),C.instance):(C.instance=new C(t),C.instance)}setupInterceptors(){}async request(t,s,i={},e={},n){const r=`${n||this.baseUrl}${s}`,a={...e,method:t.toUpperCase(),headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,...e.headers}};"GET"!==t.toUpperCase()&&i&&Object.keys(i).length>0&&(a.body=JSON.stringify(i));const o=await fetch(r,a);if(401===o.status&&this.emit401Event(),!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return await async function(t){let s;try{const i=await t.text();if(""===i)s=null;else if(""===i.trim())s=null;else try{s=JSON.parse(i)}catch(t){s=i}}catch(t){s=null}return{data:s,status:t.status,statusText:t.statusText,headers:t.headers}}(o)}setToken(t){this.token=t}getToken(){return this.token}onUnauthorized(t){this.unauthorizedListeners.push(t)}offUnauthorized(t){const s=this.unauthorizedListeners.indexOf(t);s>-1&&this.unauthorizedListeners.splice(s,1)}emit401Event(){for(const t of this.unauthorizedListeners)t()}}export{l as KycVerified,y as Money,C as default};
package/dist/types.d.ts CHANGED
@@ -1,12 +1,17 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
1
+ interface ApiResponse<T = any> {
2
+ data: T;
3
+ status: number;
4
+ statusText: string;
5
+ headers: Headers;
6
+ }
2
7
 
3
8
  declare class Account {
4
9
  private client;
5
10
  private endpoint;
6
11
  constructor(client: ApiClient);
7
- getAccounts(): Promise<AxiosResponse>;
8
- createAoaAccount(): Promise<AxiosResponse>;
9
- createEurAccount(): Promise<AxiosResponse>;
12
+ getAccounts(): Promise<ApiResponse>;
13
+ createAoaAccount(): Promise<ApiResponse>;
14
+ createEurAccount(): Promise<ApiResponse>;
10
15
  }
11
16
 
12
17
  type CreateUser = {
@@ -42,85 +47,85 @@ declare class Auth {
42
47
  signOut(): Promise<void>;
43
48
  createUser(user: Omit<CreateUser, "id">): Promise<CreatedUser>;
44
49
  login(credentials: LoginParameter): Promise<CreatedUser>;
45
- verifyToken(token: string): Promise<AxiosResponse>;
46
- checkUsernameAvailability(username: string): Promise<AxiosResponse>;
47
- _loginWithEmailAndPassword(email: string, password: string): Promise<AxiosResponse>;
48
- _loginWithUsernameAndPassword(username: string, password: string): Promise<AxiosResponse>;
49
- _loginFactory(credentials: LoginParameter): (credentials: LoginParameter) => Promise<AxiosResponse>;
50
+ verifyToken(token: string): Promise<ApiResponse>;
51
+ checkUsernameAvailability(username: string): Promise<ApiResponse>;
52
+ _loginWithEmailAndPassword(email: string, password: string): Promise<ApiResponse>;
53
+ _loginWithUsernameAndPassword(username: string, password: string): Promise<ApiResponse>;
54
+ _loginFactory(credentials: LoginParameter): (credentials: LoginParameter) => Promise<ApiResponse>;
50
55
  }
51
56
 
52
57
  declare class Beneficiaries {
53
58
  private readonly client;
54
59
  private endpoint;
55
60
  constructor(client: ApiClient);
56
- getBeneficiaries(): Promise<AxiosResponse>;
57
- getBeneficiary(id: number): Promise<AxiosResponse>;
58
- getBeneficiariesByType(type: "AO" | "EU"): Promise<AxiosResponse>;
59
- getMyOwnBeneficiaries(type?: "AO" | "EU"): Promise<AxiosResponse>;
60
- createBeneficiary(name: string, iban: string, type: "AO" | "EU", isMe?: boolean): Promise<AxiosResponse>;
61
+ getBeneficiaries(): Promise<ApiResponse>;
62
+ getBeneficiary(id: number): Promise<ApiResponse>;
63
+ getBeneficiariesByType(type: "AO" | "EU"): Promise<ApiResponse>;
64
+ getMyOwnBeneficiaries(type?: "AO" | "EU"): Promise<ApiResponse>;
65
+ createBeneficiary(name: string, iban: string, type: "AO" | "EU", isMe?: boolean): Promise<ApiResponse>;
61
66
  }
62
67
 
63
68
  declare class Commission {
64
69
  private client;
65
70
  private endpoint;
66
71
  constructor(client: ApiClient);
67
- get(): Promise<AxiosResponse>;
68
- getHighCommission(): Promise<AxiosResponse>;
72
+ get(): Promise<ApiResponse>;
73
+ getHighCommission(): Promise<ApiResponse>;
69
74
  }
70
75
 
71
76
  declare class CurrentCommision {
72
77
  private client;
73
78
  private endpoint;
74
79
  constructor(client: ApiClient);
75
- getCurrentCommission(crossCurrencyTypeId: number): Promise<AxiosResponse>;
80
+ getCurrentCommission(crossCurrencyTypeId: number): Promise<ApiResponse>;
76
81
  }
77
82
 
78
83
  declare class CrossCurrencyTypes {
79
84
  private readonly client;
80
85
  private endpoint;
81
86
  constructor(client: ApiClient);
82
- getCrossCurrencyType(origin_currency?: number, final_currency?: number): Promise<AxiosResponse>;
87
+ getCrossCurrencyType(origin_currency?: number, final_currency?: number): Promise<ApiResponse>;
83
88
  }
84
89
 
85
90
  declare class CrossCurrencyTransferLimits {
86
91
  private readonly client;
87
92
  private endpoint;
88
93
  constructor(client: ApiClient);
89
- getCrossCurrencyTransferLimits(): Promise<AxiosResponse>;
90
- getCrossCurrencyTransferLimitsById(crossCurrencyTypeId: number): Promise<AxiosResponse>;
94
+ getCrossCurrencyTransferLimits(): Promise<ApiResponse>;
95
+ getCrossCurrencyTransferLimitsById(crossCurrencyTypeId: number): Promise<ApiResponse>;
91
96
  }
92
97
 
93
98
  declare class Currencies {
94
99
  private readonly client;
95
100
  private endpoint;
96
101
  constructor(client: ApiClient);
97
- getCurrencies(): Promise<AxiosResponse>;
102
+ getCurrencies(): Promise<ApiResponse>;
98
103
  }
99
104
 
100
105
  declare class FxRate {
101
106
  private readonly client;
102
107
  private endpoint;
103
108
  constructor(client: ApiClient);
104
- getFxRates(): Promise<AxiosResponse>;
105
- getFxRate(originalCurrencyId: number, finalCurrencyId: number): Promise<AxiosResponse>;
109
+ getFxRates(): Promise<ApiResponse>;
110
+ getFxRate(originalCurrencyId: number, finalCurrencyId: number): Promise<ApiResponse>;
106
111
  }
107
112
 
108
113
  declare class InvitationCodes {
109
114
  private readonly client;
110
115
  private endpoint;
111
116
  constructor(client: ApiClient);
112
- generateNew(): Promise<AxiosResponse>;
113
- sendCodeTo(code: string, username: string): Promise<AxiosResponse>;
114
- getMyInvitationCodes(): Promise<AxiosResponse>;
115
- redeemInvitationCode(code: string): Promise<AxiosResponse>;
117
+ generateNew(): Promise<ApiResponse>;
118
+ sendCodeTo(code: string, username: string): Promise<ApiResponse>;
119
+ getMyInvitationCodes(): Promise<ApiResponse>;
120
+ redeemInvitationCode(code: string): Promise<ApiResponse>;
116
121
  }
117
122
 
118
123
  declare class LiquidityPools {
119
124
  private readonly client;
120
125
  private endpoint;
121
126
  constructor(client: ApiClient);
122
- getLiquidityPools(): Promise<AxiosResponse>;
123
- getLiquidityRatio(id: number): Promise<AxiosResponse>;
127
+ getLiquidityPools(): Promise<ApiResponse>;
128
+ getLiquidityRatio(id: number): Promise<ApiResponse>;
124
129
  }
125
130
 
126
131
  declare class Money {
@@ -171,11 +176,11 @@ declare class Transactions {
171
176
  private readonly client;
172
177
  private endpoint;
173
178
  constructor(client: ApiClient);
174
- get(): Promise<AxiosResponse>;
175
- getTransaction(id: number): Promise<AxiosResponse>;
176
- doCrossCurrency(doCrossCurrency: ICrosscurrencyPostParams): Promise<AxiosResponse>;
177
- doP2P(doCrossCurrency: Omit<IP2PTransaction, "fx_rate_id">): Promise<AxiosResponse>;
178
- getFXConfig(originalCurrencyId: number, finalCurrencyId: number, amount: number): Promise<AxiosResponse>;
179
+ get(): Promise<ApiResponse>;
180
+ getTransaction(id: number): Promise<ApiResponse>;
181
+ doCrossCurrency(doCrossCurrency: ICrosscurrencyPostParams): Promise<ApiResponse>;
182
+ doP2P(doCrossCurrency: Omit<IP2PTransaction, "fx_rate_id">): Promise<ApiResponse>;
183
+ getFXConfig(originalCurrencyId: number, finalCurrencyId: number, amount: number): Promise<ApiResponse>;
179
184
  }
180
185
 
181
186
  declare enum KycVerified {
@@ -196,7 +201,7 @@ declare class Veriff {
196
201
  private readonly client;
197
202
  private endpoint;
198
203
  constructor(client: ApiClient);
199
- createSession(userId: string): Promise<AxiosResponse>;
204
+ createSession(userId: string): Promise<ApiResponse>;
200
205
  }
201
206
 
202
207
  type CreateOffer = {
@@ -211,33 +216,33 @@ declare class Offers {
211
216
  private readonly client;
212
217
  private readonly endpoint;
213
218
  constructor(client: ApiClient);
214
- createOffer(data: CreateOffer): Promise<AxiosResponse>;
215
- getOffers(): Promise<AxiosResponse>;
216
- getMyOffers(): Promise<AxiosResponse>;
217
- getOffer(id: number): Promise<AxiosResponse>;
219
+ createOffer(data: CreateOffer): Promise<ApiResponse>;
220
+ getOffers(): Promise<ApiResponse>;
221
+ getMyOffers(): Promise<ApiResponse>;
222
+ getOffer(id: number): Promise<ApiResponse>;
218
223
  }
219
224
 
220
225
  declare class PaymentMethod {
221
226
  private client;
222
227
  private endpoint;
223
228
  constructor(client: ApiClient);
224
- getPaymentMethods(): Promise<AxiosResponse>;
225
- getPaymentMethodsByCurrency(currencyId: number): Promise<AxiosResponse>;
229
+ getPaymentMethods(): Promise<ApiResponse>;
230
+ getPaymentMethodsByCurrency(currencyId: number): Promise<ApiResponse>;
226
231
  }
227
232
 
228
233
  declare class Payments {
229
234
  private client;
230
235
  private endpoint;
231
236
  constructor(client: ApiClient);
232
- getPaymentByTransactionId(id: number): Promise<AxiosResponse>;
237
+ getPaymentByTransactionId(id: number): Promise<ApiResponse>;
233
238
  }
234
239
 
235
240
  declare class Plaid {
236
241
  private readonly client;
237
242
  private endpoint;
238
243
  constructor(client: ApiClient);
239
- createPaymentInitiationLinkToken(paymentId: string): Promise<AxiosResponse>;
240
- createPaymentInitiation(amount: number): Promise<AxiosResponse>;
244
+ createPaymentInitiationLinkToken(paymentId: string): Promise<ApiResponse>;
245
+ createPaymentInitiation(amount: number): Promise<ApiResponse>;
241
246
  }
242
247
 
243
248
  interface ApiClientOptions {
@@ -245,10 +250,10 @@ interface ApiClientOptions {
245
250
  lombongoIdBaseUrl: string;
246
251
  token?: string;
247
252
  }
248
- interface CustomRequestInit extends Omit<AxiosRequestConfig, "headers"> {
253
+ interface CustomRequestInit extends Omit<RequestInit, "headers" | "method" | "body"> {
249
254
  headers?: Record<string, string>;
250
255
  }
251
- type Method = "get" | "post";
256
+ type Method = "get" | "post" | "put" | "patch" | "delete";
252
257
  declare class ApiClient {
253
258
  private static instance;
254
259
  private token?;
@@ -277,7 +282,7 @@ declare class ApiClient {
277
282
  private constructor();
278
283
  static init(options: ApiClientOptions): ApiClient;
279
284
  private setupInterceptors;
280
- request(method: Method, endpoint: string, body?: object, options?: CustomRequestInit, overrideBaseUrl?: string): Promise<AxiosResponse>;
285
+ request(method: Method, endpoint: string, body?: object, options?: CustomRequestInit, overrideBaseUrl?: string): Promise<ApiResponse>;
281
286
  setToken(token: string): void;
282
287
  getToken(): string | undefined;
283
288
  onUnauthorized(listener: () => void): void;
@@ -285,4 +290,4 @@ declare class ApiClient {
285
290
  private emit401Event;
286
291
  }
287
292
 
288
- export { Money, ApiClient as default };
293
+ export { KycVerified, Money, ApiClient as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lombongo-api-client",
3
- "version": "0.0.113",
3
+ "version": "0.0.115",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/esm/base.js",
@@ -29,7 +29,6 @@
29
29
  "license": "ISC",
30
30
  "dependencies": {
31
31
  "@types/jest": "^29.5.12",
32
- "axios": "^1.7.2",
33
32
  "jest": "^29.7.0",
34
33
  "ts-jest": "^29.1.2",
35
34
  "ts-node": "^10.9.2"