lombongo-api-client 0.0.85 → 0.0.87
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 +1 -1
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
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 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="/current-commission"}async getCurrentCommission(){return await this.client.request("get",this.endpoint)}}class
|
|
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 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="/current-commission"}async getCurrentCommission(){return await this.client.request("get",this.endpoint)}}class a{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class r{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="/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 c{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 o{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class u{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 y{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 w{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 l{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 g{constructor({baseUrl:t,token:g,lombongoIdBaseUrl:d}){this.baseUrl=t,this.token=g,this.lombongoIdBaseUrl=d,this.auth=new i(this),this.accounts=new s(this),this.currencies=new a(this),this.currentCommision=new n(this),this.fxRates=new r(this),this.liquidityPools=new h(this),this.paymentMethods=new y(this),this.payments=new w(this),this.transactions=new c(this),this.offers=new u(this),this.plaid=new l(this),this.beneficiaries=new e(this),this.veriff=new o(this)}static init(t){return g.instance?(t?.token&&(g.instance.token=t.token),t?.baseUrl&&(g.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(g.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),g.instance):(g.instance=new g(t),g.instance)}async request(s,i,e={},n={},a){const r=`${a||this.baseUrl}${i}`,h={...n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,...n.headers},method:s,url:r};return"GET"!==s.toUpperCase()&&Object.keys(e).length>0&&(h.data=e),await t(h)}setToken(t){this.token=t}getToken(){return this.token}}export{g as default};
|
package/dist/types.d.ts
CHANGED
|
@@ -117,6 +117,7 @@ declare class Transactions {
|
|
|
117
117
|
private endpoint;
|
|
118
118
|
constructor(client: ApiClient);
|
|
119
119
|
get(): Promise<AxiosResponse>;
|
|
120
|
+
getTransaction(id: number): Promise<AxiosResponse>;
|
|
120
121
|
doCrossCurrency(doCrossCurrency: ICrosscurrencyPostParams): Promise<AxiosResponse>;
|
|
121
122
|
doP2P(doCrossCurrency: Omit<IP2PTransaction, "fx_rate_id">): Promise<AxiosResponse>;
|
|
122
123
|
getFXConfig(originalCurrencyId: number, finalCurrencyId: number, amount: number): Promise<AxiosResponse>;
|
|
@@ -155,6 +156,13 @@ declare class PaymentMethod {
|
|
|
155
156
|
getPaymentMethodsByCurrency(currencyId: number): Promise<AxiosResponse>;
|
|
156
157
|
}
|
|
157
158
|
|
|
159
|
+
declare class Payments {
|
|
160
|
+
private client;
|
|
161
|
+
private endpoint;
|
|
162
|
+
constructor(client: ApiClient);
|
|
163
|
+
getPaymentByTransactionId(id: number): Promise<AxiosResponse>;
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
declare class Plaid {
|
|
159
167
|
private readonly client;
|
|
160
168
|
private endpoint;
|
|
@@ -186,6 +194,7 @@ declare class ApiClient {
|
|
|
186
194
|
liquidityPools: LiquidityPools;
|
|
187
195
|
offers: Offers;
|
|
188
196
|
paymentMethods: PaymentMethod;
|
|
197
|
+
payments: Payments;
|
|
189
198
|
transactions: Transactions;
|
|
190
199
|
plaid: Plaid;
|
|
191
200
|
veriff: Veriff;
|