@fiado/api-invoker 5.48.0 → 5.49.0

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.
@@ -1,10 +1,10 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
2
  import { StandardResponse } from "@fiado/gateway-adapter";
3
- import { CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
+ import { ConsumePromotionRequest, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
4
4
  import { ILoanOfferingsBusinessApi } from "./interfaces/ILoanOfferingsBusinessApi.js";
5
5
  /**
6
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 4
7
- * endpoints privados de lectura del catálogo. Contrato y semántica completos →
6
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
7
+ * endpoints privados. Contrato y semántica completos →
8
8
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
9
9
  *
10
10
  * Env var requerida en el consumer: `LOAN_OFFERINGS_BUSINESS_URL`.
@@ -22,4 +22,5 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
22
22
  listActivePlansForRetailer(retailerId: string, tenantId: string): Promise<StandardResponse<CreditPlanResponse[]>>;
23
23
  listActiveFinanciers(tenantId: string): Promise<StandardResponse<FinancierResponse[]>>;
24
24
  simulate(planId: string, input: SimulateCreditPlanRequest, tenantId: string): Promise<StandardResponse<SimulationResultResponse>>;
25
+ consumePromotion(promotionId: string, input: ConsumePromotionRequest, tenantId: string): Promise<StandardResponse<ConsumePromotionResponse>>;
25
26
  }
@@ -12,8 +12,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { inject, injectable } from "inversify";
14
14
  /**
15
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 4
16
- * endpoints privados de lectura del catálogo. Contrato y semántica completos →
15
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
16
+ * endpoints privados. Contrato y semántica completos →
17
17
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
18
18
  *
19
19
  * Env var requerida en el consumer: `LOAN_OFFERINGS_BUSINESS_URL`.
@@ -46,6 +46,10 @@ let LoanOfferingsBusinessApi = class LoanOfferingsBusinessApi {
46
46
  const url = `${this.baseUrl}/private/credit-plans/${encodeURIComponent(planId)}/simulate?tenantId=${encodeURIComponent(tenantId)}`;
47
47
  return await this.httpRequest.post(url, input);
48
48
  }
49
+ async consumePromotion(promotionId, input, tenantId) {
50
+ const url = `${this.baseUrl}/private/promotions/${encodeURIComponent(promotionId)}/consume?tenantId=${encodeURIComponent(tenantId)}`;
51
+ return await this.httpRequest.post(url, input);
52
+ }
49
53
  };
50
54
  LoanOfferingsBusinessApi = __decorate([
51
55
  injectable(),
@@ -1,8 +1,9 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
- import { CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
2
+ import { ConsumePromotionRequest, ConsumePromotionResponse, CreditPlanResponse, FinancierResponse, SimulateCreditPlanRequest, SimulationResultResponse } from "@fiado/type-kit/bin/loanOfferings/index.js";
3
3
  /**
4
4
  * Contrato del publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1)
5
- * para sus 4 endpoints privados de LECTURA del catálogo SOFOM (service-to-service, VPC-only).
5
+ * para sus 5 endpoints privados service-to-service (VPC-only): 4 de LECTURA del catálogo SOFOM y
6
+ * 1 de ESCRITURA que registra el consumo de una promoción.
6
7
  *
7
8
  * loan-offerings es el catálogo comercial del SOFOM: planes de crédito + financieras + la relación
8
9
  * M:N retailer↔plan + el simulador de cuota. Consumidores previstos:
@@ -62,4 +63,15 @@ export interface ILoanOfferingsBusinessApi {
62
63
  * (`400 INVALID_PLAN_PARAMETERS`, ej. plazo fuera de `termWeeksOptions`).
63
64
  */
64
65
  simulate(planId: string, input: SimulateCreditPlanRequest, tenantId: string): Promise<StandardResponse<SimulationResultResponse>>;
66
+ /**
67
+ * POST /private/promotions/{promotionId}/consume — cuenta un crédito activado bajo esta
68
+ * promoción y suma su bono PCF al presupuesto. Al alcanzar el tope la promoción queda `PAUSED`.
69
+ *
70
+ * Idempotente por `creditId`: reenviar el mismo crédito devuelve 200 con
71
+ * `alreadyCounted: true` y NO mueve los contadores. Se llama al ACTIVAR, nunca al cotizar —
72
+ * una promoción que se cotiza y no se vende no consume nada.
73
+ *
74
+ * @throws si la promoción no existe (`404 PROMOTION_NOT_FOUND`).
75
+ */
76
+ consumePromotion(promotionId: string, input: ConsumePromotionRequest, tenantId: string): Promise<StandardResponse<ConsumePromotionResponse>>;
65
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.48.0",
3
+ "version": "5.49.0",
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
  "type": "module",
6
6
  "main": "bin/index.js",
@@ -34,7 +34,7 @@
34
34
  "@fiado/gateway-adapter": "^3.9.0",
35
35
  "@fiado/http-client": "^2.0.1",
36
36
  "@fiado/logger": "^1.1.3",
37
- "@fiado/type-kit": "^3.368.0",
37
+ "@fiado/type-kit": "^3.370.0",
38
38
  "dotenv": "^16.4.7"
39
39
  },
40
40
  "peerDependencies": {
@@ -2,6 +2,8 @@ import { inject, injectable } from "inversify";
2
2
  import type { IHttpRequest } from "@fiado/http-client";
3
3
  import { StandardResponse } from "@fiado/gateway-adapter";
4
4
  import {
5
+ ConsumePromotionRequest,
6
+ ConsumePromotionResponse,
5
7
  CreditPlanResponse,
6
8
  FinancierResponse,
7
9
  SimulateCreditPlanRequest,
@@ -10,8 +12,8 @@ import {
10
12
  import { ILoanOfferingsBusinessApi } from "./interfaces/ILoanOfferingsBusinessApi.js";
11
13
 
12
14
  /**
13
- * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 4
14
- * endpoints privados de lectura del catálogo. Contrato y semántica completos →
15
+ * Publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1) para sus 5
16
+ * endpoints privados. Contrato y semántica completos →
15
17
  * `ILoanOfferingsBusinessApi` (tenantId obligatorio, `StandardResponse` → leer `result.data`).
16
18
  *
17
19
  * Env var requerida en el consumer: `LOAN_OFFERINGS_BUSINESS_URL`.
@@ -59,4 +61,13 @@ export default class LoanOfferingsBusinessApi implements ILoanOfferingsBusinessA
59
61
  const url = `${this.baseUrl}/private/credit-plans/${encodeURIComponent(planId)}/simulate?tenantId=${encodeURIComponent(tenantId)}`;
60
62
  return await this.httpRequest.post(url, input);
61
63
  }
64
+
65
+ async consumePromotion(
66
+ promotionId: string,
67
+ input: ConsumePromotionRequest,
68
+ tenantId: string,
69
+ ): Promise<StandardResponse<ConsumePromotionResponse>> {
70
+ const url = `${this.baseUrl}/private/promotions/${encodeURIComponent(promotionId)}/consume?tenantId=${encodeURIComponent(tenantId)}`;
71
+ return await this.httpRequest.post(url, input);
72
+ }
62
73
  }
@@ -1,5 +1,7 @@
1
1
  import { StandardResponse } from "@fiado/gateway-adapter";
2
2
  import {
3
+ ConsumePromotionRequest,
4
+ ConsumePromotionResponse,
3
5
  CreditPlanResponse,
4
6
  FinancierResponse,
5
7
  SimulateCreditPlanRequest,
@@ -8,7 +10,8 @@ import {
8
10
 
9
11
  /**
10
12
  * Contrato del publisher HTTP del lambda `loan-offerings-business` (componente 07 SureKeep Fase 1)
11
- * para sus 4 endpoints privados de LECTURA del catálogo SOFOM (service-to-service, VPC-only).
13
+ * para sus 5 endpoints privados service-to-service (VPC-only): 4 de LECTURA del catálogo SOFOM y
14
+ * 1 de ESCRITURA que registra el consumo de una promoción.
12
15
  *
13
16
  * loan-offerings es el catálogo comercial del SOFOM: planes de crédito + financieras + la relación
14
17
  * M:N retailer↔plan + el simulador de cuota. Consumidores previstos:
@@ -83,4 +86,20 @@ export interface ILoanOfferingsBusinessApi {
83
86
  input: SimulateCreditPlanRequest,
84
87
  tenantId: string,
85
88
  ): Promise<StandardResponse<SimulationResultResponse>>;
89
+
90
+ /**
91
+ * POST /private/promotions/{promotionId}/consume — cuenta un crédito activado bajo esta
92
+ * promoción y suma su bono PCF al presupuesto. Al alcanzar el tope la promoción queda `PAUSED`.
93
+ *
94
+ * Idempotente por `creditId`: reenviar el mismo crédito devuelve 200 con
95
+ * `alreadyCounted: true` y NO mueve los contadores. Se llama al ACTIVAR, nunca al cotizar —
96
+ * una promoción que se cotiza y no se vende no consume nada.
97
+ *
98
+ * @throws si la promoción no existe (`404 PROMOTION_NOT_FOUND`).
99
+ */
100
+ consumePromotion(
101
+ promotionId: string,
102
+ input: ConsumePromotionRequest,
103
+ tenantId: string,
104
+ ): Promise<StandardResponse<ConsumePromotionResponse>>;
86
105
  }