@fiado/api-invoker 1.1.16 → 1.1.18

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.
Files changed (94) hide show
  1. package/README.md +64 -64
  2. package/bin/container.config.js +2 -0
  3. package/bin/tern/api/TernApi.d.ts +3 -0
  4. package/bin/tern/api/TernApi.js +31 -0
  5. package/package.json +28 -28
  6. package/src/account-beneficiary/AccountBeneficiaryApi.ts +18 -18
  7. package/src/account-beneficiary/index.ts +2 -2
  8. package/src/account-beneficiary/interfaces/IAccountBeneficiaryApi.ts +7 -7
  9. package/src/account-fiadoinc/AccountFiadoIncApi.ts +65 -65
  10. package/src/account-fiadoinc/index.ts +1 -1
  11. package/src/account-fiadoinc/interfaces/IAccountFiadoIncApi.ts +32 -32
  12. package/src/account-fiadosa/AccountFiadoSAApi.ts +27 -27
  13. package/src/account-fiadosa/index.ts +1 -1
  14. package/src/account-fiadosa/interfaces/IAccountFiadoSAApi.ts +11 -11
  15. package/src/account-pagoconfiado/AccountPagoConfiadoApi.ts +32 -32
  16. package/src/account-pagoconfiado/index.ts +2 -2
  17. package/src/account-pagoconfiado/interfaces/IAccountPagoConfiadoApi.ts +10 -10
  18. package/src/activity-business/ActivityApi.ts +21 -21
  19. package/src/activity-business/index.ts +5 -5
  20. package/src/activity-business/interfaces/IActivityApi.ts +8 -8
  21. package/src/activity-business/queue/ActivityPublisher.ts +26 -26
  22. package/src/activity-business/queue/IActivityPublisher.ts +4 -4
  23. package/src/address/AddressApi.ts +46 -46
  24. package/src/address/index.ts +3 -3
  25. package/src/address/interfaces/IAddressApi.ts +30 -30
  26. package/src/authentication/AuthenticationApi.ts +16 -16
  27. package/src/authentication/index.ts +4 -4
  28. package/src/authentication/interfaces/IAuthenticationApi.ts +5 -5
  29. package/src/bankAccount/BankAccountApi.ts +37 -37
  30. package/src/bankAccount/index.ts +1 -1
  31. package/src/bankAccount/interfaces/IBankAccountApi.ts +4 -4
  32. package/src/bbvaRst/api/BBVARstApi.ts +16 -16
  33. package/src/bbvaRst/api/interfaces/IBBVARstApi.ts +4 -4
  34. package/src/bbvaRst/index.ts +1 -1
  35. package/src/card/CardApi.ts +36 -36
  36. package/src/card/index.ts +3 -3
  37. package/src/card/interfaces/ICardApi.ts +10 -10
  38. package/src/collector/CollectorApi.ts +21 -21
  39. package/src/collector/index.ts +2 -2
  40. package/src/collector/interfaces/ICollectorApi.ts +19 -19
  41. package/src/container.config.ts +77 -75
  42. package/src/contract-generator/ContractGeneratorApi.ts +18 -18
  43. package/src/contract-generator/index.ts +2 -2
  44. package/src/contract-generator/interfaces/IContractGeneratorApi.ts +16 -16
  45. package/src/directory/DirectoryApi.ts +115 -115
  46. package/src/directory/index.ts +3 -3
  47. package/src/directory/interfaces/IDirectoryApi.ts +66 -66
  48. package/src/exchangeRates/ExchangeRatesApi.ts +27 -27
  49. package/src/exchangeRates/index.ts +1 -1
  50. package/src/exchangeRates/interfaces/IExchangeRatesApi.ts +8 -8
  51. package/src/fraudPreventionEngine/api/FraudPreventionEngineApi.ts +22 -22
  52. package/src/fraudPreventionEngine/api/interfaces/IFraudPreventionEngineApi.ts +7 -7
  53. package/src/fraudPreventionEngine/index.ts +1 -1
  54. package/src/group/GroupApi.ts +24 -24
  55. package/src/group/index.ts +1 -1
  56. package/src/group/interfaces/IGroupApi.ts +23 -23
  57. package/src/identity/IdentityApi.ts +47 -47
  58. package/src/identity/index.ts +3 -3
  59. package/src/identity/interfaces/IIdentityApi.ts +33 -33
  60. package/src/index.ts +27 -27
  61. package/src/notificationMessages/index.ts +1 -1
  62. package/src/notificationMessages/queue/NotificationMessagePublisher.ts +22 -22
  63. package/src/notificationMessages/queue/interfaces/INotificationMessagesPublisher.ts +4 -4
  64. package/src/p2pContact/api/P2pContactApi.ts +19 -19
  65. package/src/p2pContact/api/interfaces/IP2pContactApi.ts +4 -4
  66. package/src/p2pContact/index.ts +1 -1
  67. package/src/pomelo/api/PomeloApi.ts +99 -99
  68. package/src/pomelo/api/interfaces/IPomeloApi.ts +27 -27
  69. package/src/pomelo/index.ts +1 -1
  70. package/src/product-catalog/ProductCatalogApi.ts +17 -17
  71. package/src/product-catalog/index.ts +1 -1
  72. package/src/product-catalog/interfaces/IProductCatalogApi.ts +6 -6
  73. package/src/sessionActivity/index.ts +2 -2
  74. package/src/sessionActivity/queue/SessionActivityPublisher.ts +22 -22
  75. package/src/sessionActivity/queue/interfaces/ISessionActivityPublisher.ts +4 -4
  76. package/src/stpAccount/api/STPAccountApi.ts +102 -102
  77. package/src/stpAccount/api/interfaces/ISTPAccountApi.ts +6 -6
  78. package/src/stpAccount/index.ts +1 -1
  79. package/src/stpServicePayment/api/StpServicePaymentApi.ts +35 -35
  80. package/src/stpServicePayment/api/interfaces/IStpServicePaymentApi.ts +11 -11
  81. package/src/stpServicePayment/index.ts +1 -1
  82. package/src/stpSpei/api/StpSpeiApi.ts +20 -20
  83. package/src/stpSpei/api/interfaces/IStpSpeiApi.ts +4 -4
  84. package/src/stpSpei/index.ts +1 -1
  85. package/src/tern/api/TernApi.ts +133 -96
  86. package/src/tern/api/interfaces/ITernApi.ts +29 -29
  87. package/src/tern/index.ts +1 -1
  88. package/src/transaction/index.ts +2 -2
  89. package/src/transaction/queue/TransactionPublisher.ts +24 -24
  90. package/src/transaction/queue/interfaces/ITransactionPublisher.ts +4 -4
  91. package/src/transactionProcessor/api/TransactionProcessorApi.ts +23 -23
  92. package/src/transactionProcessor/api/interfaces/ITransactionProcessorApi.ts +7 -7
  93. package/src/transactionProcessor/index.ts +1 -1
  94. package/tsconfig.json +21 -21
package/README.md CHANGED
@@ -1,64 +1,64 @@
1
- # fiado-api-invoker
2
-
3
- `fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
4
-
5
-
6
- ## Configuración
7
-
8
- Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
9
-
10
-
11
- ## Instalación
12
- ```bash
13
- `npm install fiado-api-invoker @fiado/http-client`
14
- ```
15
-
16
- ## Configuración del Contenedor de InversifyJS
17
-
18
- ```typescript
19
- import { Container } from "inversify";
20
- import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
21
- import { apiInvokerContainer } from '@fiado/api-invoker';
22
-
23
- // Crea el contenedor principal de tu aplicación
24
- const container = new Container();
25
-
26
- // Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
27
- container.load(gatewayAdapterBindings);
28
-
29
- // Registro del cliente HTTP
30
- container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
31
-
32
- // Exporta el contenedor para su uso en toda tu aplicación
33
- export { container };
34
-
35
-
36
- ```
37
-
38
-
39
- ## Uso de IDirectoryApi en Servicios del Proyecto
40
-
41
- Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
42
-
43
- ```typescript
44
- import { inject, injectable } from "inversify";
45
- import { IDirectoryApi } from "fiado-api-invoker";
46
- import { log } from "@fiado/logger";
47
-
48
- @injectable()
49
- export class SomeService {
50
- constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
51
-
52
- public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
53
- try {
54
- const details = await this.directoryApi.getByIds(directoryIds);
55
- log.info(details);
56
-
57
- } catch (error) {
58
- log.error("Error fetching directory details:", error);
59
- }
60
- }
61
- }
62
- ```
63
-
64
-
1
+ # fiado-api-invoker
2
+
3
+ `fiado-api-invoker` es una librería diseñada para facilitar la invocación de APIs privadas de AWS Lambda a través de API Gateway dentro de la misma VPC. Esta librería simplifica el proceso de configuración y llamada a servicios, permitiendo a los desarrolladores centrarse en la lógica de negocio.
4
+
5
+
6
+ ## Configuración
7
+
8
+ Antes de usar la librería, asegúrate de configurar la URL base del API Gateway privado que corresponda por ejemplo si vas a usar los servicios del Lambda `Directory` se puede hacer estableciendo la variable de entorno `DIRECTORY_LAMBDA_URL`.
9
+
10
+
11
+ ## Instalación
12
+ ```bash
13
+ `npm install fiado-api-invoker @fiado/http-client`
14
+ ```
15
+
16
+ ## Configuración del Contenedor de InversifyJS
17
+
18
+ ```typescript
19
+ import { Container } from "inversify";
20
+ import { IHttpRequest, AxiosHttpRequest } from "@fiado/http-client";
21
+ import { apiInvokerContainer } from '@fiado/api-invoker';
22
+
23
+ // Crea el contenedor principal de tu aplicación
24
+ const container = new Container();
25
+
26
+ // Aplica las configuraciones de vinculación de fiado-gateway-adapter al contenedor
27
+ container.load(gatewayAdapterBindings);
28
+
29
+ // Registro del cliente HTTP
30
+ container.bind<IHttpRequest>("IHttpRequest").to(AxiosHttpRequest);
31
+
32
+ // Exporta el contenedor para su uso en toda tu aplicación
33
+ export { container };
34
+
35
+
36
+ ```
37
+
38
+
39
+ ## Uso de IDirectoryApi en Servicios del Proyecto
40
+
41
+ Para utilizar `fiado-api-invoker`, necesitas configurar el contenedor de InversifyJS en tu aplicación. Aquí te mostramos cómo registrar las dependencias necesarias:
42
+
43
+ ```typescript
44
+ import { inject, injectable } from "inversify";
45
+ import { IDirectoryApi } from "fiado-api-invoker";
46
+ import { log } from "@fiado/logger";
47
+
48
+ @injectable()
49
+ export class SomeService {
50
+ constructor(@inject("IDirectoryApi") private directoryApi: IDirectoryApi) {}
51
+
52
+ public async fetchDirectoryDetails(directoryIds: string[]): Promise<void> {
53
+ try {
54
+ const details = await this.directoryApi.getByIds(directoryIds);
55
+ log.info(details);
56
+
57
+ } catch (error) {
58
+ log.error("Error fetching directory details:", error);
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+
@@ -33,6 +33,7 @@ const FraudPreventionEngineApi_1 = __importDefault(require("./fraudPreventionEng
33
33
  const group_1 = require("./group");
34
34
  const ActivityApi_1 = __importDefault(require("./activity-business/ActivityApi"));
35
35
  const TransactionProcessorApi_1 = __importDefault(require("./transactionProcessor/api/TransactionProcessorApi"));
36
+ const ActivityPublisher_1 = __importDefault(require("./activity-business/queue/ActivityPublisher"));
36
37
  exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
37
38
  bind("IDirectoryApi").to(directory_1.DirectoryApi);
38
39
  bind("IIdentityApi").to(identity_1.IdentityApi);
@@ -62,4 +63,5 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
62
63
  bind("IGroupApi").to(group_1.GroupApi);
63
64
  bind("IActivityApi").to(ActivityApi_1.default);
64
65
  bind("ITransactionProcessorApi").to(TransactionProcessorApi_1.default);
66
+ bind("IActivityPublisher").to(ActivityPublisher_1.default);
65
67
  });
@@ -19,4 +19,7 @@ export default class TernApi implements ITernApi {
19
19
  activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
20
20
  assignCardToUser(request: AssignCardRequest): Promise<any>;
21
21
  p2pTransfer(request: BankAccountP2pTransferRequest): Promise<any>;
22
+ getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
23
+ getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
24
+ getAccountTransactions(accountId: string): Promise<any>;
22
25
  }
@@ -73,6 +73,37 @@ let TernApi = class TernApi {
73
73
  const url = `${this.baseUrl}users/accounts/transfer_balances`;
74
74
  return await this.httpRequest.patch(url, request);
75
75
  }
76
+ //transactions
77
+ async getTransactions(accountId, page, pageSize, startDate, endDate, detail = false) {
78
+ try {
79
+ let url = `${this.baseUrl}users/${accountId}/v2/transactions?page=${page}&detail=${detail}`;
80
+ // Verificar si pageSize es válido y agregarlo
81
+ if (pageSize != null) {
82
+ url += `&pageSize=${encodeURIComponent(pageSize)}`;
83
+ }
84
+ // Verificar si startDate es válido y agregarlo
85
+ if (startDate) {
86
+ url += `&startDate=${encodeURIComponent(startDate)}`;
87
+ }
88
+ // Verificar si endDate es válido y agregarlo
89
+ if (endDate) {
90
+ url += `&endDate=${encodeURIComponent(endDate)}`;
91
+ }
92
+ return await this.httpRequest.get(url);
93
+ }
94
+ catch (error) {
95
+ console.log(error);
96
+ throw error;
97
+ }
98
+ }
99
+ async getCardTransactions(externalUserId, page, pageSize) {
100
+ const url = `${this.baseUrl}users/${externalUserId}/transactions?page=${page}&pageSize=${pageSize}`;
101
+ return await this.httpRequest.get(url);
102
+ }
103
+ async getAccountTransactions(accountId) {
104
+ const url = `${this.baseUrl}accounts/${accountId}/transactions/all`;
105
+ return await this.httpRequest.get(url);
106
+ }
76
107
  };
77
108
  TernApi = __decorate([
78
109
  (0, inversify_1.injectable)(),
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@fiado/api-invoker",
3
- "version": "1.1.16",
4
- "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
5
- "main": "bin/index.js",
6
- "types": "bin/index.d.ts",
7
- "scripts": {
8
- "test": "test",
9
- "build": "tsc"
10
- },
11
- "keywords": [],
12
- "author": "Fiado Inc",
13
- "license": "ISC",
14
- "dependencies": {
15
- "@aws-sdk/client-sqs": "^3.572.0",
16
- "@fiado/gateway-adapter": "^1.1.32",
17
- "@fiado/http-client": "^1.0.2",
18
- "@fiado/logger": "^1.0.2",
19
- "@fiado/type-kit": "^1.2.33",
20
- "dotenv": "^16.4.5",
21
- "inversify": "^6.0.2",
22
- "reflect-metadata": "^0.2.1",
23
- "typescript": "^5.4.3"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^20.12.7"
27
- }
28
- }
1
+ {
2
+ "name": "@fiado/api-invoker",
3
+ "version": "1.1.18",
4
+ "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
5
+ "main": "bin/index.js",
6
+ "types": "bin/index.d.ts",
7
+ "scripts": {
8
+ "test": "test",
9
+ "build": "tsc"
10
+ },
11
+ "keywords": [],
12
+ "author": "Fiado Inc",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "@aws-sdk/client-sqs": "^3.572.0",
16
+ "@fiado/gateway-adapter": "^1.1.32",
17
+ "@fiado/http-client": "^1.0.2",
18
+ "@fiado/logger": "^1.0.2",
19
+ "@fiado/type-kit": "^1.2.33",
20
+ "dotenv": "^16.4.5",
21
+ "inversify": "^6.0.2",
22
+ "reflect-metadata": "^0.2.1",
23
+ "typescript": "^5.4.3"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.12.7"
27
+ }
28
+ }
@@ -1,19 +1,19 @@
1
- import { inject, injectable } from "inversify";
2
- import { IAccountBeneficiaryApi } from "./interfaces/IAccountBeneficiaryApi";
3
- import { IHttpRequest } from "@fiado/http-client";
4
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary";
5
- import { CountryId } from "@fiado/type-kit/bin/country";
6
-
7
-
8
- @injectable()
9
- export class AccountBeneficiaryApi implements IAccountBeneficiaryApi {
10
- private readonly baseUrl = process.env.ACCOUNT_BENEFICIARY_LAMBDA_URL || "";
11
-
12
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
13
- }
14
-
15
- async create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void> {
16
- const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
17
- return await this.httpRequest.post(url, input);
18
- }
1
+ import { inject, injectable } from "inversify";
2
+ import { IAccountBeneficiaryApi } from "./interfaces/IAccountBeneficiaryApi";
3
+ import { IHttpRequest } from "@fiado/http-client";
4
+ import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary";
5
+ import { CountryId } from "@fiado/type-kit/bin/country";
6
+
7
+
8
+ @injectable()
9
+ export class AccountBeneficiaryApi implements IAccountBeneficiaryApi {
10
+ private readonly baseUrl = process.env.ACCOUNT_BENEFICIARY_LAMBDA_URL || "";
11
+
12
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
13
+ }
14
+
15
+ async create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void> {
16
+ const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
17
+ return await this.httpRequest.post(url, input);
18
+ }
19
19
  }
@@ -1,3 +1,3 @@
1
-
2
- export * from './interfaces/IAccountBeneficiaryApi';
1
+
2
+ export * from './interfaces/IAccountBeneficiaryApi';
3
3
  export * from './AccountBeneficiaryApi';
@@ -1,8 +1,8 @@
1
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary";
2
- import { CountryId } from "@fiado/type-kit/bin/country";
3
-
4
- export interface IAccountBeneficiaryApi {
5
-
6
- create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void>;
7
-
1
+ import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary";
2
+ import { CountryId } from "@fiado/type-kit/bin/country";
3
+
4
+ export interface IAccountBeneficiaryApi {
5
+
6
+ create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void>;
7
+
8
8
  }
@@ -1,66 +1,66 @@
1
- import {IAccountFiadoIncApi} from "./interfaces/IAccountFiadoIncApi";
2
- import {
3
- AccountCreateRequest,
4
- AccountCreateResponse,
5
- AccountUpdateBalanceRequest, AccountUpdateRequest, ExecuteP2pOperationRequest,
6
- ExecutePocketOperationRequest,
7
- GetAccountResponse,
8
- GetPocketBalanceResponse
9
- } from "@fiado/type-kit/bin/account";
10
- import {inject, injectable} from "inversify";
11
- import {IHttpRequest} from "@fiado/http-client";
12
- import {ApiGatewayResponse} from "@fiado/gateway-adapter";
13
- import {OperationEnum} from "@fiado/type-kit/bin/transaction";
14
-
15
- @injectable()
16
- export default class AccountFiadoIncApi implements IAccountFiadoIncApi {
17
- private readonly baseUrl = process.env.ACCOUNT_FIADOINC_LAMBDA_URL || "";
18
-
19
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
20
- }
21
-
22
- async createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>> {
23
- const url = `${this.baseUrl}`;
24
- return await this.httpRequest.post(url, data);
25
- }
26
-
27
- async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>> {
28
- const url = `${this.baseUrl}users/${directoryId}`;
29
- return await this.httpRequest.get(url);
30
- }
31
-
32
- async getPocketBalance(directoryId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>> {
33
- const url = `${this.baseUrl}/pockets/users/${directoryId}/balance`;
34
- return await this.httpRequest.get(url);
35
- }
36
-
37
- async updatePocketBalance(pocketId: string, request: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<null>> {
38
- const url = `${this.baseUrl}/pockets/${pocketId}/balance`;
39
- return await this.httpRequest.put(url, request);
40
- }
41
-
42
- async getPocketBalanceById(pocketId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>> {
43
- const url = `${this.baseUrl}/pockets/${pocketId}/balance`;
44
- return await this.httpRequest.get(url);
45
- }
46
-
47
- async executePocketTransaction(pocketId: string, operation: OperationEnum, request: ExecutePocketOperationRequest): Promise<ApiGatewayResponse<any>> {
48
- const url = `${this.baseUrl}/pockets/${pocketId}/${operation}`;
49
- return await this.httpRequest.post(url, request);
50
- }
51
-
52
- async executeP2pTransaction(request: ExecuteP2pOperationRequest): Promise<ApiGatewayResponse<any>> {
53
- const url = `${this.baseUrl}/p2p/send`;
54
- return await this.httpRequest.post(url, request);
55
- }
56
-
57
- async deletePocket(pocketId: string): Promise<ApiGatewayResponse<void>> {
58
- const url = `${this.baseUrl}pockets/${pocketId}`;
59
- return await this.httpRequest.delete(url);
60
- }
61
-
62
- async update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>> {
63
- const url = `${this.baseUrl}users/${directoryId}`;
64
- return await this.httpRequest.put(url, data);
65
- }
1
+ import {IAccountFiadoIncApi} from "./interfaces/IAccountFiadoIncApi";
2
+ import {
3
+ AccountCreateRequest,
4
+ AccountCreateResponse,
5
+ AccountUpdateBalanceRequest, AccountUpdateRequest, ExecuteP2pOperationRequest,
6
+ ExecutePocketOperationRequest,
7
+ GetAccountResponse,
8
+ GetPocketBalanceResponse
9
+ } from "@fiado/type-kit/bin/account";
10
+ import {inject, injectable} from "inversify";
11
+ import {IHttpRequest} from "@fiado/http-client";
12
+ import {ApiGatewayResponse} from "@fiado/gateway-adapter";
13
+ import {OperationEnum} from "@fiado/type-kit/bin/transaction";
14
+
15
+ @injectable()
16
+ export default class AccountFiadoIncApi implements IAccountFiadoIncApi {
17
+ private readonly baseUrl = process.env.ACCOUNT_FIADOINC_LAMBDA_URL || "";
18
+
19
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
20
+ }
21
+
22
+ async createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>> {
23
+ const url = `${this.baseUrl}`;
24
+ return await this.httpRequest.post(url, data);
25
+ }
26
+
27
+ async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>> {
28
+ const url = `${this.baseUrl}users/${directoryId}`;
29
+ return await this.httpRequest.get(url);
30
+ }
31
+
32
+ async getPocketBalance(directoryId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>> {
33
+ const url = `${this.baseUrl}/pockets/users/${directoryId}/balance`;
34
+ return await this.httpRequest.get(url);
35
+ }
36
+
37
+ async updatePocketBalance(pocketId: string, request: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<null>> {
38
+ const url = `${this.baseUrl}/pockets/${pocketId}/balance`;
39
+ return await this.httpRequest.put(url, request);
40
+ }
41
+
42
+ async getPocketBalanceById(pocketId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>> {
43
+ const url = `${this.baseUrl}/pockets/${pocketId}/balance`;
44
+ return await this.httpRequest.get(url);
45
+ }
46
+
47
+ async executePocketTransaction(pocketId: string, operation: OperationEnum, request: ExecutePocketOperationRequest): Promise<ApiGatewayResponse<any>> {
48
+ const url = `${this.baseUrl}/pockets/${pocketId}/${operation}`;
49
+ return await this.httpRequest.post(url, request);
50
+ }
51
+
52
+ async executeP2pTransaction(request: ExecuteP2pOperationRequest): Promise<ApiGatewayResponse<any>> {
53
+ const url = `${this.baseUrl}/p2p/send`;
54
+ return await this.httpRequest.post(url, request);
55
+ }
56
+
57
+ async deletePocket(pocketId: string): Promise<ApiGatewayResponse<void>> {
58
+ const url = `${this.baseUrl}pockets/${pocketId}`;
59
+ return await this.httpRequest.delete(url);
60
+ }
61
+
62
+ async update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>> {
63
+ const url = `${this.baseUrl}users/${directoryId}`;
64
+ return await this.httpRequest.put(url, data);
65
+ }
66
66
  }
@@ -1,2 +1,2 @@
1
- export * from './interfaces/IAccountFiadoIncApi';
1
+ export * from './interfaces/IAccountFiadoIncApi';
2
2
  export * from './AccountFiadoIncApi';
@@ -1,33 +1,33 @@
1
- import {
2
- AccountCreateRequest,
3
- AccountCreateResponse,
4
- AccountUpdateBalanceRequest,
5
- AccountUpdateRequest,
6
- ExecuteP2pOperationRequest,
7
- ExecutePocketOperationRequest,
8
- GetAccountResponse,
9
- GetPocketBalanceResponse
10
- } from "@fiado/type-kit/bin/account";
11
- import {ApiGatewayResponse} from "@fiado/gateway-adapter";
12
- import {OperationEnum} from "@fiado/type-kit/bin/transaction";
13
-
14
-
15
- export interface IAccountFiadoIncApi {
16
- createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>>;
17
-
18
- getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
19
-
20
- getPocketBalance(directoryId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>>;
21
-
22
- updatePocketBalance(pocketId: string, request: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<null>>;
23
-
24
- getPocketBalanceById(pocketId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>>;
25
-
26
- executePocketTransaction(pocketId: string, operation: OperationEnum, request: ExecutePocketOperationRequest): Promise<ApiGatewayResponse<any>>;
27
-
28
- executeP2pTransaction(request: ExecuteP2pOperationRequest): Promise<ApiGatewayResponse<any>>;
29
-
30
- deletePocket(pocketId: string): Promise<ApiGatewayResponse<void>>
31
-
32
- update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>>
1
+ import {
2
+ AccountCreateRequest,
3
+ AccountCreateResponse,
4
+ AccountUpdateBalanceRequest,
5
+ AccountUpdateRequest,
6
+ ExecuteP2pOperationRequest,
7
+ ExecutePocketOperationRequest,
8
+ GetAccountResponse,
9
+ GetPocketBalanceResponse
10
+ } from "@fiado/type-kit/bin/account";
11
+ import {ApiGatewayResponse} from "@fiado/gateway-adapter";
12
+ import {OperationEnum} from "@fiado/type-kit/bin/transaction";
13
+
14
+
15
+ export interface IAccountFiadoIncApi {
16
+ createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse>>;
17
+
18
+ getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
19
+
20
+ getPocketBalance(directoryId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>>;
21
+
22
+ updatePocketBalance(pocketId: string, request: AccountUpdateBalanceRequest): Promise<ApiGatewayResponse<null>>;
23
+
24
+ getPocketBalanceById(pocketId: string): Promise<ApiGatewayResponse<GetPocketBalanceResponse>>;
25
+
26
+ executePocketTransaction(pocketId: string, operation: OperationEnum, request: ExecutePocketOperationRequest): Promise<ApiGatewayResponse<any>>;
27
+
28
+ executeP2pTransaction(request: ExecuteP2pOperationRequest): Promise<ApiGatewayResponse<any>>;
29
+
30
+ deletePocket(pocketId: string): Promise<ApiGatewayResponse<void>>
31
+
32
+ update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>>
33
33
  }
@@ -1,28 +1,28 @@
1
- import {IAccountFiadoSAApi} from "./interfaces/IAccountFiadoSAApi";
2
- import {AccountCreateRequest, AccountCreateResponse, AccountUpdateRequest, GetAccountResponse} from "@fiado/type-kit/bin/account";
3
- import {ApiGatewayResponse} from "@fiado/gateway-adapter";
4
- import {inject, injectable} from "inversify";
5
- import {IHttpRequest} from "@fiado/http-client";
6
-
7
- @injectable()
8
- export default class AccountFiadoSAApi implements IAccountFiadoSAApi {
9
- private readonly baseUrl = process.env.ACCOUNT_FIADOSA_LAMBDA_URL || "";
10
-
11
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
12
- }
13
-
14
- async createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse[]>> {
15
- const url = `${this.baseUrl}`;
16
- return await this.httpRequest.post(url, data);
17
- }
18
-
19
- async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>> {
20
- const url = `${this.baseUrl}users/${directoryId}`;
21
- return await this.httpRequest.get(url);
22
- }
23
-
24
- async update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>> {
25
- const url = `${this.baseUrl}users/${directoryId}`;
26
- return await this.httpRequest.put(url, data);
27
- }
1
+ import {IAccountFiadoSAApi} from "./interfaces/IAccountFiadoSAApi";
2
+ import {AccountCreateRequest, AccountCreateResponse, AccountUpdateRequest, GetAccountResponse} from "@fiado/type-kit/bin/account";
3
+ import {ApiGatewayResponse} from "@fiado/gateway-adapter";
4
+ import {inject, injectable} from "inversify";
5
+ import {IHttpRequest} from "@fiado/http-client";
6
+
7
+ @injectable()
8
+ export default class AccountFiadoSAApi implements IAccountFiadoSAApi {
9
+ private readonly baseUrl = process.env.ACCOUNT_FIADOSA_LAMBDA_URL || "";
10
+
11
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
12
+ }
13
+
14
+ async createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse[]>> {
15
+ const url = `${this.baseUrl}`;
16
+ return await this.httpRequest.post(url, data);
17
+ }
18
+
19
+ async getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>> {
20
+ const url = `${this.baseUrl}users/${directoryId}`;
21
+ return await this.httpRequest.get(url);
22
+ }
23
+
24
+ async update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>> {
25
+ const url = `${this.baseUrl}users/${directoryId}`;
26
+ return await this.httpRequest.put(url, data);
27
+ }
28
28
  }
@@ -1,2 +1,2 @@
1
- export * from './interfaces/IAccountFiadoSAApi';
1
+ export * from './interfaces/IAccountFiadoSAApi';
2
2
  export * from './AccountFiadoSAApi';
@@ -1,12 +1,12 @@
1
- import {AccountCreateRequest, AccountCreateResponse, AccountUpdateRequest, GetAccountResponse} from "@fiado/type-kit/bin/account";
2
- import {ApiGatewayResponse} from "@fiado/gateway-adapter";
3
-
4
-
5
- export interface IAccountFiadoSAApi {
6
- createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse[]>>;
7
-
8
- getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
9
-
10
- update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>>
11
-
1
+ import {AccountCreateRequest, AccountCreateResponse, AccountUpdateRequest, GetAccountResponse} from "@fiado/type-kit/bin/account";
2
+ import {ApiGatewayResponse} from "@fiado/gateway-adapter";
3
+
4
+
5
+ export interface IAccountFiadoSAApi {
6
+ createAccount(data: AccountCreateRequest): Promise<ApiGatewayResponse<AccountCreateResponse[]>>;
7
+
8
+ getAccountByDirectoryId(directoryId: string): Promise<ApiGatewayResponse<GetAccountResponse[]>>;
9
+
10
+ update(directoryId: string, data: AccountUpdateRequest): Promise<ApiGatewayResponse<void>>
11
+
12
12
  }