@fiado/api-invoker 1.2.84 → 1.2.86

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.
@@ -2,8 +2,10 @@ import { ITernApi } from "./interfaces/ITernApi";
2
2
  import { IHttpRequest } from "@fiado/http-client";
3
3
  import { BankAccountP2pTransferRequest, CreateBankAccountRequest, CreateBankAccountUserRequest, GetBankAccountRequest, GetBankAccountUserRequest } from "@fiado/type-kit/bin/account";
4
4
  import { ActivateBankAccountCardRequest, AssignCardRequest, CreateBankAccountCardRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
5
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
6
+ import { BankAccountP2pTransferResponse } from "@fiado/type-kit/bin/account/dtos/BankAccountP2pTransferResponse";
5
7
  export default class TernApi implements ITernApi {
6
- private httpRequest;
8
+ private readonly httpRequest;
7
9
  private readonly baseUrl;
8
10
  constructor(httpRequest: IHttpRequest);
9
11
  getUser(request: GetBankAccountUserRequest): Promise<any>;
@@ -19,7 +21,7 @@ export default class TernApi implements ITernApi {
19
21
  updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
20
22
  activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
21
23
  assignCardToUser(request: AssignCardRequest): Promise<any>;
22
- p2pTransfer(request: BankAccountP2pTransferRequest): Promise<any>;
24
+ p2pTransfer(request: BankAccountP2pTransferRequest): Promise<FiadoApiResponse<BankAccountP2pTransferResponse>>;
23
25
  getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean, raw?: boolean): Promise<any>;
24
26
  getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
25
27
  getAccountTransactions(accountId: string): Promise<any>;
@@ -1,7 +1,9 @@
1
- import { CreateBankAccountRequest, CreateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
1
+ import { BankAccountP2pTransferRequest, CreateBankAccountRequest, CreateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
2
2
  import { GetBankAccountUserRequest } from "@fiado/type-kit/bin/account/dtos/GetBankAccountUserRequest";
3
3
  import { GetBankAccountRequest } from "@fiado/type-kit/bin/account/dtos/GetBankAccountRequest";
4
4
  import { ActivateBankAccountCardRequest, AssignCardRequest, CreateBankAccountCardRequest, UpdateBankAccountCardRequest, UpdateBankAccountCardResponse } from "@fiado/type-kit/bin/card";
5
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
6
+ import { BankAccountP2pTransferResponse } from "@fiado/type-kit/bin/account/dtos/BankAccountP2pTransferResponse";
5
7
  export interface ITernApi {
6
8
  getUser(request: GetBankAccountUserRequest): Promise<any>;
7
9
  getAccount(request: GetBankAccountRequest): Promise<any>;
@@ -15,7 +17,7 @@ export interface ITernApi {
15
17
  updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
16
18
  activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
17
19
  assignCardToUser(request: AssignCardRequest): Promise<any>;
18
- p2pTransfer(request: any): Promise<any>;
20
+ p2pTransfer(request: BankAccountP2pTransferRequest): Promise<FiadoApiResponse<BankAccountP2pTransferResponse>>;
19
21
  getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
20
22
  getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
21
23
  getAccountTransactions(accountId: string): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "1.2.84",
3
+ "version": "1.2.86",
4
4
  "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "@fiado/gateway-adapter": "^1.1.40",
17
17
  "@fiado/http-client": "^1.0.5",
18
18
  "@fiado/logger": "^1.0.3",
19
- "@fiado/type-kit": "^1.8.44",
19
+ "@fiado/type-kit": "^1.8.48",
20
20
  "dotenv": "^16.4.7",
21
21
  "inversify": "^6.2.2",
22
22
  "reflect-metadata": "^0.2.2"
@@ -2,147 +2,147 @@ import {ITernApi} from "./interfaces/ITernApi";
2
2
  import {inject, injectable} from "inversify";
3
3
  import {IHttpRequest} from "@fiado/http-client";
4
4
  import {
5
- BankAccountP2pTransferRequest,
6
- CreateBankAccountRequest,
7
- CreateBankAccountUserRequest,
8
- GetBankAccountRequest,
9
- GetBankAccountUserRequest,
5
+ BankAccountP2pTransferRequest,
6
+ CreateBankAccountRequest,
7
+ CreateBankAccountUserRequest,
8
+ GetBankAccountRequest,
9
+ GetBankAccountUserRequest,
10
10
  } from "@fiado/type-kit/bin/account";
11
11
  import {
12
- ActivateBankAccountCardRequest,
13
- AssignCardRequest,
14
- CreateBankAccountCardRequest,
15
- UpdateBankAccountCardRequest
12
+ ActivateBankAccountCardRequest,
13
+ AssignCardRequest,
14
+ CreateBankAccountCardRequest,
15
+ UpdateBankAccountCardRequest
16
16
  } from "@fiado/type-kit/bin/card";
17
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
18
+ import {BankAccountP2pTransferResponse} from "@fiado/type-kit/bin/account/dtos/BankAccountP2pTransferResponse";
17
19
 
18
20
 
19
21
  @injectable()
20
22
  export default class TernApi implements ITernApi {
21
- private readonly baseUrl = process.env.TERN_LAMBDA_URL || "";
22
-
23
- constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
24
- }
25
-
26
- /// USERS
27
- async getUser(request: GetBankAccountUserRequest): Promise<any> {
28
- const url: string = `${this.baseUrl}users/${request.externalUserId}`;
29
- return await this.httpRequest.get(url);
30
- }
31
-
32
- async createUser(request: CreateBankAccountUserRequest): Promise<any> {
33
- const url: string = `${this.baseUrl}users/create`;
34
- return await this.httpRequest.post(url, request);
35
- }
36
-
37
- /// ACCOUNTS
38
- async getAccount(request: GetBankAccountRequest): Promise<any> {
39
- const url: string = `${this.baseUrl}accounts/${request.externalAccountId}`;
40
- return await this.httpRequest.get(url);
41
- }
42
-
43
- async getBusinessAccount(request: GetBankAccountRequest): Promise<any> {
44
- const url: string = `${this.baseUrl}accounts/${request.externalAccountId}?accountType=BUSINESS`;
45
- return await this.httpRequest.get(url);
46
- }
47
-
48
- async createAccount(request: CreateBankAccountRequest): Promise<any> {
49
- const url: string = `${this.baseUrl}accounts/create`;
50
- return await this.httpRequest.post(url, request);
51
- }
52
-
53
- /// CARDS
54
-
55
- async getCardSensitiveInformation(externalCardId: string, externalUserId?: string): Promise<any> {
56
-
57
- const url = `${this.baseUrl}cards/${externalCardId}/sensitive`;
58
- return await this.httpRequest.get(url);
59
- }
60
-
61
- async getCardsById(externalCardId: string): Promise<any> {
62
-
63
- const url = `${this.baseUrl}cards/${externalCardId}/`;
64
- return await this.httpRequest.get(url);
65
- }
66
-
67
- async createCard(request: CreateBankAccountCardRequest): Promise<any> {
68
- const url = `${this.baseUrl}cards/create`;
69
- return await this.httpRequest.post(url, request);
70
- }
71
-
72
- async blockCard(request: UpdateBankAccountCardRequest): Promise<any> {
73
- const url = `${this.baseUrl}cards/block`;
74
- return await this.httpRequest.post(url, request);
75
- }
76
-
77
- async changePin(request: UpdateBankAccountCardRequest): Promise<any> {
78
- const url = `${this.baseUrl}cards/${request.cardId}/`;
79
- return await this.httpRequest.put(url, request);
80
- }
81
-
82
- async updateCard(request: UpdateBankAccountCardRequest): Promise<any> {
83
- const url = `${this.baseUrl}cards/${request.cardId}/`;
84
- return await this.httpRequest.put(url, request);
85
- }
86
-
87
- async activateCard(request: ActivateBankAccountCardRequest): Promise<any> {
88
- const url = `${this.baseUrl}cards/activate`;
89
- return await this.httpRequest.post(url, request);
90
- }
91
-
92
- async assignCardToUser(request: AssignCardRequest): Promise<any> {
93
- const url = `${this.baseUrl}cards/activate`;
94
- return await this.httpRequest.post(url, request);
95
- }
96
-
97
- async p2pTransfer(request: BankAccountP2pTransferRequest): Promise<any> {
98
- const url: string = `${this.baseUrl}users/accounts/transfer_balances`;
99
- return await this.httpRequest.patch(url, request);
100
- }
101
-
102
- //transactions
103
- async getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail: boolean = false, raw: boolean = false): Promise<any> {
104
- try {
105
- let url = `${this.baseUrl}users/${accountId}/v2/transactions?page=${page}&detail=${detail}&raw=${raw}`;
106
-
107
- // Verificar si pageSize es válido y agregarlo
108
- if (pageSize != null) {
109
- url += `&pageSize=${encodeURIComponent(pageSize)}`;
110
- }
111
-
112
- // Verificar si startDate es válido y agregarlo
113
- if (startDate) {
114
- url += `&startDate=${encodeURIComponent(startDate)}`;
115
- }
116
-
117
- // Verificar si endDate es válido y agregarlo
118
- if (endDate) {
119
- url += `&endDate=${encodeURIComponent(endDate)}`;
120
- }
121
-
122
- return await this.httpRequest.get(url);
123
- } catch (error) {
124
- console.log(error);
125
- throw error;
126
- }
127
- }
128
-
129
- async getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any> {
130
- const url = `${this.baseUrl}users/${externalUserId}/transactions?page=${page}&pageSize=${pageSize}`;
131
- return await this.httpRequest.get(url);
132
- }
133
-
134
- async getAccountTransactions(accountId: string): Promise<any> {
135
- const url = `${this.baseUrl}accounts/${accountId}/transactions/all`;
136
- return await this.httpRequest.get(url);
137
- }
138
-
139
- async getCardsByUserId(externalUserId: string): Promise<any> {
140
- const url = `${this.baseUrl}users/${externalUserId}/cards`;
141
- return await this.httpRequest.get(url);
142
- }
143
-
144
- async getAccountsByUserId(externalUserId: string): Promise<any> {
145
- const url = `${this.baseUrl}users/${externalUserId}/accounts`;
146
- return await this.httpRequest.get(url);
147
- }
23
+ private readonly baseUrl = process.env.TERN_LAMBDA_URL || "";
24
+
25
+ constructor(@inject("IHttpRequest") private readonly httpRequest: IHttpRequest) {
26
+ }
27
+
28
+ /// USERS
29
+ async getUser(request: GetBankAccountUserRequest): Promise<any> {
30
+ const url: string = `${this.baseUrl}users/${request.externalUserId}`;
31
+ return await this.httpRequest.get(url);
32
+ }
33
+
34
+ async createUser(request: CreateBankAccountUserRequest): Promise<any> {
35
+ const url: string = `${this.baseUrl}users/create`;
36
+ return await this.httpRequest.post(url, request);
37
+ }
38
+
39
+ /// ACCOUNTS
40
+ async getAccount(request: GetBankAccountRequest): Promise<any> {
41
+ const url: string = `${this.baseUrl}accounts/${request.externalAccountId}`;
42
+ return await this.httpRequest.get(url);
43
+ }
44
+
45
+ async getBusinessAccount(request: GetBankAccountRequest): Promise<any> {
46
+ const url: string = `${this.baseUrl}accounts/${request.externalAccountId}?accountType=BUSINESS`;
47
+ return await this.httpRequest.get(url);
48
+ }
49
+
50
+ async createAccount(request: CreateBankAccountRequest): Promise<any> {
51
+ const url: string = `${this.baseUrl}accounts/create`;
52
+ return await this.httpRequest.post(url, request);
53
+ }
54
+
55
+ /// CARDS
56
+ async getCardSensitiveInformation(externalCardId: string, externalUserId?: string): Promise<any> {
57
+ const url = `${this.baseUrl}cards/${externalCardId}/sensitive`;
58
+ return await this.httpRequest.get(url);
59
+ }
60
+
61
+ async getCardsById(externalCardId: string): Promise<any> {
62
+
63
+ const url = `${this.baseUrl}cards/${externalCardId}/`;
64
+ return await this.httpRequest.get(url);
65
+ }
66
+
67
+ async createCard(request: CreateBankAccountCardRequest): Promise<any> {
68
+ const url = `${this.baseUrl}cards/create`;
69
+ return await this.httpRequest.post(url, request);
70
+ }
71
+
72
+ async blockCard(request: UpdateBankAccountCardRequest): Promise<any> {
73
+ const url = `${this.baseUrl}cards/block`;
74
+ return await this.httpRequest.post(url, request);
75
+ }
76
+
77
+ async changePin(request: UpdateBankAccountCardRequest): Promise<any> {
78
+ const url = `${this.baseUrl}cards/${request.cardId}/`;
79
+ return await this.httpRequest.put(url, request);
80
+ }
81
+
82
+ async updateCard(request: UpdateBankAccountCardRequest): Promise<any> {
83
+ const url = `${this.baseUrl}cards/${request.cardId}/`;
84
+ return await this.httpRequest.put(url, request);
85
+ }
86
+
87
+ async activateCard(request: ActivateBankAccountCardRequest): Promise<any> {
88
+ const url = `${this.baseUrl}cards/activate`;
89
+ return await this.httpRequest.post(url, request);
90
+ }
91
+
92
+ async assignCardToUser(request: AssignCardRequest): Promise<any> {
93
+ const url = `${this.baseUrl}cards/activate`;
94
+ return await this.httpRequest.post(url, request);
95
+ }
96
+
97
+ async p2pTransfer(request: BankAccountP2pTransferRequest): Promise<FiadoApiResponse<BankAccountP2pTransferResponse>> {
98
+ const url: string = `${this.baseUrl}users/accounts/transfer_balances`;
99
+ return await this.httpRequest.patch(url, request);
100
+ }
101
+
102
+ //transactions
103
+ async getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail: boolean = false, raw: boolean = false): Promise<any> {
104
+ try {
105
+ let url = `${this.baseUrl}users/${accountId}/v2/transactions?page=${page}&detail=${detail}&raw=${raw}`;
106
+
107
+ // Verificar si pageSize es válido y agregarlo
108
+ if (pageSize != null) {
109
+ url += `&pageSize=${encodeURIComponent(pageSize)}`;
110
+ }
111
+
112
+ // Verificar si startDate es válido y agregarlo
113
+ if (startDate) {
114
+ url += `&startDate=${encodeURIComponent(startDate)}`;
115
+ }
116
+
117
+ // Verificar si endDate es válido y agregarlo
118
+ if (endDate) {
119
+ url += `&endDate=${encodeURIComponent(endDate)}`;
120
+ }
121
+
122
+ return await this.httpRequest.get(url);
123
+ } catch (error) {
124
+ console.log(error);
125
+ throw error;
126
+ }
127
+ }
128
+
129
+ async getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any> {
130
+ const url = `${this.baseUrl}users/${externalUserId}/transactions?page=${page}&pageSize=${pageSize}`;
131
+ return await this.httpRequest.get(url);
132
+ }
133
+
134
+ async getAccountTransactions(accountId: string): Promise<any> {
135
+ const url = `${this.baseUrl}accounts/${accountId}/transactions/all`;
136
+ return await this.httpRequest.get(url);
137
+ }
138
+
139
+ async getCardsByUserId(externalUserId: string): Promise<any> {
140
+ const url = `${this.baseUrl}users/${externalUserId}/cards`;
141
+ return await this.httpRequest.get(url);
142
+ }
143
+
144
+ async getAccountsByUserId(externalUserId: string): Promise<any> {
145
+ const url = `${this.baseUrl}users/${externalUserId}/accounts`;
146
+ return await this.httpRequest.get(url);
147
+ }
148
148
  }
@@ -1,49 +1,55 @@
1
- import {CreateBankAccountRequest, CreateBankAccountUserRequest} from "@fiado/type-kit/bin/account";
1
+ import {
2
+ BankAccountP2pTransferRequest,
3
+ CreateBankAccountRequest,
4
+ CreateBankAccountUserRequest
5
+ } from "@fiado/type-kit/bin/account";
2
6
  import {GetBankAccountUserRequest} from "@fiado/type-kit/bin/account/dtos/GetBankAccountUserRequest";
3
7
  import {GetBankAccountRequest} from "@fiado/type-kit/bin/account/dtos/GetBankAccountRequest";
4
8
  import {
5
- ActivateBankAccountCardRequest,
6
- AssignCardRequest,
7
- CreateBankAccountCardRequest,
8
- UpdateBankAccountCardRequest,
9
- UpdateBankAccountCardResponse
9
+ ActivateBankAccountCardRequest,
10
+ AssignCardRequest,
11
+ CreateBankAccountCardRequest,
12
+ UpdateBankAccountCardRequest,
13
+ UpdateBankAccountCardResponse
10
14
  } from "@fiado/type-kit/bin/card";
15
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
16
+ import {BankAccountP2pTransferResponse} from "@fiado/type-kit/bin/account/dtos/BankAccountP2pTransferResponse";
11
17
 
12
18
  export interface ITernApi {
13
- getUser(request: GetBankAccountUserRequest): Promise<any>;
19
+ getUser(request: GetBankAccountUserRequest): Promise<any>;
14
20
 
15
- getAccount(request: GetBankAccountRequest): Promise<any>;
21
+ getAccount(request: GetBankAccountRequest): Promise<any>;
16
22
 
17
- getBusinessAccount(request: GetBankAccountRequest): Promise<any>
23
+ getBusinessAccount(request: GetBankAccountRequest): Promise<any>
18
24
 
19
- createUser(request: CreateBankAccountUserRequest): Promise<any>;
25
+ createUser(request: CreateBankAccountUserRequest): Promise<any>;
20
26
 
21
- createAccount(request: CreateBankAccountRequest): Promise<any>
27
+ createAccount(request: CreateBankAccountRequest): Promise<any>
22
28
 
23
- getCardsById(externalCardId: string): Promise<any>;
29
+ getCardsById(externalCardId: string): Promise<any>;
24
30
 
25
- createCard(request: CreateBankAccountCardRequest): Promise<any>;
31
+ createCard(request: CreateBankAccountCardRequest): Promise<any>;
26
32
 
27
- blockCard(request: UpdateBankAccountCardRequest): Promise<any>;
33
+ blockCard(request: UpdateBankAccountCardRequest): Promise<any>;
28
34
 
29
- changePin(request: UpdateBankAccountCardRequest): Promise<UpdateBankAccountCardResponse>;
35
+ changePin(request: UpdateBankAccountCardRequest): Promise<UpdateBankAccountCardResponse>;
30
36
 
31
- updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
37
+ updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
32
38
 
33
- activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
39
+ activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
34
40
 
35
- assignCardToUser(request: AssignCardRequest): Promise<any>;
41
+ assignCardToUser(request: AssignCardRequest): Promise<any>;
36
42
 
37
- p2pTransfer(request: any): Promise<any>
43
+ p2pTransfer(request: BankAccountP2pTransferRequest): Promise<FiadoApiResponse<BankAccountP2pTransferResponse>>;
38
44
 
39
- getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
45
+ getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
40
46
 
41
- getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
47
+ getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
42
48
 
43
- getAccountTransactions(accountId: string): Promise<any>;
49
+ getAccountTransactions(accountId: string): Promise<any>;
44
50
 
45
- getCardsByUserId(externalUserId: string): Promise<any>;
51
+ getCardsByUserId(externalUserId: string): Promise<any>;
46
52
 
47
- getAccountsByUserId(externalUserId: string): Promise<any>;
53
+ getAccountsByUserId(externalUserId: string): Promise<any>;
48
54
 
49
55
  }