@fiado/api-invoker 1.2.55 → 1.2.56

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.
@@ -23,4 +23,5 @@ export default class TernApi implements ITernApi {
23
23
  getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean, raw?: boolean): Promise<any>;
24
24
  getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
25
25
  getAccountTransactions(accountId: string): Promise<any>;
26
+ getCardsByUserId(externalUserId: string): Promise<any>;
26
27
  }
@@ -108,6 +108,10 @@ let TernApi = class TernApi {
108
108
  const url = `${this.baseUrl}accounts/${accountId}/transactions/all`;
109
109
  return await this.httpRequest.get(url);
110
110
  }
111
+ async getCardsByUserId(externalUserId) {
112
+ const url = `${this.baseUrl}users/${externalUserId}/cards`;
113
+ return await this.httpRequest.get(url);
114
+ }
111
115
  };
112
116
  TernApi = __decorate([
113
117
  (0, inversify_1.injectable)(),
@@ -19,4 +19,5 @@ export interface ITernApi {
19
19
  getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
20
20
  getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
21
21
  getAccountTransactions(accountId: string): Promise<any>;
22
+ getCardsByUserId(externalUserId: string): Promise<any>;
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "1.2.55",
3
+ "version": "1.2.56",
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",
@@ -1,138 +1,143 @@
1
- import { ITernApi } from "./interfaces/ITernApi";
2
- import { inject, injectable } from "inversify";
3
- import { IHttpRequest } from "@fiado/http-client";
1
+ import {ITernApi} from "./interfaces/ITernApi";
2
+ import {inject, injectable} from "inversify";
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
17
 
18
18
 
19
19
  @injectable()
20
20
  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
- }
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
+ }
138
143
  }
@@ -1,39 +1,46 @@
1
1
  import {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
- import { ActivateBankAccountCardRequest, AssignCardRequest, CreateBankAccountCardRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
4
+ import {
5
+ ActivateBankAccountCardRequest,
6
+ AssignCardRequest,
7
+ CreateBankAccountCardRequest,
8
+ UpdateBankAccountCardRequest
9
+ } from "@fiado/type-kit/bin/card";
5
10
 
6
11
  export interface ITernApi {
7
- getUser(request: GetBankAccountUserRequest): Promise<any>;
12
+ getUser(request: GetBankAccountUserRequest): Promise<any>;
8
13
 
9
- getAccount(request: GetBankAccountRequest): Promise<any>;
14
+ getAccount(request: GetBankAccountRequest): Promise<any>;
10
15
 
11
- getBusinessAccount(request: GetBankAccountRequest): Promise<any>
16
+ getBusinessAccount(request: GetBankAccountRequest): Promise<any>
12
17
 
13
- createUser(request: CreateBankAccountUserRequest): Promise<any>;
18
+ createUser(request: CreateBankAccountUserRequest): Promise<any>;
14
19
 
15
- createAccount(request: CreateBankAccountRequest): Promise<any>
20
+ createAccount(request: CreateBankAccountRequest): Promise<any>
16
21
 
17
- getCardsById(externalCardId: string): Promise<any>;
22
+ getCardsById(externalCardId: string): Promise<any>;
18
23
 
19
- createCard(request: CreateBankAccountCardRequest): Promise<any>;
24
+ createCard(request: CreateBankAccountCardRequest): Promise<any>;
20
25
 
21
- blockCard(request: UpdateBankAccountCardRequest): Promise<any>;
26
+ blockCard(request: UpdateBankAccountCardRequest): Promise<any>;
22
27
 
23
- changePin(request: UpdateBankAccountCardRequest): Promise<any>;
28
+ changePin(request: UpdateBankAccountCardRequest): Promise<any>;
24
29
 
25
- updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
30
+ updateCard(request: UpdateBankAccountCardRequest): Promise<any>;
26
31
 
27
- activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
32
+ activateCard(request: ActivateBankAccountCardRequest): Promise<any>;
28
33
 
29
- assignCardToUser(request: AssignCardRequest): Promise<any>;
34
+ assignCardToUser(request: AssignCardRequest): Promise<any>;
30
35
 
31
- p2pTransfer(request: any): Promise<any>
36
+ p2pTransfer(request: any): Promise<any>
32
37
 
33
- getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
38
+ getTransactions(accountId: string, page: number, pageSize?: number | null, startDate?: string | null, endDate?: string | null, detail?: boolean): Promise<any>;
34
39
 
35
- getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
40
+ getCardTransactions(externalUserId: string, page: number, pageSize: number): Promise<any>;
36
41
 
37
- getAccountTransactions(accountId: string): Promise<any>
42
+ getAccountTransactions(accountId: string): Promise<any>;
43
+
44
+ getCardsByUserId(externalUserId: string): Promise<any>;
38
45
 
39
46
  }