@fiado/api-invoker 1.2.42 → 1.2.44

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.
@@ -0,0 +1,17 @@
1
+ import { IHttpRequest } from "@fiado/http-client";
2
+ import { IActivityApi } from './interfaces/IActivityApi';
3
+ import { TypeOfDirectoryId } from '@fiado/type-kit/bin/directory';
4
+ export declare class ActivityApi implements IActivityApi {
5
+ private httpRequest;
6
+ private readonly baseUrl;
7
+ constructor(httpRequest: IHttpRequest);
8
+ getActivities(typeOfActivities: string[]): Promise<any>;
9
+ getActivitiesByDirectoryIdAndTypeOfActivity(directoryId: string, typeOfActivities: string[]): Promise<any>;
10
+ postActivity(params: {
11
+ directoryId: string;
12
+ typeOfDirectoryId: TypeOfDirectoryId;
13
+ typeOfActivity: string;
14
+ amount: string;
15
+ date: string;
16
+ }): Promise<any>;
17
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ActivityApi = void 0;
19
+ const dotenv_1 = __importDefault(require("dotenv"));
20
+ const inversify_1 = require("inversify");
21
+ dotenv_1.default.config();
22
+ let ActivityApi = class ActivityApi {
23
+ constructor(httpRequest) {
24
+ this.httpRequest = httpRequest;
25
+ this.baseUrl = process.env.ACTIVITY_LAMBDA_URL || "";
26
+ }
27
+ async getActivities(typeOfActivities) {
28
+ let url = `${this.baseUrl}activities`;
29
+ if (typeOfActivities.length > 0) {
30
+ url = `${this.baseUrl}activities?${typeOfActivities.map(id => `typeOfActivities=${encodeURIComponent(id)}`).join('&')}`;
31
+ }
32
+ const operationName = "getActivities";
33
+ return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
34
+ }
35
+ async getActivitiesByDirectoryIdAndTypeOfActivity(directoryId, typeOfActivities) {
36
+ if (directoryId == null || directoryId == undefined || directoryId == "") {
37
+ throw new Error("At least directory ID is required.");
38
+ }
39
+ let url = `${this.baseUrl}activities/directory/${directoryId}`;
40
+ if (typeOfActivities.length > 0) {
41
+ url = `${this.baseUrl}activities/directory/${directoryId}?${typeOfActivities.map(id => `typeOfActivities=${encodeURIComponent(id)}`).join('&')}`;
42
+ }
43
+ const operationName = "getActivitiesByDirectoryIdAndTypeOfActivity";
44
+ return await this.httpRequest.post(`${url}`, null, { 'operationName': operationName });
45
+ }
46
+ async postActivity(params) {
47
+ if (params.directoryId == null || params.directoryId == undefined || params.directoryId == "") {
48
+ throw new Error("At least directory ID is required.");
49
+ }
50
+ if (params.typeOfDirectoryId == null || params.typeOfDirectoryId == undefined) {
51
+ throw new Error("At least typeOfDirectoryId is required.");
52
+ }
53
+ if (params.typeOfActivity == null || params.typeOfActivity == undefined || params.typeOfActivity == "") {
54
+ throw new Error("At least typeOfActivity is required.");
55
+ }
56
+ if (params.amount == null || params.amount == undefined || params.amount == "") {
57
+ throw new Error("At least amount is required.");
58
+ }
59
+ if (params.date == null || params.date == undefined || params.date == "") {
60
+ throw new Error("At least date is required.");
61
+ }
62
+ const url = `${this.baseUrl}/activities/create`;
63
+ const operationName = "postActivity";
64
+ return await this.httpRequest.post(`${url}`, params, { 'operationName': operationName });
65
+ }
66
+ };
67
+ exports.ActivityApi = ActivityApi;
68
+ exports.ActivityApi = ActivityApi = __decorate([
69
+ (0, inversify_1.injectable)(),
70
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
71
+ __metadata("design:paramtypes", [Object])
72
+ ], ActivityApi);
@@ -0,0 +1,2 @@
1
+ export * from './interfaces/IActivityApi';
2
+ export * from './ActivityApi';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces/IActivityApi"), exports);
18
+ __exportStar(require("./ActivityApi"), exports);
@@ -0,0 +1,39 @@
1
+ import { TypeOfDirectoryId } from "@fiado/type-kit/bin/directory";
2
+ /**
3
+ * Interfaz para el servicio Directory que permite operaciones sobre directorios.
4
+ */
5
+ export interface IActivityApi {
6
+ /**
7
+ * Obtiene una lista de entidades de la tabla ActivityDirectory.
8
+ * @param directoryId Directorio que se va a consultar.
9
+ * @param typeOfActivities Array de tipos de actividades (Opcional).
10
+ * @returns Retorna un arreglo de objetos de ActivityDirectory.
11
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
+ */
13
+ getActivitiesByDirectoryIdAndTypeOfActivity(directoryId: string, typeOfActivities: string[]): Promise<any>;
14
+ /**
15
+ * Obtener actividades globales.
16
+ * @param typeOfActivity Tipo de actividad
17
+ * Puede devolver un arreglo vacío si no se encuentran coincidencias.
18
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
19
+ */
20
+ getActivities(typeOfActivities: string[]): Promise<any>;
21
+ /**
22
+ * Proceso para agregar a las actividades.
23
+ * @param directoryId Directorio
24
+ * @param typeOfDirectoryId Tipo de directorio
25
+ * @param typeOfActivity Tipo de actividad
26
+ * @param amount Monto de la actividad
27
+ * @param date Fecha de la actividad
28
+ * @returns Retorna un objeto de ActivityDirectory.
29
+ * Puede devolver un arreglo vacío si no se encuentran coincidencias.
30
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
31
+ */
32
+ postActivity(params: {
33
+ directoryId: string;
34
+ typeOfDirectoryId: TypeOfDirectoryId;
35
+ typeOfActivity: string;
36
+ amount: string;
37
+ date: string;
38
+ }): Promise<any>;
39
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,36 +1,39 @@
1
1
  import { ICentralPaymentsConnectorApi } from "./interfaces/ICentralPaymentsConnectorApi";
2
2
  import { IHttpRequest } from "@fiado/http-client";
3
- import { ApiResponse } from "@fiado/gateway-adapter";
4
- import { CreateBankAccountUserRequest, UpdateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
5
- import { SubmitOOWQuestionAnswersRequest } from "@fiado/type-kit/bin/centralPayments";
6
- import { UploadDocumentRequest } from "@fiado/type-kit/bin/identity";
7
- import { ActivateBankAccountCardRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
3
+ import { CreateBankAccountUserRequest, CreateBankAccountUserResponse, GetBankAccountUserResponse, UpdateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
4
+ import { CentralPaymentsDocumentUploadRequest, HealthcheckResponse, OOWQuestionsResponse, SubmitOOWQuestionAnswersRequest } from "@fiado/type-kit/bin/centralPayments";
5
+ import { ActivateBankAccountCardRequest, ActivateBankAccountCardResponse, CardBatchRequest, CardBatchResponse, CardStatementListResponse, GetBankAccountCardBalanceResponse, GetBankAccountCardResponse, StatementDocumentResponse, UpdateBankAccountCardRequest, UpdateBankAccountCardResponse } from "@fiado/type-kit/bin/card";
8
6
  import { Status } from "@fiado/type-kit/bin/directory/enums/Status";
7
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
8
+ import { CentralPaymentsQueryParams, CentralPaymentsTransactionItem, TransactionListResponse } from "@fiado/type-kit/bin/transaction";
9
+ import { InvokerUtils } from "../utils/InvokerUtils";
9
10
  export declare class CentralPaymentsConnectorApi implements ICentralPaymentsConnectorApi {
10
11
  private readonly httpRequest;
12
+ private readonly _invokerUtils;
11
13
  private readonly baseUrl;
12
- constructor(httpRequest: IHttpRequest);
13
- healthcheck(): Promise<ApiResponse>;
14
- createCardholder(request: CreateBankAccountUserRequest): Promise<ApiResponse>;
15
- getCardholder(externalUserId: string): Promise<ApiResponse>;
16
- updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<ApiResponse>;
17
- getOOWQuestions(externalUserId: string): Promise<ApiResponse>;
18
- submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<ApiResponse>;
19
- uploadDocuments(externalUserId: string, request: UploadDocumentRequest): Promise<ApiResponse>;
20
- setCardPin(request: UpdateBankAccountCardRequest): Promise<ApiResponse>;
21
- getCardInformation(externalCardId: string): Promise<ApiResponse>;
22
- getCardSensitiveInformation(externalCardId: string): Promise<ApiResponse>;
23
- activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<ApiResponse>;
24
- getCardBalance(externalCardId: string): Promise<ApiResponse>;
25
- updateCardStatus(externalCardId: string, status: Status): Promise<ApiResponse>;
26
- updateCardProgram(externalCardId: string, programId: string): Promise<ApiResponse>;
27
- orderPhysicalCard(externalCardId: string): Promise<ApiResponse>;
28
- getCardsByExternalUserId(externalUserId: string): Promise<ApiResponse>;
29
- generateCardsInBatch(request: any): Promise<ApiResponse>;
30
- getCardBatch(batchId: string): Promise<ApiResponse>;
31
- deleteCardBatch(batchId: string): Promise<ApiResponse>;
32
- getStatementsList(externalCardId: string): Promise<ApiResponse>;
33
- getStatementDocument(statementId: string): Promise<ApiResponse>;
34
- getTransactionHistory(externalCardId: string, params: Record<string, string>): Promise<ApiResponse>;
35
- getTransactionDetails(externalTransactionId: string): Promise<ApiResponse>;
14
+ constructor(httpRequest: IHttpRequest, _invokerUtils: InvokerUtils);
15
+ healthcheck(): Promise<FiadoApiResponse<HealthcheckResponse>>;
16
+ createCardholder(request: CreateBankAccountUserRequest): Promise<FiadoApiResponse<CreateBankAccountUserResponse>>;
17
+ getCardholder(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
18
+ updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
19
+ deleteCardholder(externalUserId: string): Promise<FiadoApiResponse<null>>;
20
+ getOOWQuestions(externalUserId: string): Promise<FiadoApiResponse<OOWQuestionsResponse[]>>;
21
+ submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
22
+ uploadDocuments(externalUserId: string, request: CentralPaymentsDocumentUploadRequest): Promise<FiadoApiResponse<null>>;
23
+ setCardPin(request: UpdateBankAccountCardRequest): Promise<FiadoApiResponse<UpdateBankAccountCardResponse>>;
24
+ getCardInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
25
+ getCardSensitiveInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
26
+ activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<FiadoApiResponse<ActivateBankAccountCardResponse>>;
27
+ getCardBalance(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardBalanceResponse>>;
28
+ updateCardStatus(externalCardId: string, status: Status): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
29
+ updateCardProgram(externalCardId: string, programId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
30
+ orderPhysicalCard(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
31
+ getCardsByExternalUserId(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
32
+ generateCardsInBatch(request: CardBatchRequest): Promise<FiadoApiResponse<CardBatchResponse>>;
33
+ getCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
34
+ deleteCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
35
+ getStatementsList(externalCardId: string): Promise<FiadoApiResponse<CardStatementListResponse[]>>;
36
+ getStatementDocument(statementId: string): Promise<FiadoApiResponse<StatementDocumentResponse>>;
37
+ getTransactionHistory(externalCardId: string, params: CentralPaymentsQueryParams): Promise<FiadoApiResponse<TransactionListResponse<CentralPaymentsTransactionItem>>>;
38
+ getTransactionDetails(externalTransactionId: string): Promise<FiadoApiResponse<CentralPaymentsTransactionItem>>;
36
39
  }
@@ -14,9 +14,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CentralPaymentsConnectorApi = void 0;
16
16
  const inversify_1 = require("inversify");
17
+ const InvokerUtils_1 = require("../utils/InvokerUtils");
17
18
  let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
18
- constructor(httpRequest) {
19
+ constructor(httpRequest, _invokerUtils) {
19
20
  this.httpRequest = httpRequest;
21
+ this._invokerUtils = _invokerUtils;
20
22
  this.baseUrl = process.env.CENTRAL_PAYMENTS_LAMBDA_URL || "";
21
23
  }
22
24
  /* HEALTHCHECK */
@@ -37,6 +39,10 @@ let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
37
39
  const url = `${this.baseUrl}/cardholders/${externalUserId}`;
38
40
  return await this.httpRequest.put(url, request);
39
41
  }
42
+ async deleteCardholder(externalUserId) {
43
+ const url = `${this.baseUrl}/cardholders/${externalUserId}`;
44
+ return await this.httpRequest.delete(url);
45
+ }
40
46
  /* KYC DOCUMENTS */
41
47
  async getOOWQuestions(externalUserId) {
42
48
  const url = `${this.baseUrl}/kyc/${externalUserId}/oow/questions`;
@@ -48,12 +54,12 @@ let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
48
54
  }
49
55
  async uploadDocuments(externalUserId, request) {
50
56
  const url = `${this.baseUrl}/kyc/${externalUserId}/documents/upload`;
51
- return await this.httpRequest.post(url);
57
+ return await this.httpRequest.post(url, request);
52
58
  }
53
59
  /* CARDS */
54
60
  async setCardPin(request) {
55
61
  const url = `${this.baseUrl}/cards/pin/change`;
56
- return await this.httpRequest.put(url, request);
62
+ return await this.httpRequest.post(url, request);
57
63
  }
58
64
  async getCardInformation(externalCardId) {
59
65
  const url = `${this.baseUrl}/cards/${externalCardId}`;
@@ -76,11 +82,11 @@ let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
76
82
  return await this.httpRequest.put(url);
77
83
  }
78
84
  async updateCardProgram(externalCardId, programId) {
79
- const url = `${this.baseUrl}/cards/${externalCardId}/program/${programId}`;
85
+ const url = `${this.baseUrl}/cards/${externalCardId}/programs/${programId}`;
80
86
  return await this.httpRequest.put(url);
81
87
  }
82
- async orderPhysicalCard(externalCardId) {
83
- const url = `${this.baseUrl}/cards/${externalCardId}/physical`;
88
+ async orderPhysicalCard(externalUserId) {
89
+ const url = `${this.baseUrl}/cards/physical/order/${externalUserId}`;
84
90
  return await this.httpRequest.put(url);
85
91
  }
86
92
  async getCardsByExternalUserId(externalUserId) {
@@ -101,7 +107,7 @@ let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
101
107
  }
102
108
  /* STATEMENTS */
103
109
  async getStatementsList(externalCardId) {
104
- const url = `${this.baseUrl}/statements/${externalCardId}`;
110
+ const url = `${this.baseUrl}/statements/cards/${externalCardId}`;
105
111
  return await this.httpRequest.get(url);
106
112
  }
107
113
  async getStatementDocument(statementId) {
@@ -110,7 +116,8 @@ let CentralPaymentsConnectorApi = class CentralPaymentsConnectorApi {
110
116
  }
111
117
  /* TRANSACTIONS */
112
118
  async getTransactionHistory(externalCardId, params) {
113
- const url = `${this.baseUrl}/transactions/${externalCardId}?${new URLSearchParams(params)}`;
119
+ const queryParams = this._invokerUtils.toQueryStringParameters(params);
120
+ const url = `${this.baseUrl}/transactions/history/${externalCardId}?${queryParams}`;
114
121
  return await this.httpRequest.get(url);
115
122
  }
116
123
  async getTransactionDetails(externalTransactionId) {
@@ -122,5 +129,6 @@ exports.CentralPaymentsConnectorApi = CentralPaymentsConnectorApi;
122
129
  exports.CentralPaymentsConnectorApi = CentralPaymentsConnectorApi = __decorate([
123
130
  (0, inversify_1.injectable)(),
124
131
  __param(0, (0, inversify_1.inject)("IHttpRequest")),
125
- __metadata("design:paramtypes", [Object])
132
+ __param(1, (0, inversify_1.inject)("InvokerUtils")),
133
+ __metadata("design:paramtypes", [Object, InvokerUtils_1.InvokerUtils])
126
134
  ], CentralPaymentsConnectorApi);
@@ -1,31 +1,32 @@
1
- import { ApiResponse } from "@fiado/gateway-adapter";
2
- import { CreateBankAccountUserRequest, UpdateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
3
- import { SubmitOOWQuestionAnswersRequest } from "@fiado/type-kit/bin/centralPayments";
4
- import { UploadDocumentRequest } from "@fiado/type-kit/bin/identity";
5
- import { ActivateBankAccountCardRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
1
+ import { CreateBankAccountUserRequest, CreateBankAccountUserResponse, GetBankAccountUserResponse, UpdateBankAccountUserRequest } from "@fiado/type-kit/bin/account";
2
+ import { CentralPaymentsDocumentUploadRequest, HealthcheckResponse, OOWQuestionsResponse, SubmitOOWQuestionAnswersRequest } from "@fiado/type-kit/bin/centralPayments";
3
+ import { ActivateBankAccountCardRequest, ActivateBankAccountCardResponse, CardBatchRequest, CardBatchResponse, CardStatementListResponse, GetBankAccountCardBalanceResponse, GetBankAccountCardResponse, StatementDocumentResponse, UpdateBankAccountCardRequest, UpdateBankAccountCardResponse } from "@fiado/type-kit/bin/card";
6
4
  import { Status } from "@fiado/type-kit/bin/directory/enums/Status";
5
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
6
+ import { CentralPaymentsQueryParams, CentralPaymentsTransactionItem, TransactionListResponse } from "@fiado/type-kit/bin/transaction";
7
7
  export interface ICentralPaymentsConnectorApi {
8
- healthcheck(): Promise<ApiResponse>;
9
- createCardholder(request: CreateBankAccountUserRequest): Promise<ApiResponse>;
10
- getCardholder(externalUserId: string): Promise<ApiResponse>;
11
- updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<ApiResponse>;
12
- getOOWQuestions(externalUserId: string): Promise<ApiResponse>;
13
- submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<ApiResponse>;
14
- uploadDocuments(externalUserId: string, request: UploadDocumentRequest): Promise<ApiResponse>;
15
- setCardPin(request: UpdateBankAccountCardRequest): Promise<ApiResponse>;
16
- getCardInformation(externalCardId: string): Promise<ApiResponse>;
17
- getCardSensitiveInformation(externalCardId: string): Promise<ApiResponse>;
18
- activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<ApiResponse>;
19
- getCardBalance(externalCardId: string): Promise<ApiResponse>;
20
- updateCardStatus(externalCardId: string, status: Status): Promise<ApiResponse>;
21
- updateCardProgram(externalCardId: string, programId: string): Promise<ApiResponse>;
22
- orderPhysicalCard(externalCardId: string): Promise<ApiResponse>;
23
- getCardsByExternalUserId(externalUserId: string): Promise<ApiResponse>;
24
- generateCardsInBatch(request: any): Promise<ApiResponse>;
25
- getCardBatch(batchId: string): Promise<ApiResponse>;
26
- deleteCardBatch(batchId: string): Promise<ApiResponse>;
27
- getStatementsList(externalCardId: string): Promise<ApiResponse>;
28
- getStatementDocument(statementId: string): Promise<ApiResponse>;
29
- getTransactionHistory(externalCardId: string, params: Record<string, string>): Promise<ApiResponse>;
30
- getTransactionDetails(externalTransactionId: string): Promise<ApiResponse>;
8
+ healthcheck(): Promise<FiadoApiResponse<HealthcheckResponse>>;
9
+ createCardholder(request: CreateBankAccountUserRequest): Promise<FiadoApiResponse<CreateBankAccountUserResponse>>;
10
+ getCardholder(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
11
+ updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
12
+ deleteCardholder(externalUserId: string): Promise<FiadoApiResponse<null>>;
13
+ getOOWQuestions(externalUserId: string): Promise<FiadoApiResponse<OOWQuestionsResponse[]>>;
14
+ submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
15
+ uploadDocuments(externalUserId: string, request: CentralPaymentsDocumentUploadRequest): Promise<FiadoApiResponse<null>>;
16
+ setCardPin(request: UpdateBankAccountCardRequest): Promise<FiadoApiResponse<UpdateBankAccountCardResponse>>;
17
+ getCardInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
18
+ getCardSensitiveInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
19
+ activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<FiadoApiResponse<ActivateBankAccountCardResponse>>;
20
+ getCardBalance(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardBalanceResponse>>;
21
+ updateCardStatus(externalCardId: string, status: Status): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
22
+ updateCardProgram(externalCardId: string, programId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
23
+ orderPhysicalCard(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
24
+ getCardsByExternalUserId(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
25
+ generateCardsInBatch(request: CardBatchRequest): Promise<FiadoApiResponse<CardBatchResponse>>;
26
+ getCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
27
+ deleteCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
28
+ getStatementsList(externalCardId: string): Promise<FiadoApiResponse<CardStatementListResponse[]>>;
29
+ getStatementDocument(statementId: string): Promise<FiadoApiResponse<StatementDocumentResponse>>;
30
+ getTransactionHistory(externalCardId: string, params: CentralPaymentsQueryParams): Promise<FiadoApiResponse<TransactionListResponse<CentralPaymentsTransactionItem>>>;
31
+ getTransactionDetails(externalTransactionId: string): Promise<FiadoApiResponse<CentralPaymentsTransactionItem>>;
31
32
  }
@@ -51,7 +51,12 @@ const device_1 = require("./device");
51
51
  const observations_1 = require("./observations");
52
52
  const CognitoConnectorV2_1 = __importDefault(require("./cognitoConnector/CognitoConnectorV2"));
53
53
  const centralPayments_1 = require("./centralPayments");
54
+ const InvokerUtils_1 = require("./utils/InvokerUtils");
55
+ const service_business_1 = require("./service-business");
54
56
  exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
57
+ // UTILS bindings
58
+ bind("InvokerUtils").to(InvokerUtils_1.InvokerUtils);
59
+ // API invoker bindings
55
60
  bind("IDirectoryApi").to(directory_1.DirectoryApi);
56
61
  bind("IIdentityApi").to(identity_1.IdentityApi);
57
62
  bind("IAddressApi").to(address_1.AddressApi);
@@ -98,4 +103,5 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
98
103
  bind("IDeviceApi").to(device_1.DeviceApi);
99
104
  bind("IObservationsApi").to(observations_1.ObservationsApi);
100
105
  bind("ICentralPaymentsConnectorApi").to(centralPayments_1.CentralPaymentsConnectorApi);
106
+ bind("IServiceApi").to(service_business_1.ServiceApi);
101
107
  });
package/bin/index.d.ts CHANGED
@@ -39,3 +39,4 @@ export * from "./blacklist";
39
39
  export * from "./legalDocument";
40
40
  export * from "./device";
41
41
  export * from "./observations";
42
+ export * from "./service-business";
package/bin/index.js CHANGED
@@ -55,3 +55,4 @@ __exportStar(require("./blacklist"), exports);
55
55
  __exportStar(require("./legalDocument"), exports);
56
56
  __exportStar(require("./device"), exports);
57
57
  __exportStar(require("./observations"), exports);
58
+ __exportStar(require("./service-business"), exports);
@@ -0,0 +1,27 @@
1
+ import { IHttpRequest } from "@fiado/http-client";
2
+ import { IServiceApi } from "./interfaces/IServiceApi";
3
+ import { ServiceFlowEnum, ServiceMembershipStatusEnum, UpdateServiceMembershipRequest } from "@fiado/type-kit/bin/services";
4
+ import { ServiceCompanyEnum } from "@fiado/type-kit/bin/services/enums/ServiceCompanyEnum";
5
+ export declare class ServiceApi implements IServiceApi {
6
+ private httpRequest;
7
+ private readonly baseUrl;
8
+ constructor(httpRequest: IHttpRequest);
9
+ getServices(params: {
10
+ pageSize?: number;
11
+ index?: string;
12
+ company?: ServiceCompanyEnum;
13
+ flow?: ServiceFlowEnum;
14
+ }): Promise<void>;
15
+ getServiceMembershipsByDirectoryId(params: {
16
+ directoryId: string;
17
+ pageSize?: number;
18
+ index?: string;
19
+ }): Promise<void>;
20
+ getServiceMembershipsByDirectoryIdAndStatus(params: {
21
+ pageSize?: number;
22
+ index?: string;
23
+ directoryId: string;
24
+ status: ServiceMembershipStatusEnum;
25
+ }): Promise<void>;
26
+ updateServiceMembership(serviceMembershipId: string, params: UpdateServiceMembershipRequest): Promise<void>;
27
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ServiceApi = void 0;
19
+ const inversify_1 = require("inversify");
20
+ const dotenv_1 = __importDefault(require("dotenv"));
21
+ dotenv_1.default.config();
22
+ let ServiceApi = class ServiceApi {
23
+ constructor(httpRequest) {
24
+ this.httpRequest = httpRequest;
25
+ this.baseUrl = process.env.SERVICE_BUSINESS_URL || "";
26
+ }
27
+ async getServices(params) {
28
+ const url = `${this.baseUrl}services`;
29
+ const queryParameters = [];
30
+ if (params.pageSize)
31
+ queryParameters.push(`pageSize=${params.pageSize}`);
32
+ if (params.index)
33
+ queryParameters.push(`index=${params.index}`);
34
+ if (params.company)
35
+ queryParameters.push(`status=${params.company}`);
36
+ if (params.flow)
37
+ queryParameters.push(`flow=${params.flow}`);
38
+ if (queryParameters.length > 0) {
39
+ url.concat(`?${queryParameters.join('&')}`);
40
+ }
41
+ return await this.httpRequest.get(url);
42
+ }
43
+ async getServiceMembershipsByDirectoryId(params) {
44
+ const url = `${this.baseUrl}services?directoryId=${params.directoryId}`;
45
+ const queryParameters = [];
46
+ if (params.pageSize)
47
+ queryParameters.push(`pageSize=${params.pageSize}`);
48
+ if (params.index)
49
+ queryParameters.push(`index=${params.index}`);
50
+ if (queryParameters.length > 0) {
51
+ url.concat(`${queryParameters.join('&')}`);
52
+ }
53
+ return await this.httpRequest.get(url);
54
+ }
55
+ async getServiceMembershipsByDirectoryIdAndStatus(params) {
56
+ const url = `${this.baseUrl}services/memberships/status/${params.status}?directoryId=${params.directoryId}`;
57
+ const queryParameters = [];
58
+ if (params.pageSize)
59
+ queryParameters.push(`pageSize=${params.pageSize}`);
60
+ if (params.index)
61
+ queryParameters.push(`index=${params.index}`);
62
+ if (queryParameters.length > 0) {
63
+ url.concat(`${queryParameters.join('&')}`);
64
+ }
65
+ return await this.httpRequest.get(url);
66
+ }
67
+ async updateServiceMembership(serviceMembershipId, params) {
68
+ const url = `${this.baseUrl}services/memberships/${serviceMembershipId}`;
69
+ return await this.httpRequest.put(url, params);
70
+ }
71
+ };
72
+ exports.ServiceApi = ServiceApi;
73
+ exports.ServiceApi = ServiceApi = __decorate([
74
+ (0, inversify_1.injectable)(),
75
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
76
+ __metadata("design:paramtypes", [Object])
77
+ ], ServiceApi);
@@ -0,0 +1,2 @@
1
+ export * from './interfaces/IServiceApi';
2
+ export * from './ServiceApi';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces/IServiceApi"), exports);
18
+ __exportStar(require("./ServiceApi"), exports);
@@ -0,0 +1,49 @@
1
+ import { ServiceFlowEnum, ServiceMembershipStatusEnum, UpdateServiceMembershipRequest } from "@fiado/type-kit/bin/services";
2
+ import { ServiceCompanyEnum } from "@fiado/type-kit/bin/services/enums/ServiceCompanyEnum";
3
+ /**
4
+ * Interfaz que define las operaciones que se pueden realizar en el servicio de black list.
5
+ */
6
+ export interface IServiceApi {
7
+ /**
8
+ * Consulta de membresias
9
+ * @param value valor del parametro.
10
+ * @returns Una promesa que resuelve a void.
11
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
12
+ */
13
+ getServices(params: {
14
+ pageSize?: number;
15
+ index?: string;
16
+ company?: ServiceCompanyEnum;
17
+ flow?: ServiceFlowEnum;
18
+ }): Promise<void>;
19
+ /**
20
+ * Consulta de membresias de un directorio dado un directoryId
21
+ * @param value valor del parametro.
22
+ * @returns Una promesa que resuelve a void.
23
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
24
+ */
25
+ getServiceMembershipsByDirectoryId(params: {
26
+ directoryId: string;
27
+ pageSize?: number;
28
+ index?: string;
29
+ }): Promise<void>;
30
+ /**
31
+ * Consulta de membresias de un directorio dado un directoryId y un status
32
+ * @param value valor del parametro.
33
+ * @returns Una promesa que resuelve a void.
34
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
35
+ */
36
+ getServiceMembershipsByDirectoryIdAndStatus(params: {
37
+ pageSize?: number;
38
+ index?: string;
39
+ directoryId: string;
40
+ status: ServiceMembershipStatusEnum;
41
+ }): Promise<void>;
42
+ /**
43
+ * Actualizar una membresia de un servicio
44
+ * @param value valor del parametro.
45
+ * @returns Una promesa que resuelve a void.
46
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
47
+ */
48
+ updateServiceMembership(serviceMembershipId: string, params: UpdateServiceMembershipRequest): Promise<void>;
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export declare class InvokerUtils {
2
+ constructor();
3
+ toQueryStringParameters(object: any): string;
4
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InvokerUtils = void 0;
13
+ const inversify_1 = require("inversify");
14
+ let InvokerUtils = class InvokerUtils {
15
+ constructor() {
16
+ }
17
+ toQueryStringParameters(object) {
18
+ const records = Object.entries(object).reduce((acc, [key, value]) => {
19
+ if (Array.isArray(value)) {
20
+ acc[key] = value.join(','); // Convierte arrays a una cadena separada por comas
21
+ }
22
+ else {
23
+ acc[key] = String(value); // Convierte todos los demás valores a string
24
+ }
25
+ return acc;
26
+ }, {});
27
+ return new URLSearchParams(records).toString();
28
+ }
29
+ };
30
+ exports.InvokerUtils = InvokerUtils;
31
+ exports.InvokerUtils = InvokerUtils = __decorate([
32
+ (0, inversify_1.injectable)(),
33
+ __metadata("design:paramtypes", [])
34
+ ], InvokerUtils);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "1.2.42",
3
+ "version": "1.2.44",
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.2",
18
18
  "@fiado/logger": "^1.0.3",
19
- "@fiado/type-kit": "^1.7.5",
19
+ "@fiado/type-kit": "^1.8.15",
20
20
  "dotenv": "^16.4.5",
21
21
  "inversify": "^6.0.2",
22
22
  "reflect-metadata": "^0.2.1",
@@ -1,141 +1,172 @@
1
1
  import {ICentralPaymentsConnectorApi} from "./interfaces/ICentralPaymentsConnectorApi";
2
2
  import {inject, injectable} from "inversify";
3
3
  import {IHttpRequest} from "@fiado/http-client";
4
- import {ApiResponse} from "@fiado/gateway-adapter";
5
- import {CreateBankAccountUserRequest, UpdateBankAccountUserRequest} from "@fiado/type-kit/bin/account";
6
- import {SubmitOOWQuestionAnswersRequest} from "@fiado/type-kit/bin/centralPayments";
7
- import {UploadDocumentRequest} from "@fiado/type-kit/bin/identity";
8
- import {ActivateBankAccountCardRequest, UpdateBankAccountCardRequest} from "@fiado/type-kit/bin/card";
4
+ import {
5
+ CreateBankAccountUserRequest,
6
+ CreateBankAccountUserResponse,
7
+ GetBankAccountUserResponse,
8
+ UpdateBankAccountUserRequest
9
+ } from "@fiado/type-kit/bin/account";
10
+ import {
11
+ CentralPaymentsDocumentUploadRequest,
12
+ HealthcheckResponse,
13
+ OOWQuestionsResponse,
14
+ SubmitOOWQuestionAnswersRequest
15
+ } from "@fiado/type-kit/bin/centralPayments";
16
+ import {
17
+ ActivateBankAccountCardRequest,
18
+ ActivateBankAccountCardResponse,
19
+ CardBatchRequest,
20
+ CardBatchResponse,
21
+ CardStatementListResponse,
22
+ GetBankAccountCardBalanceResponse,
23
+ GetBankAccountCardResponse,
24
+ StatementDocumentResponse,
25
+ UpdateBankAccountCardRequest,
26
+ UpdateBankAccountCardResponse
27
+ } from "@fiado/type-kit/bin/card";
9
28
  import {Status} from "@fiado/type-kit/bin/directory/enums/Status";
29
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
30
+ import {
31
+ CentralPaymentsQueryParams,
32
+ CentralPaymentsTransactionItem,
33
+ TransactionListResponse
34
+ } from "@fiado/type-kit/bin/transaction";
35
+ import {InvokerUtils} from "../utils/InvokerUtils";
10
36
 
11
37
  @injectable()
12
38
  export class CentralPaymentsConnectorApi implements ICentralPaymentsConnectorApi {
13
39
  private readonly baseUrl = process.env.CENTRAL_PAYMENTS_LAMBDA_URL || "";
14
40
 
15
41
  constructor(
16
- @inject("IHttpRequest") private readonly httpRequest: IHttpRequest
42
+ @inject("IHttpRequest") private readonly httpRequest: IHttpRequest,
43
+ @inject("InvokerUtils") private readonly _invokerUtils: InvokerUtils,
17
44
  ) {
18
45
  }
19
46
 
20
47
  /* HEALTHCHECK */
21
- async healthcheck(): Promise<ApiResponse> {
48
+ async healthcheck(): Promise<FiadoApiResponse<HealthcheckResponse>> {
22
49
  const url = `${this.baseUrl}/healthcheck`;
23
50
  return await this.httpRequest.get(url);
24
51
  }
25
52
 
26
53
  /* CARDHOLDERS */
27
- async createCardholder(request: CreateBankAccountUserRequest): Promise<ApiResponse> {
54
+ async createCardholder(request: CreateBankAccountUserRequest): Promise<FiadoApiResponse<CreateBankAccountUserResponse>> {
28
55
  const url = `${this.baseUrl}/cardholders`;
29
56
  return await this.httpRequest.post(url, request);
30
57
  }
31
58
 
32
- async getCardholder(externalUserId: string): Promise<ApiResponse> {
59
+ async getCardholder(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountUserResponse>> {
33
60
  const url = `${this.baseUrl}/cardholders/${externalUserId}`;
34
61
  return await this.httpRequest.get(url);
35
62
  }
36
63
 
37
- async updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<ApiResponse> {
64
+ async updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<FiadoApiResponse<GetBankAccountUserResponse>> {
38
65
  const url = `${this.baseUrl}/cardholders/${externalUserId}`;
39
66
  return await this.httpRequest.put(url, request);
40
67
  }
41
68
 
69
+ async deleteCardholder(externalUserId: string): Promise<FiadoApiResponse<null>> {
70
+ const url = `${this.baseUrl}/cardholders/${externalUserId}`;
71
+ return await this.httpRequest.delete(url);
72
+ }
73
+
42
74
  /* KYC DOCUMENTS */
43
- async getOOWQuestions(externalUserId: string): Promise<ApiResponse> {
75
+ async getOOWQuestions(externalUserId: string): Promise<FiadoApiResponse<OOWQuestionsResponse[]>> {
44
76
  const url = `${this.baseUrl}/kyc/${externalUserId}/oow/questions`;
45
77
  return await this.httpRequest.get(url);
46
78
  }
47
79
 
48
- async submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<ApiResponse> {
80
+ async submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<FiadoApiResponse<GetBankAccountUserResponse>> {
49
81
  const url = `${this.baseUrl}/kyc/${externalUserId}/oow/questions`;
50
82
  return await this.httpRequest.post(url, request);
51
83
  }
52
84
 
53
- async uploadDocuments(externalUserId: string, request: UploadDocumentRequest): Promise<ApiResponse> {
85
+ async uploadDocuments(externalUserId: string, request: CentralPaymentsDocumentUploadRequest): Promise<FiadoApiResponse<null>> {
54
86
  const url = `${this.baseUrl}/kyc/${externalUserId}/documents/upload`;
55
- return await this.httpRequest.post(url);
87
+ return await this.httpRequest.post(url, request);
56
88
  }
57
89
 
58
90
  /* CARDS */
59
- async setCardPin(request: UpdateBankAccountCardRequest): Promise<ApiResponse> {
91
+ async setCardPin(request: UpdateBankAccountCardRequest): Promise<FiadoApiResponse<UpdateBankAccountCardResponse>> {
60
92
  const url = `${this.baseUrl}/cards/pin/change`;
61
- return await this.httpRequest.put(url, request);
93
+ return await this.httpRequest.post(url, request);
62
94
  }
63
95
 
64
- async getCardInformation(externalCardId: string): Promise<ApiResponse> {
96
+ async getCardInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
65
97
  const url = `${this.baseUrl}/cards/${externalCardId}`;
66
98
  return await this.httpRequest.get(url);
67
99
  }
68
100
 
69
- async getCardSensitiveInformation(externalCardId: string): Promise<ApiResponse> {
101
+ async getCardSensitiveInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
70
102
  const url = `${this.baseUrl}/cards/${externalCardId}/sensitive`;
71
103
  return await this.httpRequest.get(url);
72
104
  }
73
105
 
74
- async activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<ApiResponse> {
106
+ async activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<FiadoApiResponse<ActivateBankAccountCardResponse>> {
75
107
  const url = `${this.baseUrl}/cards/${externalCardId}/activate`;
76
108
  return await this.httpRequest.post(url, request);
77
109
  }
78
110
 
79
- async getCardBalance(externalCardId: string): Promise<ApiResponse> {
111
+ async getCardBalance(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardBalanceResponse>> {
80
112
  const url = `${this.baseUrl}/cards/${externalCardId}/balance`;
81
113
  return await this.httpRequest.get(url);
82
114
  }
83
115
 
84
- async updateCardStatus(externalCardId: string, status: Status): Promise<ApiResponse> {
116
+ async updateCardStatus(externalCardId: string, status: Status): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
85
117
  const url = `${this.baseUrl}/cards/${externalCardId}/status/${status}`;
86
118
  return await this.httpRequest.put(url);
87
119
  }
88
120
 
89
- async updateCardProgram(externalCardId: string, programId: string): Promise<ApiResponse> {
90
- const url = `${this.baseUrl}/cards/${externalCardId}/program/${programId}`;
121
+ async updateCardProgram(externalCardId: string, programId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
122
+ const url = `${this.baseUrl}/cards/${externalCardId}/programs/${programId}`;
91
123
  return await this.httpRequest.put(url);
92
124
  }
93
125
 
94
- async orderPhysicalCard(externalCardId: string): Promise<ApiResponse> {
95
- const url = `${this.baseUrl}/cards/${externalCardId}/physical`;
126
+ async orderPhysicalCard(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
127
+ const url = `${this.baseUrl}/cards/physical/order/${externalUserId}`;
96
128
  return await this.httpRequest.put(url);
97
129
  }
98
130
 
99
- async getCardsByExternalUserId(externalUserId: string): Promise<ApiResponse> {
131
+ async getCardsByExternalUserId(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>> {
100
132
  const url = `${this.baseUrl}/cards/cardholders/${externalUserId}`;
101
133
  return await this.httpRequest.get(url);
102
134
  }
103
135
 
104
- async generateCardsInBatch(request: any): Promise<ApiResponse> {
136
+ async generateCardsInBatch(request: CardBatchRequest): Promise<FiadoApiResponse<CardBatchResponse>> {
105
137
  const url = `${this.baseUrl}/cards/batch`;
106
138
  return await this.httpRequest.post(url, request);
107
139
  }
108
140
 
109
- async getCardBatch(batchId: string): Promise<ApiResponse> {
141
+ async getCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>> {
110
142
  const url = `${this.baseUrl}/cards/batch/${batchId}`;
111
143
  return await this.httpRequest.get(url);
112
144
  }
113
145
 
114
- async deleteCardBatch(batchId: string): Promise<ApiResponse> {
146
+ async deleteCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>> {
115
147
  const url = `${this.baseUrl}/cards/batch/${batchId}`;
116
148
  return await this.httpRequest.delete(url);
117
149
  }
118
150
 
119
151
  /* STATEMENTS */
120
- async getStatementsList(externalCardId: string): Promise<ApiResponse> {
121
- const url = `${this.baseUrl}/statements/${externalCardId}`;
152
+ async getStatementsList(externalCardId: string): Promise<FiadoApiResponse<CardStatementListResponse[]>> {
153
+ const url = `${this.baseUrl}/statements/cards/${externalCardId}`;
122
154
  return await this.httpRequest.get(url);
123
155
  }
124
156
 
125
- async getStatementDocument(statementId: string): Promise<ApiResponse> {
157
+ async getStatementDocument(statementId: string): Promise<FiadoApiResponse<StatementDocumentResponse>> {
126
158
  const url = `${this.baseUrl}/statements/document-url/${statementId}`;
127
159
  return await this.httpRequest.get(url);
128
160
  }
129
161
 
130
162
  /* TRANSACTIONS */
131
- async getTransactionHistory(externalCardId: string,
132
- params: Record<string, string>
133
- ): Promise<ApiResponse> {
134
- const url = `${this.baseUrl}/transactions/${externalCardId}?${new URLSearchParams(params)}`;
163
+ async getTransactionHistory(externalCardId: string, params: CentralPaymentsQueryParams): Promise<FiadoApiResponse<TransactionListResponse<CentralPaymentsTransactionItem>>> {
164
+ const queryParams: string = this._invokerUtils.toQueryStringParameters(params);
165
+ const url = `${this.baseUrl}/transactions/history/${externalCardId}?${queryParams}`;
135
166
  return await this.httpRequest.get(url);
136
167
  }
137
168
 
138
- async getTransactionDetails(externalTransactionId: string): Promise<ApiResponse> {
169
+ async getTransactionDetails(externalTransactionId: string): Promise<FiadoApiResponse<CentralPaymentsTransactionItem>> {
139
170
  const url = `${this.baseUrl}/transactions/${externalTransactionId}`;
140
171
  return await this.httpRequest.get(url);
141
172
  }
@@ -1,54 +1,81 @@
1
- import {ApiResponse} from "@fiado/gateway-adapter";
2
- import {CreateBankAccountUserRequest, UpdateBankAccountUserRequest} from "@fiado/type-kit/bin/account";
3
- import {SubmitOOWQuestionAnswersRequest} from "@fiado/type-kit/bin/centralPayments";
4
- import {UploadDocumentRequest} from "@fiado/type-kit/bin/identity";
5
- import {ActivateBankAccountCardRequest, UpdateBankAccountCardRequest} from "@fiado/type-kit/bin/card";
1
+ import {
2
+ CreateBankAccountUserRequest,
3
+ CreateBankAccountUserResponse,
4
+ GetBankAccountUserResponse,
5
+ UpdateBankAccountUserRequest
6
+ } from "@fiado/type-kit/bin/account";
7
+ import {
8
+ CentralPaymentsDocumentUploadRequest,
9
+ HealthcheckResponse,
10
+ OOWQuestionsResponse,
11
+ SubmitOOWQuestionAnswersRequest
12
+ } from "@fiado/type-kit/bin/centralPayments";
13
+ import {
14
+ ActivateBankAccountCardRequest,
15
+ ActivateBankAccountCardResponse,
16
+ CardBatchRequest,
17
+ CardBatchResponse,
18
+ CardStatementListResponse,
19
+ GetBankAccountCardBalanceResponse,
20
+ GetBankAccountCardResponse,
21
+ StatementDocumentResponse,
22
+ UpdateBankAccountCardRequest,
23
+ UpdateBankAccountCardResponse
24
+ } from "@fiado/type-kit/bin/card";
6
25
  import {Status} from "@fiado/type-kit/bin/directory/enums/Status";
26
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
27
+ import {
28
+ CentralPaymentsQueryParams,
29
+ CentralPaymentsTransactionItem,
30
+ TransactionListResponse
31
+ } from "@fiado/type-kit/bin/transaction";
7
32
 
8
33
  export interface ICentralPaymentsConnectorApi {
9
- healthcheck(): Promise<ApiResponse>;
34
+ healthcheck(): Promise<FiadoApiResponse<HealthcheckResponse>>;
10
35
 
11
- createCardholder(request: CreateBankAccountUserRequest): Promise<ApiResponse>;
36
+ createCardholder(request: CreateBankAccountUserRequest): Promise<FiadoApiResponse<CreateBankAccountUserResponse>>;
12
37
 
13
- getCardholder(externalUserId: string): Promise<ApiResponse>;
38
+ getCardholder(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
14
39
 
15
- updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<ApiResponse>;
40
+ updateCardholder(externalUserId: string, request: UpdateBankAccountUserRequest): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
16
41
 
17
- getOOWQuestions(externalUserId: string): Promise<ApiResponse>;
42
+ deleteCardholder(externalUserId: string): Promise<FiadoApiResponse<null>>;
18
43
 
19
- submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<ApiResponse>;
44
+ getOOWQuestions(externalUserId: string): Promise<FiadoApiResponse<OOWQuestionsResponse[]>>;
20
45
 
21
- uploadDocuments(externalUserId: string, request: UploadDocumentRequest): Promise<ApiResponse>;
46
+ submitOOWQuestionAnswers(externalUserId: string, request: SubmitOOWQuestionAnswersRequest[]): Promise<FiadoApiResponse<GetBankAccountUserResponse>>;
22
47
 
23
- setCardPin(request: UpdateBankAccountCardRequest): Promise<ApiResponse>;
48
+ uploadDocuments(externalUserId: string, request: CentralPaymentsDocumentUploadRequest): Promise<FiadoApiResponse<null>>;
24
49
 
25
- getCardInformation(externalCardId: string): Promise<ApiResponse>;
50
+ setCardPin(request: UpdateBankAccountCardRequest): Promise<FiadoApiResponse<UpdateBankAccountCardResponse>>;
26
51
 
27
- getCardSensitiveInformation(externalCardId: string): Promise<ApiResponse>;
52
+ getCardInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
28
53
 
29
- activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<ApiResponse>;
54
+ getCardSensitiveInformation(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
30
55
 
31
- getCardBalance(externalCardId: string): Promise<ApiResponse>;
56
+ activateCard(externalCardId: string, request: ActivateBankAccountCardRequest): Promise<FiadoApiResponse<ActivateBankAccountCardResponse>>;
32
57
 
33
- updateCardStatus(externalCardId: string, status: Status): Promise<ApiResponse>;
58
+ getCardBalance(externalCardId: string): Promise<FiadoApiResponse<GetBankAccountCardBalanceResponse>>;
34
59
 
35
- updateCardProgram(externalCardId: string, programId: string): Promise<ApiResponse>
60
+ updateCardStatus(externalCardId: string, status: Status): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
36
61
 
37
- orderPhysicalCard(externalCardId: string): Promise<ApiResponse>;
62
+ updateCardProgram(externalCardId: string, programId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
38
63
 
39
- getCardsByExternalUserId(externalUserId: string): Promise<ApiResponse>;
64
+ orderPhysicalCard(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
40
65
 
41
- generateCardsInBatch(request: any): Promise<ApiResponse>;
66
+ getCardsByExternalUserId(externalUserId: string): Promise<FiadoApiResponse<GetBankAccountCardResponse>>;
42
67
 
43
- getCardBatch(batchId: string): Promise<ApiResponse>;
68
+ generateCardsInBatch(request: CardBatchRequest): Promise<FiadoApiResponse<CardBatchResponse>>;
44
69
 
45
- deleteCardBatch(batchId: string): Promise<ApiResponse>;
70
+ getCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
46
71
 
47
- getStatementsList(externalCardId: string): Promise<ApiResponse>;
72
+ deleteCardBatch(batchId: string): Promise<FiadoApiResponse<CardBatchResponse>>;
48
73
 
49
- getStatementDocument(statementId: string): Promise<ApiResponse>;
74
+ getStatementsList(externalCardId: string): Promise<FiadoApiResponse<CardStatementListResponse[]>>;
50
75
 
51
- getTransactionHistory(externalCardId: string, params: Record<string, string>): Promise<ApiResponse>;
76
+ getStatementDocument(statementId: string): Promise<FiadoApiResponse<StatementDocumentResponse>>;
52
77
 
53
- getTransactionDetails(externalTransactionId: string): Promise<ApiResponse>;
78
+ getTransactionHistory(externalCardId: string, params: CentralPaymentsQueryParams): Promise<FiadoApiResponse<TransactionListResponse<CentralPaymentsTransactionItem>>>;
79
+
80
+ getTransactionDetails(externalTransactionId: string): Promise<FiadoApiResponse<CentralPaymentsTransactionItem>>;
54
81
  }
@@ -44,26 +44,37 @@ import TransactionProcessorApi from "./transactionProcessor/api/TransactionProce
44
44
  import {ITransactionProcessorApi} from "./transactionProcessor";
45
45
  import ActivityPublisher from "./activity-business/queue/ActivityPublisher";
46
46
  import RiskProfileApi from "./riskProfile/api/RiskProfileApi";
47
- import {IRiskProfileApi, ITransactionAlarmPublisher, ITransactionAlertApi, TransactionAlarmPublisher} from "./riskProfile";
47
+ import {
48
+ IRiskProfileApi,
49
+ ITransactionAlarmPublisher,
50
+ ITransactionAlertApi,
51
+ TransactionAlarmPublisher
52
+ } from "./riskProfile";
48
53
  import {ContactInformationApi, IContactInformationApi} from "./contactInformation";
49
54
  import {FiadoMessagesApi, IFiadoMessagesApi} from "./fiadoMessages";
50
55
  import CnbvApi from "./cnbv-business/CnbvApi";
51
- import { ICnbvApi } from "./cnbv-business";
56
+ import {ICnbvApi} from "./cnbv-business";
52
57
  import TransactionApi from "./transaction/api/TransactionApi";
53
- import { IPomeloProcessorApi, PomeloProcessorApi } from "./pomeloProcessor";
54
- import { DisputesApi, IDisputesApi } from "./disputes";
58
+ import {IPomeloProcessorApi, PomeloProcessorApi} from "./pomeloProcessor";
59
+ import {DisputesApi, IDisputesApi} from "./disputes";
55
60
  import TransactionAlertApi from "./riskProfile/api/TransactionAlertApi";
56
- import { DirectoriesApi, IDirectoriesApi } from "./directories";
57
- import { ICognitoConnectorApi, ICognitoV2Api } from "./cognitoConnector";
61
+ import {DirectoriesApi, IDirectoriesApi} from "./directories";
62
+ import {ICognitoConnectorApi, ICognitoV2Api} from "./cognitoConnector";
58
63
  import CognitoConnectorApi from "./cognitoConnector/CognitoConnectorApi";
59
- import { IZendeskApi, ZendeskApi } from "./zendesk";
60
- import { BlackListApi, IBlackListApi } from "./blacklist";
61
- import { DeviceApi, IDeviceApi } from "./device";
62
- import { IObservationsApi, ObservationsApi } from "./observations";
64
+ import {IZendeskApi, ZendeskApi} from "./zendesk";
65
+ import {BlackListApi, IBlackListApi} from "./blacklist";
66
+ import {DeviceApi, IDeviceApi} from "./device";
67
+ import {IObservationsApi, ObservationsApi} from "./observations";
63
68
  import CognitoApi from "./cognitoConnector/CognitoConnectorV2";
64
69
  import {CentralPaymentsConnectorApi, ICentralPaymentsConnectorApi} from "./centralPayments";
70
+ import {InvokerUtils} from "./utils/InvokerUtils";
71
+ import { IServiceApi, ServiceApi } from "./service-business";
65
72
 
66
73
  export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
74
+ // UTILS bindings
75
+ bind<InvokerUtils>("InvokerUtils").to(InvokerUtils);
76
+
77
+ // API invoker bindings
67
78
  bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
68
79
  bind<IIdentityApi>("IIdentityApi").to(IdentityApi);
69
80
  bind<IAddressApi>("IAddressApi").to(AddressApi);
@@ -110,4 +121,6 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
110
121
  bind<IDeviceApi>("IDeviceApi").to(DeviceApi);
111
122
  bind<IObservationsApi>("IObservationsApi").to(ObservationsApi);
112
123
  bind<ICentralPaymentsConnectorApi>("ICentralPaymentsConnectorApi").to(CentralPaymentsConnectorApi);
124
+ bind<IServiceApi>("IServiceApi").to(ServiceApi);
125
+
113
126
  });
package/src/index.ts CHANGED
@@ -38,4 +38,5 @@ export * from "./zendesk";
38
38
  export * from "./blacklist";
39
39
  export * from "./legalDocument";
40
40
  export * from "./device";
41
- export * from "./observations";
41
+ export * from "./observations";
42
+ export * from "./service-business";
@@ -0,0 +1,61 @@
1
+ import { inject, injectable } from "inversify";
2
+ import { IHttpRequest } from "@fiado/http-client";
3
+ import dotenv from 'dotenv';
4
+ import { IServiceApi } from "./interfaces/IServiceApi";
5
+ import { ServiceFlowEnum, ServiceMembershipStatusEnum, UpdateServiceMembershipRequest } from "@fiado/type-kit/bin/services";
6
+ import { ServiceCompanyEnum } from "@fiado/type-kit/bin/services/enums/ServiceCompanyEnum";
7
+ dotenv.config();
8
+
9
+ @injectable()
10
+ export class ServiceApi implements IServiceApi {
11
+ private readonly baseUrl = process.env.SERVICE_BUSINESS_URL || "";
12
+
13
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) { }
14
+
15
+ async getServices(params: { pageSize?: number; index?: string; company?: ServiceCompanyEnum; flow?: ServiceFlowEnum; }): Promise<void> {
16
+ const url = `${this.baseUrl}services`;
17
+ const queryParameters = [];
18
+ if (params.pageSize) queryParameters.push(`pageSize=${params.pageSize}`);
19
+ if (params.index) queryParameters.push(`index=${params.index}`);
20
+ if (params.company) queryParameters.push(`status=${params.company}`);
21
+ if (params.flow) queryParameters.push(`flow=${params.flow}`);
22
+
23
+ if (queryParameters.length > 0) {
24
+ url.concat(`?${queryParameters.join('&')}`);
25
+ }
26
+
27
+ return await this.httpRequest.get(url);
28
+ }
29
+
30
+ async getServiceMembershipsByDirectoryId(params: { directoryId: string; pageSize?: number; index?: string; }): Promise<void> {
31
+ const url = `${this.baseUrl}services?directoryId=${params.directoryId}`;
32
+ const queryParameters = [];
33
+ if (params.pageSize) queryParameters.push(`pageSize=${params.pageSize}`);
34
+ if (params.index) queryParameters.push(`index=${params.index}`);
35
+
36
+ if (queryParameters.length > 0) {
37
+ url.concat(`${queryParameters.join('&')}`);
38
+ }
39
+
40
+ return await this.httpRequest.get(url);
41
+ }
42
+
43
+ async getServiceMembershipsByDirectoryIdAndStatus(params: { pageSize?: number; index?: string; directoryId: string; status: ServiceMembershipStatusEnum; }): Promise<void> {
44
+ const url = `${this.baseUrl}services/memberships/status/${params.status}?directoryId=${params.directoryId}`;
45
+
46
+ const queryParameters = [];
47
+ if (params.pageSize) queryParameters.push(`pageSize=${params.pageSize}`);
48
+ if (params.index) queryParameters.push(`index=${params.index}`);
49
+
50
+ if (queryParameters.length > 0) {
51
+ url.concat(`${queryParameters.join('&')}`);
52
+ }
53
+
54
+ return await this.httpRequest.get(url);
55
+ }
56
+ async updateServiceMembership(serviceMembershipId: string, params: UpdateServiceMembershipRequest): Promise<void> {
57
+ const url = `${this.baseUrl}services/memberships/${serviceMembershipId}`;
58
+ return await this.httpRequest.put(url, params);
59
+ }
60
+
61
+ }
@@ -0,0 +1,3 @@
1
+
2
+ export * from './interfaces/IServiceApi';
3
+ export * from './ServiceApi';
@@ -0,0 +1,44 @@
1
+ import { RegisterDeviceRequest } from "@fiado/type-kit/bin/device";
2
+ import { ServiceFlowEnum, ServiceMembershipStatusEnum, UpdateServiceMembershipRequest } from "@fiado/type-kit/bin/services";
3
+ import { ServiceCompanyEnum } from "@fiado/type-kit/bin/services/enums/ServiceCompanyEnum";
4
+
5
+ /**
6
+ * Interfaz que define las operaciones que se pueden realizar en el servicio de black list.
7
+ */
8
+ export interface IServiceApi {
9
+
10
+ /**
11
+ * Consulta de membresias
12
+ * @param value valor del parametro.
13
+ * @returns Una promesa que resuelve a void.
14
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
15
+ */
16
+ getServices(params: { pageSize?: number; index?: string; company?:ServiceCompanyEnum, flow?:ServiceFlowEnum }): Promise<void>;
17
+
18
+ /**
19
+ * Consulta de membresias de un directorio dado un directoryId
20
+ * @param value valor del parametro.
21
+ * @returns Una promesa que resuelve a void.
22
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
23
+ */
24
+ getServiceMembershipsByDirectoryId(params: { directoryId: string; pageSize?: number; index?: string; }): Promise<void>;
25
+
26
+
27
+ /**
28
+ * Consulta de membresias de un directorio dado un directoryId y un status
29
+ * @param value valor del parametro.
30
+ * @returns Una promesa que resuelve a void.
31
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
32
+ */
33
+ getServiceMembershipsByDirectoryIdAndStatus(params: { pageSize?: number; index?: string; directoryId:string,status:ServiceMembershipStatusEnum }): Promise<void>;
34
+
35
+
36
+ /**
37
+ * Actualizar una membresia de un servicio
38
+ * @param value valor del parametro.
39
+ * @returns Una promesa que resuelve a void.
40
+ * @throws {Error} Lanza un error si los parámetros de entrada son inválidos.
41
+ */
42
+ updateServiceMembership(serviceMembershipId:string,params: UpdateServiceMembershipRequest): Promise<void>;
43
+
44
+ }
@@ -0,0 +1,19 @@
1
+ import {injectable} from "inversify";
2
+
3
+ @injectable()
4
+ export class InvokerUtils {
5
+ constructor() {
6
+ }
7
+
8
+ toQueryStringParameters(object: any): string {
9
+ const records: Record<string, string> = Object.entries(object).reduce((acc, [key, value]) => {
10
+ if (Array.isArray(value)) {
11
+ acc[key] = value.join(','); // Convierte arrays a una cadena separada por comas
12
+ } else {
13
+ acc[key] = String(value); // Convierte todos los demás valores a string
14
+ }
15
+ return acc;
16
+ }, {} as Record<string, string>);
17
+ return new URLSearchParams(records).toString();
18
+ }
19
+ }