lombongo-api-client 0.0.63 → 0.0.64

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 delete t.password,this.authState={authenticated:!0,user:t,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:{email:i.email,username:i.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){return await this.client.request("post",this.endpoint,{name:t,iban:s,type:i})}}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="/offers"}async getOffers(){return await this.client.request("get",this.endpoint)}async getOffer(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class c{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 u{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 y{constructor({baseUrl:t,token:y,lombongoIdBaseUrl:w}){this.baseUrl=t,this.token=y,this.lombongoIdBaseUrl=w,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 c(this),this.transactions=new o(this),this.offers=new h(this),this.plaid=new u(this),this.beneficiaries=new e(this)}static init(t){return y.instance?(t?.token&&(y.instance.token=t.token),t?.baseUrl&&(y.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(y.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),y.instance):(y.instance=new y(t),y.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{y 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:t,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:{email:i.email,username:i.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){return await this.client.request("post",this.endpoint,{name:t,iban:s,type:i})}}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="/offers"}async createOffer(t){return await this.client.request("get",this.endpoint)}async getOffers(){return await this.client.request("post",this.endpoint)}async getOffer(t){const s=`${this.endpoint}/${t}`;return await this.client.request("get",s)}}class c{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 u{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 y{constructor({baseUrl:t,token:y,lombongoIdBaseUrl:w}){this.baseUrl=t,this.token=y,this.lombongoIdBaseUrl=w,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 c(this),this.transactions=new o(this),this.offers=new h(this),this.plaid=new u(this),this.beneficiaries=new e(this)}static init(t){return y.instance?(t?.token&&(y.instance.token=t.token),t?.baseUrl&&(y.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(y.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),y.instance):(y.instance=new y(t),y.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{y as default};
package/dist/types.d.ts CHANGED
@@ -106,14 +106,22 @@ declare class Transactions {
106
106
  constructor(client: ApiClient);
107
107
  get(): Promise<AxiosResponse>;
108
108
  doCrossCurrency(doCrossCurrency: ICrosscurrencyPostParams): Promise<AxiosResponse>;
109
- doP2P(doCrossCurrency: IP2PTransaction): Promise<AxiosResponse>;
109
+ doP2P(doCrossCurrency: Omit<IP2PTransaction, "fx_rate_id">): Promise<AxiosResponse>;
110
110
  getFXConfig(originalCurrencyId: number, finalCurrencyId: number, amount: number): Promise<AxiosResponse>;
111
111
  }
112
112
 
113
+ type CreateOffer = {
114
+ offerValue: number;
115
+ offerPrice: number;
116
+ offerValueCurrency: number;
117
+ offerPriceCurrency: number;
118
+ rate: number;
119
+ };
113
120
  declare class Offers {
114
121
  private readonly client;
115
122
  private readonly endpoint;
116
123
  constructor(client: ApiClient);
124
+ createOffer(data: CreateOffer): Promise<AxiosResponse>;
117
125
  getOffers(): Promise<AxiosResponse>;
118
126
  getOffer(id: number): Promise<AxiosResponse>;
119
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lombongo-api-client",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/esm/base.js",