squarefi-bff-api-module 1.17.11 → 1.17.13

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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.17.13] - 2025-04-24
9
+
10
+ ### Changed
11
+
12
+ - Streamlined exchange module by dynamically generating order type methods
13
+
14
+ ## [1.17.12] - 2025-04-23
15
+
16
+ ### Fixed
17
+
18
+ - Enforced required fields in DestinationListItemExternalBankingData type address object
19
+
8
20
  ## [1.17.11] - 2025-04-23
9
21
 
10
22
  ### Changed
@@ -1,35 +1,14 @@
1
1
  import { API } from './types';
2
- export declare const exchange: {
2
+ import { OrderType } from '../constants';
3
+ type IExchangeByOrderType = {
4
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
5
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
6
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
7
+ };
8
+ type IExchangeModule = {
3
9
  byOrderType: {
4
- DEPOSIT_FIAT_SEPA: {
5
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
6
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
7
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
8
- };
9
- DEPOSIT_FIAT_SWIFT: {
10
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
11
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
12
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
13
- };
14
- WITHDRAWAL_FIAT_SEPA: {
15
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
16
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
17
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
18
- };
19
- TRANSFER_CARD_SUBACCOUNT: {
20
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
21
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
22
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
23
- };
24
- WITHDRAWAL_CRYPTO: {
25
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
26
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
27
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
28
- };
29
- EXCHANGE_CRYPTO_INTERNAL: {
30
- getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
31
- getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
32
- getByOrderType: () => Promise<API.Exchange.Exchange[]>;
33
- };
10
+ [key in OrderType]: IExchangeByOrderType;
34
11
  };
35
12
  };
13
+ export declare const exchange: IExchangeModule;
14
+ export {};
@@ -8,14 +8,10 @@ const createOrderTypeMethods = (orderType) => ({
8
8
  getByToCurrency: (to_uuid) => apiClientFactory_1.apiClientV1.getRequest('/exchange/', { params: { to_uuid, order_type: orderType } }),
9
9
  getByOrderType: () => apiClientFactory_1.apiClientV1.getRequest('/exchange/', { params: { order_type: orderType } }),
10
10
  });
11
+ const orderTypes = Object.values(constants_1.OrderType);
11
12
  exports.exchange = {
12
- byOrderType: {
13
- [constants_1.OrderType.DEPOSIT_FIAT_SEPA]: createOrderTypeMethods(constants_1.OrderType.DEPOSIT_FIAT_SEPA),
14
- [constants_1.OrderType.DEPOSIT_FIAT_SWIFT]: createOrderTypeMethods(constants_1.OrderType.DEPOSIT_FIAT_SWIFT),
15
- [constants_1.OrderType.WITHDRAWAL_FIAT_SEPA]: createOrderTypeMethods(constants_1.OrderType.WITHDRAWAL_FIAT_SEPA),
16
- // [OrderType.TRANSFER_CARD_PREPAID]: createOrderTypeMethods(OrderType.TRANSFER_CARD_PREPAID), // DO not used
17
- [constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT]: createOrderTypeMethods(constants_1.OrderType.TRANSFER_CARD_SUBACCOUNT),
18
- [constants_1.OrderType.WITHDRAWAL_CRYPTO]: createOrderTypeMethods(constants_1.OrderType.WITHDRAWAL_CRYPTO),
19
- [constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL]: createOrderTypeMethods(constants_1.OrderType.EXCHANGE_CRYPTO_INTERNAL),
20
- },
13
+ byOrderType: orderTypes.reduce((acc, orderType) => {
14
+ acc[orderType] = createOrderTypeMethods(orderType);
15
+ return acc;
16
+ }, {}),
21
17
  };
@@ -384,11 +384,11 @@ export declare namespace API {
384
384
  bank_name: string;
385
385
  note: string;
386
386
  swift_bic: string;
387
- address?: {
388
- city?: string;
389
- country_id?: number;
390
- postcode?: string;
391
- street1?: string;
387
+ address: {
388
+ city: string;
389
+ country_id: number;
390
+ postcode: string;
391
+ street1: string;
392
392
  street2?: string;
393
393
  };
394
394
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.17.11",
3
+ "version": "1.17.13",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,6 +4,18 @@ import { apiClientV1 } from '../utils/apiClientFactory';
4
4
 
5
5
  import { OrderType } from '../constants';
6
6
 
7
+ type IExchangeByOrderType = {
8
+ getByFromCurrency: (from_uuid: string) => Promise<API.Exchange.Exchange[]>;
9
+ getByToCurrency: (to_uuid: string) => Promise<API.Exchange.Exchange[]>;
10
+ getByOrderType: () => Promise<API.Exchange.Exchange[]>;
11
+ };
12
+
13
+ type IExchangeModule = {
14
+ byOrderType: {
15
+ [key in OrderType]: IExchangeByOrderType;
16
+ };
17
+ };
18
+
7
19
  const createOrderTypeMethods = (orderType: OrderType) => ({
8
20
  getByFromCurrency: (from_uuid: string) =>
9
21
  apiClientV1.getRequest<API.Exchange.Exchange[]>('/exchange/', { params: { from_uuid, order_type: orderType } }),
@@ -13,14 +25,11 @@ const createOrderTypeMethods = (orderType: OrderType) => ({
13
25
  apiClientV1.getRequest<API.Exchange.Exchange[]>('/exchange/', { params: { order_type: orderType } }),
14
26
  });
15
27
 
16
- export const exchange = {
17
- byOrderType: {
18
- [OrderType.DEPOSIT_FIAT_SEPA]: createOrderTypeMethods(OrderType.DEPOSIT_FIAT_SEPA),
19
- [OrderType.DEPOSIT_FIAT_SWIFT]: createOrderTypeMethods(OrderType.DEPOSIT_FIAT_SWIFT),
20
- [OrderType.WITHDRAWAL_FIAT_SEPA]: createOrderTypeMethods(OrderType.WITHDRAWAL_FIAT_SEPA),
21
- // [OrderType.TRANSFER_CARD_PREPAID]: createOrderTypeMethods(OrderType.TRANSFER_CARD_PREPAID), // DO not used
22
- [OrderType.TRANSFER_CARD_SUBACCOUNT]: createOrderTypeMethods(OrderType.TRANSFER_CARD_SUBACCOUNT),
23
- [OrderType.WITHDRAWAL_CRYPTO]: createOrderTypeMethods(OrderType.WITHDRAWAL_CRYPTO),
24
- [OrderType.EXCHANGE_CRYPTO_INTERNAL]: createOrderTypeMethods(OrderType.EXCHANGE_CRYPTO_INTERNAL),
25
- },
28
+ const orderTypes = Object.values(OrderType);
29
+
30
+ export const exchange: IExchangeModule = {
31
+ byOrderType: orderTypes.reduce((acc, orderType) => {
32
+ acc[orderType] = createOrderTypeMethods(orderType);
33
+ return acc;
34
+ }, {} as Record<OrderType, IExchangeByOrderType>),
26
35
  };
package/src/api/types.ts CHANGED
@@ -445,11 +445,11 @@ export namespace API {
445
445
  bank_name: string;
446
446
  note: string;
447
447
  swift_bic: string;
448
- address?: {
449
- city?: string;
450
- country_id?: number;
451
- postcode?: string;
452
- street1?: string;
448
+ address: {
449
+ city: string;
450
+ country_id: number;
451
+ postcode: string;
452
+ street1: string;
453
453
  street2?: string;
454
454
  };
455
455
  }