lombongo-api-client 0.0.76 → 0.0.78
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 +1 -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 _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 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 r{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class a{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 o{constructor(t){this.client=t,this.endpoint="/transactions"}async get(){return await this.client.request("get",this.endpoint)}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 h{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class c{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 u{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 y{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 w{constructor({baseUrl:t,token:w,lombongoIdBaseUrl:l}){this.baseUrl=t,this.token=w,this.lombongoIdBaseUrl=l,this.auth=new i(this),this.accounts=new s(this),this.currencies=new r(this),this.currentCommision=new n(this),this.fxRates=new a(this),this.paymentMethods=new u(this),this.transactions=new o(this),this.offers=new c(this),this.plaid=new y(this),this.beneficiaries=new e(this),this.veriff=new h(this)}static init(t){return w.instance?(t?.token&&(w.instance.token=t.token),t?.baseUrl&&(w.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(w.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),w.instance):(w.instance=new w(t),w.instance)}async request(s,i,e={},n={},r){const a=`${r||this.baseUrl}${i}`,o={...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&&(o.data=e),await t(o)}setToken(t){this.token=t}getToken(){return this.token}}export{w 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 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 _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){const s=`${this.endpoint}/my-own?type=${t}`;return 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 r{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class a{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 o{constructor(t){this.client=t,this.endpoint="/transactions"}async get(){return await this.client.request("get",this.endpoint)}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 h{constructor(t){this.client=t,this.endpoint="/veriff/sessions"}async createSession(t){return await this.client.request("post",this.endpoint,{userId:t})}}class c{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 u{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 y{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 w{constructor({baseUrl:t,token:w,lombongoIdBaseUrl:l}){this.baseUrl=t,this.token=w,this.lombongoIdBaseUrl=l,this.auth=new i(this),this.accounts=new s(this),this.currencies=new r(this),this.currentCommision=new n(this),this.fxRates=new a(this),this.paymentMethods=new u(this),this.transactions=new o(this),this.offers=new c(this),this.plaid=new y(this),this.beneficiaries=new e(this),this.veriff=new h(this)}static init(t){return w.instance?(t?.token&&(w.instance.token=t.token),t?.baseUrl&&(w.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(w.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),w.instance):(w.instance=new w(t),w.instance)}async request(s,i,e={},n={},r){const a=`${r||this.baseUrl}${i}`,o={...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&&(o.data=e),await t(o)}setToken(t){this.token=t}getToken(){return this.token}}export{w as default};
|
package/dist/types.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ declare class Beneficiaries {
|
|
|
54
54
|
constructor(client: ApiClient);
|
|
55
55
|
getBeneficiaries(): Promise<AxiosResponse>;
|
|
56
56
|
getBeneficiariesByType(type: "AO" | "EU"): Promise<AxiosResponse>;
|
|
57
|
+
getMyOwnBeneficiaries(type?: "AO" | "EU"): Promise<AxiosResponse>;
|
|
57
58
|
createBeneficiary(name: string, iban: string, type: "AO" | "EU", isMe?: boolean): Promise<AxiosResponse>;
|
|
58
59
|
}
|
|
59
60
|
|