@fiado/api-invoker 5.139.0 → 5.141.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.
- package/bin/retailCustomer/api/RetailCustomerBusinessApi.d.ts +6 -1
- package/bin/retailCustomer/api/RetailCustomerBusinessApi.js +21 -0
- package/bin/retailCustomer/api/interfaces/IRetailCustomerBusinessApi.d.ts +17 -1
- package/bin/retailPromotions/api/RetailPromotionsBusinessApi.d.ts +2 -1
- package/bin/retailPromotions/api/RetailPromotionsBusinessApi.js +4 -0
- package/bin/retailPromotions/api/interfaces/IRetailPromotionsBusinessApi.d.ts +9 -3
- package/bin/retailWizard/queue/RetailPromotionInboundPublisher.d.ts +2 -2
- package/bin/retailWizard/queue/RetailPromotionInboundPublisher.js +1 -1
- package/bin/retailWizard/queue/interfaces/IRetailPromotionInboundPublisher.d.ts +3 -3
- package/package.json +1 -1
- package/src/retailCustomer/api/RetailCustomerBusinessApi.ts +53 -0
- package/src/retailCustomer/api/interfaces/IRetailCustomerBusinessApi.ts +48 -0
- package/src/retailPromotions/api/RetailPromotionsBusinessApi.ts +10 -0
- package/src/retailPromotions/api/interfaces/IRetailPromotionsBusinessApi.ts +14 -2
- package/src/retailWizard/queue/RetailPromotionInboundPublisher.ts +3 -3
- package/src/retailWizard/queue/interfaces/IRetailPromotionInboundPublisher.ts +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import { UpsertCustomerFromKycRequest, AccountResultRequest, CustomerResponse, PromotionBonusEntryResponse, UpsertPromotionBonusRequest, WelcomeAccreditationRequest, WelcomeAccreditationResponse, WelcomeAccreditationResultRequest, WelcomeBonusResponse } from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
3
|
+
import { UpsertCustomerFromKycRequest, AccountResultRequest, CustomerResponse, PromotionBonusEntryResponse, UpsertPromotionBonusRequest, WelcomeAccreditationRequest, WelcomeAccreditationResponse, WelcomeAccreditationResultRequest, WelcomeBonusResponse, CreateCustomerReferralsRequest, CreateCustomerReferralsResponse, UpdateCustomerReferralRequest, UpdateCustomerReferralResponse, ListCustomerReferralsResponse, GetReferralsByPhoneQuery, ReferralsByPhoneResponse, GetCustomersByPhonesRequest, CustomersByPhonesResponse } from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
4
4
|
import { CustomersBatchRequest, CustomersBatchResponse } from "./dtos/CustomersBatch.js";
|
|
5
5
|
import { CustomersPageQuery, PrivateCustomerListItem } from "./dtos/CustomersPage.js";
|
|
6
6
|
import { PaginatedResult } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
@@ -32,4 +32,9 @@ export default class RetailCustomerBusinessApi implements IRetailCustomerBusines
|
|
|
32
32
|
upsertPromotionBonus(customerId: string, payload: UpsertPromotionBonusRequest, tenantId: string): Promise<StandardResponse<PromotionBonusEntryResponse>>;
|
|
33
33
|
getCustomersBatch(payload: CustomersBatchRequest, tenantId: string): Promise<StandardResponse<CustomersBatchResponse>>;
|
|
34
34
|
listCustomersPage(query: CustomersPageQuery, tenantId: string): Promise<StandardResponse<PaginatedResult<PrivateCustomerListItem>>>;
|
|
35
|
+
createCustomerReferrals(customerId: string, payload: CreateCustomerReferralsRequest, tenantId: string): Promise<StandardResponse<CreateCustomerReferralsResponse>>;
|
|
36
|
+
updateCustomerReferral(customerId: string, referralId: string, payload: UpdateCustomerReferralRequest, tenantId: string): Promise<StandardResponse<UpdateCustomerReferralResponse>>;
|
|
37
|
+
listCustomerReferrals(customerId: string, tenantId: string): Promise<StandardResponse<ListCustomerReferralsResponse>>;
|
|
38
|
+
getReferralsByPhone(query: GetReferralsByPhoneQuery, tenantId: string): Promise<StandardResponse<ReferralsByPhoneResponse>>;
|
|
39
|
+
getCustomersByPhones(payload: GetCustomersByPhonesRequest, tenantId: string): Promise<StandardResponse<CustomersByPhonesResponse>>;
|
|
35
40
|
}
|
|
@@ -75,6 +75,27 @@ let RetailCustomerBusinessApi = class RetailCustomerBusinessApi {
|
|
|
75
75
|
const url = `${this.baseUrl}/private/customers?${params.toString()}`;
|
|
76
76
|
return await this.httpRequest.get(url);
|
|
77
77
|
}
|
|
78
|
+
async createCustomerReferrals(customerId, payload, tenantId) {
|
|
79
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals?tenantId=${encodeURIComponent(tenantId)}`;
|
|
80
|
+
return await this.httpRequest.post(url, payload);
|
|
81
|
+
}
|
|
82
|
+
async updateCustomerReferral(customerId, referralId, payload, tenantId) {
|
|
83
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals/${encodeURIComponent(referralId)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
84
|
+
return await this.httpRequest.put(url, payload);
|
|
85
|
+
}
|
|
86
|
+
async listCustomerReferrals(customerId, tenantId) {
|
|
87
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals?tenantId=${encodeURIComponent(tenantId)}`;
|
|
88
|
+
return await this.httpRequest.get(url);
|
|
89
|
+
}
|
|
90
|
+
async getReferralsByPhone(query, tenantId) {
|
|
91
|
+
// POST para que el teléfono no quede en la URL ni en los logs de API Gateway.
|
|
92
|
+
const url = `${this.baseUrl}/private/referrals/by-phone?tenantId=${encodeURIComponent(tenantId)}`;
|
|
93
|
+
return await this.httpRequest.post(url, query);
|
|
94
|
+
}
|
|
95
|
+
async getCustomersByPhones(payload, tenantId) {
|
|
96
|
+
const url = `${this.baseUrl}/private/customers/by-phones?tenantId=${encodeURIComponent(tenantId)}`;
|
|
97
|
+
return await this.httpRequest.post(url, payload);
|
|
98
|
+
}
|
|
78
99
|
};
|
|
79
100
|
RetailCustomerBusinessApi = __decorate([
|
|
80
101
|
injectable(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
-
import { UpsertCustomerFromKycRequest, AccountResultRequest, CustomerResponse, PromotionBonusEntryResponse, UpsertPromotionBonusRequest, WelcomeAccreditationRequest, WelcomeAccreditationResponse, WelcomeAccreditationResultRequest, WelcomeBonusResponse } from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
2
|
+
import { UpsertCustomerFromKycRequest, AccountResultRequest, CustomerResponse, PromotionBonusEntryResponse, UpsertPromotionBonusRequest, WelcomeAccreditationRequest, WelcomeAccreditationResponse, WelcomeAccreditationResultRequest, WelcomeBonusResponse, CreateCustomerReferralsRequest, CreateCustomerReferralsResponse, UpdateCustomerReferralRequest, UpdateCustomerReferralResponse, ListCustomerReferralsResponse, GetReferralsByPhoneQuery, ReferralsByPhoneResponse, GetCustomersByPhonesRequest, CustomersByPhonesResponse } from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
3
3
|
import { CustomersBatchRequest, CustomersBatchResponse } from "../dtos/CustomersBatch.js";
|
|
4
4
|
import { CustomersPageQuery, PrivateCustomerListItem } from "../dtos/CustomersPage.js";
|
|
5
5
|
import { PaginatedResult } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
@@ -159,4 +159,20 @@ export interface IRetailCustomerBusinessApi {
|
|
|
159
159
|
* @throws `400 UNKNOWN_TENANT` si el `tenantId` viene ausente o desconocido.
|
|
160
160
|
*/
|
|
161
161
|
listCustomersPage(query: CustomersPageQuery, tenantId: string): Promise<StandardResponse<PaginatedResult<PrivateCustomerListItem>>>;
|
|
162
|
+
/**
|
|
163
|
+
* `POST /private/customers/{id}/referrals` (`privateCreateCustomerReferrals`): lote de referidos del cliente.
|
|
164
|
+
* Rechaza con `DUPLICATE_REFERRAL_PHONE` si un teléfono ya está referido en la cadena.
|
|
165
|
+
*/
|
|
166
|
+
createCustomerReferrals(customerId: string, payload: CreateCustomerReferralsRequest, tenantId: string): Promise<StandardResponse<CreateCustomerReferralsResponse>>;
|
|
167
|
+
/** `PUT /private/customers/{id}/referrals/{referralId}` (`privateUpdateCustomerReferral`): corrige nombre, teléfono o correo. */
|
|
168
|
+
updateCustomerReferral(customerId: string, referralId: string, payload: UpdateCustomerReferralRequest, tenantId: string): Promise<StandardResponse<UpdateCustomerReferralResponse>>;
|
|
169
|
+
/** `GET /private/customers/{id}/referrals` (`privateListCustomerReferrals`): referidos que capturó el cliente. */
|
|
170
|
+
listCustomerReferrals(customerId: string, tenantId: string): Promise<StandardResponse<ListCustomerReferralsResponse>>;
|
|
171
|
+
/**
|
|
172
|
+
* `POST /private/referrals/by-phone` (`privateGetReferralsByPhone`): quién recomendó el teléfono en la cadena
|
|
173
|
+
* antes de `before`, del más antiguo al más reciente. Es POST para que el teléfono no viaje en la URL.
|
|
174
|
+
*/
|
|
175
|
+
getReferralsByPhone(query: GetReferralsByPhoneQuery, tenantId: string): Promise<StandardResponse<ReferralsByPhoneResponse>>;
|
|
176
|
+
/** `POST /private/customers/by-phones` (`privateGetCustomersByPhones`): qué teléfonos del lote ya son clientes. */
|
|
177
|
+
getCustomersByPhones(payload: GetCustomersByPhonesRequest, tenantId: string): Promise<StandardResponse<CustomersByPhonesResponse>>;
|
|
162
178
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import type { ActiveSalePromotionsBySkusRequest, ActiveSalePromotionsBySkusResponse, CheckSalePromotionPaymentRequest, PrivateSalePromotionPaymentCheckResponse, PrivateReleaseSalePromotionResponse, WelcomeBonusPromotionResponse } from "@fiado/type-kit/bin/retailPromotions/index.js";
|
|
3
|
+
import type { ActiveSalePromotionsBySkusRequest, ActiveSalePromotionsBySkusResponse, CheckSalePromotionPaymentRequest, GetReferralRewardsByPhonesRequest, ReferralRewardsByPhonesResponse, PrivateSalePromotionPaymentCheckResponse, PrivateReleaseSalePromotionResponse, WelcomeBonusPromotionResponse } from "@fiado/type-kit/bin/retailPromotions/index.js";
|
|
4
4
|
import { IRetailPromotionsBusinessApi } from "./interfaces/IRetailPromotionsBusinessApi.js";
|
|
5
5
|
/** Publisher HTTP de los privados de `retail-promotions-business`. Contrato -> `IRetailPromotionsBusinessApi`. */
|
|
6
6
|
export default class RetailPromotionsBusinessApi implements IRetailPromotionsBusinessApi {
|
|
@@ -11,4 +11,5 @@ export default class RetailPromotionsBusinessApi implements IRetailPromotionsBus
|
|
|
11
11
|
checkSalePromotionPayment(tenantId: string, sessionId: string, input: CheckSalePromotionPaymentRequest): Promise<StandardResponse<PrivateSalePromotionPaymentCheckResponse>>;
|
|
12
12
|
listActiveSalePromotionsBySkus(input: ActiveSalePromotionsBySkusRequest): Promise<StandardResponse<ActiveSalePromotionsBySkusResponse>>;
|
|
13
13
|
getWelcomeBonus(retailerId: string): Promise<StandardResponse<WelcomeBonusPromotionResponse>>;
|
|
14
|
+
getReferralRewardsByPhones(tenantId: string, input: GetReferralRewardsByPhonesRequest): Promise<StandardResponse<ReferralRewardsByPhonesResponse>>;
|
|
14
15
|
}
|
|
@@ -35,6 +35,10 @@ let RetailPromotionsBusinessApi = class RetailPromotionsBusinessApi {
|
|
|
35
35
|
async getWelcomeBonus(retailerId) {
|
|
36
36
|
return await this.httpRequest.get(`${this.baseUrl}/private/retailers/${encodeURIComponent(retailerId)}/welcome-bonus`);
|
|
37
37
|
}
|
|
38
|
+
async getReferralRewardsByPhones(tenantId, input) {
|
|
39
|
+
const query = new URLSearchParams({ tenantId });
|
|
40
|
+
return await this.httpRequest.post(`${this.baseUrl}/private/referral-rewards/by-phones?${query.toString()}`, input);
|
|
41
|
+
}
|
|
38
42
|
};
|
|
39
43
|
RetailPromotionsBusinessApi = __decorate([
|
|
40
44
|
injectable(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
-
import type { ActiveSalePromotionsBySkusRequest, ActiveSalePromotionsBySkusResponse, CheckSalePromotionPaymentRequest, PrivateSalePromotionPaymentCheckResponse, PrivateReleaseSalePromotionResponse, WelcomeBonusPromotionResponse } from "@fiado/type-kit/bin/retailPromotions/index.js";
|
|
2
|
+
import type { ActiveSalePromotionsBySkusRequest, ActiveSalePromotionsBySkusResponse, CheckSalePromotionPaymentRequest, GetReferralRewardsByPhonesRequest, ReferralRewardsByPhonesResponse, PrivateSalePromotionPaymentCheckResponse, PrivateReleaseSalePromotionResponse, WelcomeBonusPromotionResponse } from "@fiado/type-kit/bin/retailPromotions/index.js";
|
|
3
3
|
export interface IRetailPromotionsBusinessApi {
|
|
4
4
|
/**
|
|
5
5
|
* `DELETE /private/sessions/{sessionId}/sale-promotion`: suelta el apartado de la promo de venta.
|
|
@@ -7,8 +7,9 @@ export interface IRetailPromotionsBusinessApi {
|
|
|
7
7
|
*/
|
|
8
8
|
releaseSalePromotion(tenantId: string, sessionId: string): Promise<StandardResponse<PrivateReleaseSalePromotionResponse>>;
|
|
9
9
|
/**
|
|
10
|
-
* `POST /private/sessions/{sessionId}/sale-promotion/payment-check`: antes del cobro de contado
|
|
11
|
-
*
|
|
10
|
+
* `POST /private/sessions/{sessionId}/sale-promotion/payment-check`: antes del cobro de contado (con `method`)
|
|
11
|
+
* o del enganche y cierre a crédito (sin `method`, contra la forma de pago de la sesión).
|
|
12
|
+
* 422 `PROMOTION_PAYMENT_NOT_ELIGIBLE` si alguna promo apartada no la acepta.
|
|
12
13
|
*/
|
|
13
14
|
checkSalePromotionPayment(tenantId: string, sessionId: string, input: CheckSalePromotionPaymentRequest): Promise<StandardResponse<PrivateSalePromotionPaymentCheckResponse>>;
|
|
14
15
|
/**
|
|
@@ -21,4 +22,9 @@ export interface IRetailPromotionsBusinessApi {
|
|
|
21
22
|
* Sin `tenantId`; la siembra si no existe. `active=false` = pausada, el wizard no paga bono.
|
|
22
23
|
*/
|
|
23
24
|
getWelcomeBonus(retailerId: string): Promise<StandardResponse<WelcomeBonusPromotionResponse>>;
|
|
25
|
+
/**
|
|
26
|
+
* `POST /private/referral-rewards/by-phones`: premios de referido por cadena y lote de teléfonos, para el cajón.
|
|
27
|
+
* Un renglón por teléfono pedido; `rewards` vacío si no tiene.
|
|
28
|
+
*/
|
|
29
|
+
getReferralRewardsByPhones(tenantId: string, input: GetReferralRewardsByPhonesRequest): Promise<StandardResponse<ReferralRewardsByPhonesResponse>>;
|
|
24
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RetailPromotionQueueMessage } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
2
2
|
import { IRetailPromotionInboundPublisher } from "./interfaces/IRetailPromotionInboundPublisher.js";
|
|
3
3
|
export declare class RetailPromotionInboundPublisher implements IRetailPromotionInboundPublisher {
|
|
4
4
|
private readonly RETAIL_PROMOTION_INBOUND_QUEUE_URL;
|
|
5
|
-
publish(message:
|
|
5
|
+
publish(message: RetailPromotionQueueMessage): Promise<void>;
|
|
6
6
|
}
|
|
@@ -11,7 +11,7 @@ let RetailPromotionInboundPublisher = class RetailPromotionInboundPublisher {
|
|
|
11
11
|
async publish(message) {
|
|
12
12
|
try {
|
|
13
13
|
const client = new SQSClient();
|
|
14
|
-
// Cola estándar: sin MessageGroupId; el consumidor deduplica por
|
|
14
|
+
// Cola estándar: sin MessageGroupId; el consumidor deduplica por evento.
|
|
15
15
|
const sendMessageRequest = {
|
|
16
16
|
QueueUrl: this.RETAIL_PROMOTION_INBOUND_QUEUE_URL,
|
|
17
17
|
MessageBody: JSON.stringify(message),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RetailPromotionQueueMessage } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Publisher hacia `RetailPromotionInboundQueue
|
|
3
|
+
* Publisher hacia `RetailPromotionInboundQueue`, que consume `retail-promotions`: venta, ACCOUNT_OPENED o CREDIT_INSTALLMENT_PAID.
|
|
4
4
|
* Env var requerida en el productor: `RETAIL_PROMOTION_INBOUND_QUEUE_URL`.
|
|
5
5
|
*/
|
|
6
6
|
export interface IRetailPromotionInboundPublisher {
|
|
7
|
-
publish(message:
|
|
7
|
+
publish(message: RetailPromotionQueueMessage): Promise<void>;
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.141.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",
|
|
@@ -11,6 +11,15 @@ import {
|
|
|
11
11
|
WelcomeAccreditationResponse,
|
|
12
12
|
WelcomeAccreditationResultRequest,
|
|
13
13
|
WelcomeBonusResponse,
|
|
14
|
+
CreateCustomerReferralsRequest,
|
|
15
|
+
CreateCustomerReferralsResponse,
|
|
16
|
+
UpdateCustomerReferralRequest,
|
|
17
|
+
UpdateCustomerReferralResponse,
|
|
18
|
+
ListCustomerReferralsResponse,
|
|
19
|
+
GetReferralsByPhoneQuery,
|
|
20
|
+
ReferralsByPhoneResponse,
|
|
21
|
+
GetCustomersByPhonesRequest,
|
|
22
|
+
CustomersByPhonesResponse,
|
|
14
23
|
} from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
15
24
|
import { CustomersBatchRequest, CustomersBatchResponse } from "./dtos/CustomersBatch.js";
|
|
16
25
|
import { CustomersPageQuery, PrivateCustomerListItem } from "./dtos/CustomersPage.js";
|
|
@@ -118,4 +127,48 @@ export default class RetailCustomerBusinessApi implements IRetailCustomerBusines
|
|
|
118
127
|
const url = `${this.baseUrl}/private/customers?${params.toString()}`;
|
|
119
128
|
return await this.httpRequest.get(url);
|
|
120
129
|
}
|
|
130
|
+
|
|
131
|
+
async createCustomerReferrals(
|
|
132
|
+
customerId: string,
|
|
133
|
+
payload: CreateCustomerReferralsRequest,
|
|
134
|
+
tenantId: string,
|
|
135
|
+
): Promise<StandardResponse<CreateCustomerReferralsResponse>> {
|
|
136
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals?tenantId=${encodeURIComponent(tenantId)}`;
|
|
137
|
+
return await this.httpRequest.post(url, payload);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async updateCustomerReferral(
|
|
141
|
+
customerId: string,
|
|
142
|
+
referralId: string,
|
|
143
|
+
payload: UpdateCustomerReferralRequest,
|
|
144
|
+
tenantId: string,
|
|
145
|
+
): Promise<StandardResponse<UpdateCustomerReferralResponse>> {
|
|
146
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals/${encodeURIComponent(referralId)}?tenantId=${encodeURIComponent(tenantId)}`;
|
|
147
|
+
return await this.httpRequest.put(url, payload);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async listCustomerReferrals(
|
|
151
|
+
customerId: string,
|
|
152
|
+
tenantId: string,
|
|
153
|
+
): Promise<StandardResponse<ListCustomerReferralsResponse>> {
|
|
154
|
+
const url = `${this.baseUrl}/private/customers/${encodeURIComponent(customerId)}/referrals?tenantId=${encodeURIComponent(tenantId)}`;
|
|
155
|
+
return await this.httpRequest.get(url);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async getReferralsByPhone(
|
|
159
|
+
query: GetReferralsByPhoneQuery,
|
|
160
|
+
tenantId: string,
|
|
161
|
+
): Promise<StandardResponse<ReferralsByPhoneResponse>> {
|
|
162
|
+
// POST para que el teléfono no quede en la URL ni en los logs de API Gateway.
|
|
163
|
+
const url = `${this.baseUrl}/private/referrals/by-phone?tenantId=${encodeURIComponent(tenantId)}`;
|
|
164
|
+
return await this.httpRequest.post(url, query);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async getCustomersByPhones(
|
|
168
|
+
payload: GetCustomersByPhonesRequest,
|
|
169
|
+
tenantId: string,
|
|
170
|
+
): Promise<StandardResponse<CustomersByPhonesResponse>> {
|
|
171
|
+
const url = `${this.baseUrl}/private/customers/by-phones?tenantId=${encodeURIComponent(tenantId)}`;
|
|
172
|
+
return await this.httpRequest.post(url, payload);
|
|
173
|
+
}
|
|
121
174
|
}
|
|
@@ -9,6 +9,15 @@ import {
|
|
|
9
9
|
WelcomeAccreditationResponse,
|
|
10
10
|
WelcomeAccreditationResultRequest,
|
|
11
11
|
WelcomeBonusResponse,
|
|
12
|
+
CreateCustomerReferralsRequest,
|
|
13
|
+
CreateCustomerReferralsResponse,
|
|
14
|
+
UpdateCustomerReferralRequest,
|
|
15
|
+
UpdateCustomerReferralResponse,
|
|
16
|
+
ListCustomerReferralsResponse,
|
|
17
|
+
GetReferralsByPhoneQuery,
|
|
18
|
+
ReferralsByPhoneResponse,
|
|
19
|
+
GetCustomersByPhonesRequest,
|
|
20
|
+
CustomersByPhonesResponse,
|
|
12
21
|
} from "@fiado/type-kit/bin/retailCustomer/index.js";
|
|
13
22
|
import { CustomersBatchRequest, CustomersBatchResponse } from "../dtos/CustomersBatch.js";
|
|
14
23
|
import { CustomersPageQuery, PrivateCustomerListItem } from "../dtos/CustomersPage.js";
|
|
@@ -209,4 +218,43 @@ export interface IRetailCustomerBusinessApi {
|
|
|
209
218
|
query: CustomersPageQuery,
|
|
210
219
|
tenantId: string,
|
|
211
220
|
): Promise<StandardResponse<PaginatedResult<PrivateCustomerListItem>>>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* `POST /private/customers/{id}/referrals` (`privateCreateCustomerReferrals`): lote de referidos del cliente.
|
|
224
|
+
* Rechaza con `DUPLICATE_REFERRAL_PHONE` si un teléfono ya está referido en la cadena.
|
|
225
|
+
*/
|
|
226
|
+
createCustomerReferrals(
|
|
227
|
+
customerId: string,
|
|
228
|
+
payload: CreateCustomerReferralsRequest,
|
|
229
|
+
tenantId: string,
|
|
230
|
+
): Promise<StandardResponse<CreateCustomerReferralsResponse>>;
|
|
231
|
+
|
|
232
|
+
/** `PUT /private/customers/{id}/referrals/{referralId}` (`privateUpdateCustomerReferral`): corrige nombre, teléfono o correo. */
|
|
233
|
+
updateCustomerReferral(
|
|
234
|
+
customerId: string,
|
|
235
|
+
referralId: string,
|
|
236
|
+
payload: UpdateCustomerReferralRequest,
|
|
237
|
+
tenantId: string,
|
|
238
|
+
): Promise<StandardResponse<UpdateCustomerReferralResponse>>;
|
|
239
|
+
|
|
240
|
+
/** `GET /private/customers/{id}/referrals` (`privateListCustomerReferrals`): referidos que capturó el cliente. */
|
|
241
|
+
listCustomerReferrals(
|
|
242
|
+
customerId: string,
|
|
243
|
+
tenantId: string,
|
|
244
|
+
): Promise<StandardResponse<ListCustomerReferralsResponse>>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* `POST /private/referrals/by-phone` (`privateGetReferralsByPhone`): quién recomendó el teléfono en la cadena
|
|
248
|
+
* antes de `before`, del más antiguo al más reciente. Es POST para que el teléfono no viaje en la URL.
|
|
249
|
+
*/
|
|
250
|
+
getReferralsByPhone(
|
|
251
|
+
query: GetReferralsByPhoneQuery,
|
|
252
|
+
tenantId: string,
|
|
253
|
+
): Promise<StandardResponse<ReferralsByPhoneResponse>>;
|
|
254
|
+
|
|
255
|
+
/** `POST /private/customers/by-phones` (`privateGetCustomersByPhones`): qué teléfonos del lote ya son clientes. */
|
|
256
|
+
getCustomersByPhones(
|
|
257
|
+
payload: GetCustomersByPhonesRequest,
|
|
258
|
+
tenantId: string,
|
|
259
|
+
): Promise<StandardResponse<CustomersByPhonesResponse>>;
|
|
212
260
|
}
|
|
@@ -5,6 +5,8 @@ import type {
|
|
|
5
5
|
ActiveSalePromotionsBySkusRequest,
|
|
6
6
|
ActiveSalePromotionsBySkusResponse,
|
|
7
7
|
CheckSalePromotionPaymentRequest,
|
|
8
|
+
GetReferralRewardsByPhonesRequest,
|
|
9
|
+
ReferralRewardsByPhonesResponse,
|
|
8
10
|
PrivateSalePromotionPaymentCheckResponse,
|
|
9
11
|
PrivateReleaseSalePromotionResponse,
|
|
10
12
|
WelcomeBonusPromotionResponse,
|
|
@@ -47,4 +49,12 @@ export default class RetailPromotionsBusinessApi implements IRetailPromotionsBus
|
|
|
47
49
|
async getWelcomeBonus(retailerId: string): Promise<StandardResponse<WelcomeBonusPromotionResponse>> {
|
|
48
50
|
return await this.httpRequest.get(`${this.baseUrl}/private/retailers/${encodeURIComponent(retailerId)}/welcome-bonus`);
|
|
49
51
|
}
|
|
52
|
+
|
|
53
|
+
async getReferralRewardsByPhones(
|
|
54
|
+
tenantId: string,
|
|
55
|
+
input: GetReferralRewardsByPhonesRequest,
|
|
56
|
+
): Promise<StandardResponse<ReferralRewardsByPhonesResponse>> {
|
|
57
|
+
const query = new URLSearchParams({ tenantId });
|
|
58
|
+
return await this.httpRequest.post(`${this.baseUrl}/private/referral-rewards/by-phones?${query.toString()}`, input);
|
|
59
|
+
}
|
|
50
60
|
}
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ActiveSalePromotionsBySkusRequest,
|
|
4
4
|
ActiveSalePromotionsBySkusResponse,
|
|
5
5
|
CheckSalePromotionPaymentRequest,
|
|
6
|
+
GetReferralRewardsByPhonesRequest,
|
|
7
|
+
ReferralRewardsByPhonesResponse,
|
|
6
8
|
PrivateSalePromotionPaymentCheckResponse,
|
|
7
9
|
PrivateReleaseSalePromotionResponse,
|
|
8
10
|
WelcomeBonusPromotionResponse,
|
|
@@ -21,8 +23,9 @@ export interface IRetailPromotionsBusinessApi {
|
|
|
21
23
|
): Promise<StandardResponse<PrivateReleaseSalePromotionResponse>>;
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
|
-
* `POST /private/sessions/{sessionId}/sale-promotion/payment-check`: antes del cobro de contado
|
|
25
|
-
*
|
|
26
|
+
* `POST /private/sessions/{sessionId}/sale-promotion/payment-check`: antes del cobro de contado (con `method`)
|
|
27
|
+
* o del enganche y cierre a crédito (sin `method`, contra la forma de pago de la sesión).
|
|
28
|
+
* 422 `PROMOTION_PAYMENT_NOT_ELIGIBLE` si alguna promo apartada no la acepta.
|
|
26
29
|
*/
|
|
27
30
|
checkSalePromotionPayment(
|
|
28
31
|
tenantId: string,
|
|
@@ -43,4 +46,13 @@ export interface IRetailPromotionsBusinessApi {
|
|
|
43
46
|
* Sin `tenantId`; la siembra si no existe. `active=false` = pausada, el wizard no paga bono.
|
|
44
47
|
*/
|
|
45
48
|
getWelcomeBonus(retailerId: string): Promise<StandardResponse<WelcomeBonusPromotionResponse>>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* `POST /private/referral-rewards/by-phones`: premios de referido por cadena y lote de teléfonos, para el cajón.
|
|
52
|
+
* Un renglón por teléfono pedido; `rewards` vacío si no tiene.
|
|
53
|
+
*/
|
|
54
|
+
getReferralRewardsByPhones(
|
|
55
|
+
tenantId: string,
|
|
56
|
+
input: GetReferralRewardsByPhonesRequest,
|
|
57
|
+
): Promise<StandardResponse<ReferralRewardsByPhonesResponse>>;
|
|
46
58
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { SendMessageCommand, SendMessageRequest, SQSClient } from "@aws-sdk/client-sqs";
|
|
2
2
|
import { injectable } from "inversify";
|
|
3
|
-
import type {
|
|
3
|
+
import type { RetailPromotionQueueMessage } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
4
4
|
import { IRetailPromotionInboundPublisher } from "./interfaces/IRetailPromotionInboundPublisher.js";
|
|
5
5
|
|
|
6
6
|
@injectable()
|
|
7
7
|
export class RetailPromotionInboundPublisher implements IRetailPromotionInboundPublisher {
|
|
8
8
|
private readonly RETAIL_PROMOTION_INBOUND_QUEUE_URL = process.env.RETAIL_PROMOTION_INBOUND_QUEUE_URL;
|
|
9
9
|
|
|
10
|
-
async publish(message:
|
|
10
|
+
async publish(message: RetailPromotionQueueMessage): Promise<void> {
|
|
11
11
|
try {
|
|
12
12
|
const client: SQSClient = new SQSClient();
|
|
13
|
-
// Cola estándar: sin MessageGroupId; el consumidor deduplica por
|
|
13
|
+
// Cola estándar: sin MessageGroupId; el consumidor deduplica por evento.
|
|
14
14
|
const sendMessageRequest: SendMessageRequest = {
|
|
15
15
|
QueueUrl: this.RETAIL_PROMOTION_INBOUND_QUEUE_URL,
|
|
16
16
|
MessageBody: JSON.stringify(message),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RetailPromotionQueueMessage } from "@fiado/type-kit/bin/retailWizard/index.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Publisher hacia `RetailPromotionInboundQueue
|
|
4
|
+
* Publisher hacia `RetailPromotionInboundQueue`, que consume `retail-promotions`: venta, ACCOUNT_OPENED o CREDIT_INSTALLMENT_PAID.
|
|
5
5
|
* Env var requerida en el productor: `RETAIL_PROMOTION_INBOUND_QUEUE_URL`.
|
|
6
6
|
*/
|
|
7
7
|
export interface IRetailPromotionInboundPublisher {
|
|
8
|
-
publish(message:
|
|
8
|
+
publish(message: RetailPromotionQueueMessage): Promise<void>;
|
|
9
9
|
}
|