@fiado/api-invoker 3.3.1 → 3.3.3

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,6 +23,7 @@ const card_1 = require("./card");
23
23
  const transaction_1 = require("./transaction");
24
24
  const contract_generator_1 = require("./contract-generator");
25
25
  const ContractBusinessApi_1 = __importDefault(require("./contract-business/api/ContractBusinessApi"));
26
+ const CreditStatementsApi_1 = __importDefault(require("./credit-statements/api/CreditStatementsApi"));
26
27
  const ProductCatalogApi_1 = __importDefault(require("./product-catalog/ProductCatalogApi"));
27
28
  const collector_1 = require("./collector");
28
29
  const P2pContactApi_1 = __importDefault(require("./p2pContact/api/P2pContactApi"));
@@ -118,6 +119,7 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
118
119
  bind("ICardApi").to(card_1.CardApi);
119
120
  bind("IContractGeneratorApi").to(contract_generator_1.ContractGeneratorApi);
120
121
  bind("IContractBusinessApi").to(ContractBusinessApi_1.default);
122
+ bind("ICreditStatementsApi").to(CreditStatementsApi_1.default);
121
123
  bind("ICollectorApi").to(collector_1.CollectorApi);
122
124
  bind("IProductCatalogApi").to(ProductCatalogApi_1.default);
123
125
  bind("IP2pContactApi").to(P2pContactApi_1.default);
@@ -14,4 +14,6 @@ export default class ContractBusinessApi implements IContractBusinessApi {
14
14
  partnerId?: string;
15
15
  category?: string;
16
16
  }): Promise<any>;
17
+ listSignedByDirectory(directoryId: string, enterprise?: string): Promise<any>;
18
+ getContractPdfUrl(contractId: string, partnerId: string, category?: string): Promise<any>;
17
19
  }
@@ -22,6 +22,14 @@ let ContractBusinessApi = class ContractBusinessApi {
22
22
  const { documentType, ...body } = params;
23
23
  return await this.httpRequest.post(`${this.baseUrl}/sign/${documentType}`, body);
24
24
  }
25
+ async listSignedByDirectory(directoryId, enterprise = "FIADOSA") {
26
+ const url = `${this.baseUrl}/backoffice/directories/${directoryId}/signed-documents?enterprise=${encodeURIComponent(enterprise)}`;
27
+ return await this.httpRequest.get(url);
28
+ }
29
+ async getContractPdfUrl(contractId, partnerId, category = "CREDITS") {
30
+ const url = `${this.baseUrl}/backoffice/contracts/${contractId}/pdf?partnerId=${encodeURIComponent(partnerId)}&category=${encodeURIComponent(category)}`;
31
+ return await this.httpRequest.get(url);
32
+ }
25
33
  };
26
34
  ContractBusinessApi = __decorate([
27
35
  (0, inversify_1.injectable)(),
@@ -11,4 +11,13 @@ export interface IContractBusinessApi {
11
11
  /** Opcional: category (ej: "credito") para el path profundo de template */
12
12
  category?: string;
13
13
  }): Promise<any>;
14
+ /**
15
+ * Lista todos los contratos firmados del directorio (no solo el último por tipo).
16
+ * Backoffice consume este endpoint para mostrar el historial.
17
+ */
18
+ listSignedByDirectory(directoryId: string, enterprise?: string): Promise<any>;
19
+ /**
20
+ * Obtiene una URL pre-firmada (15 min) para visualizar inline el PDF firmado.
21
+ */
22
+ getContractPdfUrl(contractId: string, partnerId: string, category?: string): Promise<any>;
14
23
  }
@@ -0,0 +1,10 @@
1
+ import { IHttpRequest } from "@fiado/http-client";
2
+ import { ICreditStatementsApi } from "./interfaces/ICreditStatementsApi";
3
+ export default class CreditStatementsApi implements ICreditStatementsApi {
4
+ private httpRequest;
5
+ private readonly baseUrl;
6
+ constructor(httpRequest: IHttpRequest);
7
+ listByCredit(creditId: string, limit?: number): Promise<any>;
8
+ listByDirectory(directoryId: string, limit?: number): Promise<any>;
9
+ getDownloadUrl(statementId: string): Promise<any>;
10
+ }
@@ -0,0 +1,38 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const inversify_1 = require("inversify");
16
+ let CreditStatementsApi = class CreditStatementsApi {
17
+ constructor(httpRequest) {
18
+ this.httpRequest = httpRequest;
19
+ this.baseUrl = process.env.CREDIT_STATEMENTS_BUSINESS_LAMBDA_URL || "";
20
+ }
21
+ async listByCredit(creditId, limit) {
22
+ const qs = limit ? `?limit=${limit}` : "";
23
+ return await this.httpRequest.get(`${this.baseUrl}private/credits/${creditId}/statements${qs}`);
24
+ }
25
+ async listByDirectory(directoryId, limit) {
26
+ const qs = limit ? `?limit=${limit}` : "";
27
+ return await this.httpRequest.get(`${this.baseUrl}private/directories/${directoryId}/statements${qs}`);
28
+ }
29
+ async getDownloadUrl(statementId) {
30
+ return await this.httpRequest.get(`${this.baseUrl}private/statements/${statementId}/download`);
31
+ }
32
+ };
33
+ CreditStatementsApi = __decorate([
34
+ (0, inversify_1.injectable)(),
35
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
36
+ __metadata("design:paramtypes", [Object])
37
+ ], CreditStatementsApi);
38
+ exports.default = CreditStatementsApi;
@@ -0,0 +1,26 @@
1
+ export interface ICreditStatementListItem {
2
+ statementId: string;
3
+ period: string;
4
+ periodYear: number;
5
+ periodMonth: number;
6
+ status: string;
7
+ generatedAt: string | null;
8
+ }
9
+ export interface ICreditStatementDownload {
10
+ url: string;
11
+ expiresAt: string;
12
+ }
13
+ export interface ICreditStatementsApi {
14
+ /**
15
+ * Lista los estados de cuenta de un crédito (más recientes primero).
16
+ */
17
+ listByCredit(creditId: string, limit?: number): Promise<any>;
18
+ /**
19
+ * Lista los estados de cuenta de un usuario (todos los créditos del directorio).
20
+ */
21
+ listByDirectory(directoryId: string, limit?: number): Promise<any>;
22
+ /**
23
+ * Obtiene una URL pre-firmada (15 min) para descargar el PDF del statement.
24
+ */
25
+ getDownloadUrl(statementId: string): Promise<any>;
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './api/CreditStatementsApi';
2
+ export * from './api/interfaces/ICreditStatementsApi';
@@ -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("./api/CreditStatementsApi"), exports);
18
+ __exportStar(require("./api/interfaces/ICreditStatementsApi"), exports);
package/bin/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./authentication";
16
16
  export * from "./transaction";
17
17
  export * from "./contract-generator";
18
18
  export * from "./contract-business";
19
+ export * from "./credit-statements";
19
20
  export * from "./product-catalog";
20
21
  export * from "./collector";
21
22
  export * from "./p2pContact";
package/bin/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./authentication"), exports);
32
32
  __exportStar(require("./transaction"), exports);
33
33
  __exportStar(require("./contract-generator"), exports);
34
34
  __exportStar(require("./contract-business"), exports);
35
+ __exportStar(require("./credit-statements"), exports);
35
36
  __exportStar(require("./product-catalog"), exports);
36
37
  __exportStar(require("./collector"), exports);
37
38
  __exportStar(require("./p2pContact"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "3.3.1",
4
- "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicaci\u00f3n entre ellas a trav\u00e9s de invocaciones http",
3
+ "version": "3.3.3",
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",
7
7
  "scripts": {
@@ -26,4 +26,4 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^20.17.24"
28
28
  }
29
- }
29
+ }
@@ -25,6 +25,8 @@ import { ITransactionApi, ITransactionPublisher, TransactionPublisher } from "./
25
25
  import { ContractGeneratorApi, IContractGeneratorApi } from "./contract-generator";
26
26
  import { IContractBusinessApi } from "./contract-business";
27
27
  import ContractBusinessApi from "./contract-business/api/ContractBusinessApi";
28
+ import { ICreditStatementsApi } from "./credit-statements";
29
+ import CreditStatementsApi from "./credit-statements/api/CreditStatementsApi";
28
30
  import { IProductCatalogApi } from "./product-catalog";
29
31
  import ProductCatalogApi from "./product-catalog/ProductCatalogApi";
30
32
  import { CollectorApi, ICollectorApi } from "./collector";
@@ -164,6 +166,7 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
164
166
  bind<ICardApi>("ICardApi").to(CardApi);
165
167
  bind<IContractGeneratorApi>("IContractGeneratorApi").to(ContractGeneratorApi);
166
168
  bind<IContractBusinessApi>("IContractBusinessApi").to(ContractBusinessApi);
169
+ bind<ICreditStatementsApi>("ICreditStatementsApi").to(CreditStatementsApi);
167
170
  bind<ICollectorApi>("ICollectorApi").to(CollectorApi);
168
171
  bind<IProductCatalogApi>("IProductCatalogApi").to(ProductCatalogApi);
169
172
  bind<IP2pContactApi>("IP2pContactApi").to(P2pContactApi);
@@ -23,4 +23,14 @@ export default class ContractBusinessApi implements IContractBusinessApi {
23
23
  const { documentType, ...body } = params;
24
24
  return await this.httpRequest.post(`${this.baseUrl}/sign/${documentType}`, body);
25
25
  }
26
+
27
+ async listSignedByDirectory(directoryId: string, enterprise: string = "FIADOSA"): Promise<any> {
28
+ const url = `${this.baseUrl}/backoffice/directories/${directoryId}/signed-documents?enterprise=${encodeURIComponent(enterprise)}`;
29
+ return await this.httpRequest.get(url);
30
+ }
31
+
32
+ async getContractPdfUrl(contractId: string, partnerId: string, category: string = "CREDITS"): Promise<any> {
33
+ const url = `${this.baseUrl}/backoffice/contracts/${contractId}/pdf?partnerId=${encodeURIComponent(partnerId)}&category=${encodeURIComponent(category)}`;
34
+ return await this.httpRequest.get(url);
35
+ }
26
36
  }
@@ -11,4 +11,15 @@ export interface IContractBusinessApi {
11
11
  /** Opcional: category (ej: "credito") para el path profundo de template */
12
12
  category?: string;
13
13
  }): Promise<any>;
14
+
15
+ /**
16
+ * Lista todos los contratos firmados del directorio (no solo el último por tipo).
17
+ * Backoffice consume este endpoint para mostrar el historial.
18
+ */
19
+ listSignedByDirectory(directoryId: string, enterprise?: string): Promise<any>;
20
+
21
+ /**
22
+ * Obtiene una URL pre-firmada (15 min) para visualizar inline el PDF firmado.
23
+ */
24
+ getContractPdfUrl(contractId: string, partnerId: string, category?: string): Promise<any>;
14
25
  }
@@ -0,0 +1,25 @@
1
+ import { inject, injectable } from "inversify";
2
+ import { IHttpRequest } from "@fiado/http-client";
3
+ import { ICreditStatementsApi } from "./interfaces/ICreditStatementsApi";
4
+
5
+ @injectable()
6
+ export default class CreditStatementsApi implements ICreditStatementsApi {
7
+
8
+ private readonly baseUrl = process.env.CREDIT_STATEMENTS_BUSINESS_LAMBDA_URL || "";
9
+
10
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
11
+
12
+ async listByCredit(creditId: string, limit?: number): Promise<any> {
13
+ const qs = limit ? `?limit=${limit}` : "";
14
+ return await this.httpRequest.get(`${this.baseUrl}private/credits/${creditId}/statements${qs}`);
15
+ }
16
+
17
+ async listByDirectory(directoryId: string, limit?: number): Promise<any> {
18
+ const qs = limit ? `?limit=${limit}` : "";
19
+ return await this.httpRequest.get(`${this.baseUrl}private/directories/${directoryId}/statements${qs}`);
20
+ }
21
+
22
+ async getDownloadUrl(statementId: string): Promise<any> {
23
+ return await this.httpRequest.get(`${this.baseUrl}private/statements/${statementId}/download`);
24
+ }
25
+ }
@@ -0,0 +1,30 @@
1
+ export interface ICreditStatementListItem {
2
+ statementId: string;
3
+ period: string;
4
+ periodYear: number;
5
+ periodMonth: number;
6
+ status: string;
7
+ generatedAt: string | null;
8
+ }
9
+
10
+ export interface ICreditStatementDownload {
11
+ url: string;
12
+ expiresAt: string;
13
+ }
14
+
15
+ export interface ICreditStatementsApi {
16
+ /**
17
+ * Lista los estados de cuenta de un crédito (más recientes primero).
18
+ */
19
+ listByCredit(creditId: string, limit?: number): Promise<any>;
20
+
21
+ /**
22
+ * Lista los estados de cuenta de un usuario (todos los créditos del directorio).
23
+ */
24
+ listByDirectory(directoryId: string, limit?: number): Promise<any>;
25
+
26
+ /**
27
+ * Obtiene una URL pre-firmada (15 min) para descargar el PDF del statement.
28
+ */
29
+ getDownloadUrl(statementId: string): Promise<any>;
30
+ }
@@ -0,0 +1,2 @@
1
+ export * from './api/CreditStatementsApi';
2
+ export * from './api/interfaces/ICreditStatementsApi';
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./authentication";
16
16
  export * from "./transaction";
17
17
  export * from "./contract-generator";
18
18
  export * from "./contract-business";
19
+ export * from "./credit-statements";
19
20
  export * from "./product-catalog";
20
21
  export * from "./collector";
21
22
  export * from "./p2pContact";