lombongo-api-client 0.0.97 → 0.0.99

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 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 c{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 h{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 getMyInvitationCodes(){return await this.client.request("get",this.endpoint)}}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){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 g{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class l{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 d{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 m{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 p{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 f{constructor({baseUrl:t,token:f,lombongoIdBaseUrl:$}){this.baseUrl=t,this.token=f,this.lombongoIdBaseUrl=$,this.auth=new i(this),this.accounts=new s(this),this.beneficiaries=new e(this),this.commissions=new n(this),this.currencies=new h(this),this.currentCommision=new r(this),this.crossCurrencyTransferType=new a(this),this.crossCurrencyTransferLimits=new c(this),this.fxRates=new o(this),this.invitationCodes=new u(this),this.liquidityPools=new y(this),this.paymentMethods=new d(this),this.payments=new m(this),this.transactions=new w(this),this.offers=new l(this),this.plaid=new p(this),this.veriff=new g(this),this.setupInterceptors()}static init(t){return f.instance?(t?.token&&(f.instance.token=t.token),t?.baseUrl&&(f.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(f.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),f.instance):(f.instance=new f(t),f.instance)}setupInterceptors(){}async request(s,i,e={},n={},r){const a=`${r||this.baseUrl}${i}`,c={...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&&(c.data=e),await t(c)}setToken(t){this.token=t}getToken(){return this.token}}export{f as default};
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 c{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 h{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 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){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 g{constructor(t){this.client=t}async verifyKyc(t){const s=this.client.lombongoIdBaseUrl;return(await this.client.request("get","/users/check-kyc-status",{token:t},{},s)).data}}class l{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 f{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 ${constructor({baseUrl:t,token:$,lombongoIdBaseUrl:C}){this.baseUrl=t,this.token=$,this.lombongoIdBaseUrl=C,this.auth=new i(this),this.accounts=new s(this),this.beneficiaries=new e(this),this.commissions=new n(this),this.currencies=new h(this),this.currentCommision=new r(this),this.crossCurrencyTransferType=new a(this),this.crossCurrencyTransferLimits=new c(this),this.fxRates=new o(this),this.invitationCodes=new u(this),this.liquidityPools=new y(this),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 f(this),this.veriff=new l(this),this.setupInterceptors()}static init(t){return $.instance?(t?.token&&($.instance.token=t.token),t?.baseUrl&&($.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&($.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),$.instance):($.instance=new $(t),$.instance)}setupInterceptors(){}async request(s,i,e={},n={},r){const a=`${r||this.baseUrl}${i}`,c={...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&&(c.data=e),await t(c)}setToken(t){this.token=t}getToken(){return this.token}}export{$ as default};
package/dist/types.d.ts CHANGED
@@ -54,6 +54,7 @@ declare class Beneficiaries {
54
54
  private endpoint;
55
55
  constructor(client: ApiClient);
56
56
  getBeneficiaries(): Promise<AxiosResponse>;
57
+ getBeneficiary(id: number): Promise<AxiosResponse>;
57
58
  getBeneficiariesByType(type: "AO" | "EU"): Promise<AxiosResponse>;
58
59
  getMyOwnBeneficiaries(type?: "AO" | "EU"): Promise<AxiosResponse>;
59
60
  createBeneficiary(name: string, iban: string, type: "AO" | "EU", isMe?: boolean): Promise<AxiosResponse>;
@@ -110,6 +111,7 @@ declare class InvitationCodes {
110
111
  constructor(client: ApiClient);
111
112
  generateNew(): Promise<AxiosResponse>;
112
113
  getMyInvitationCodes(): Promise<AxiosResponse>;
114
+ redeemInvitationCode(code: string): Promise<AxiosResponse>;
113
115
  }
114
116
 
115
117
  declare class LiquidityPools {
@@ -154,6 +156,12 @@ declare class Transactions {
154
156
  getFXConfig(originalCurrencyId: number, finalCurrencyId: number, amount: number): Promise<AxiosResponse>;
155
157
  }
156
158
 
159
+ declare class Users {
160
+ private client;
161
+ constructor(client: ApiClient);
162
+ verifyKyc(token: string): Promise<boolean>;
163
+ }
164
+
157
165
  declare class Veriff {
158
166
  private readonly client;
159
167
  private endpoint;
@@ -231,6 +239,7 @@ declare class ApiClient {
231
239
  paymentMethods: PaymentMethod;
232
240
  payments: Payments;
233
241
  transactions: Transactions;
242
+ users: Users;
234
243
  plaid: Plaid;
235
244
  veriff: Veriff;
236
245
  private constructor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lombongo-api-client",
3
- "version": "0.0.97",
3
+ "version": "0.0.99",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/esm/base.js",