@fiado/type-kit 3.564.0 → 3.566.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.
Files changed (134) hide show
  1. package/_test_/unit/retailCustomer/customerReferralContract.test.ts +228 -0
  2. package/_test_/unit/retailPromotions/constants.test.ts +1 -1
  3. package/_test_/unit/retailPromotions/referralPromotion.test.ts +177 -0
  4. package/_test_/unit/retailPromotions/referralRewardsByPhones.test.ts +73 -0
  5. package/_test_/unit/retailPromotions/referralWizardContracts.test.ts +119 -0
  6. package/_test_/unit/retailPromotions/salePromotionPaymentCheck.test.ts +29 -0
  7. package/_test_/unit/retailWizard/backofficeCustomerReferrals.test.ts +78 -0
  8. package/_test_/unit/retailWizard/promotionInboundMessages.test.ts +151 -0
  9. package/_test_/unit/retailWizard/referralsCapture.test.ts +66 -0
  10. package/_test_/unit/retailWizard/ventaSagaMessages.test.ts +7 -2
  11. package/bin/retailCustomer/dtos/CustomerReferral.d.ts +25 -0
  12. package/bin/retailCustomer/dtos/CustomerReferral.js +99 -0
  13. package/bin/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.d.ts +19 -0
  14. package/bin/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.js +101 -0
  15. package/bin/retailCustomer/dtos/requests/GetCustomersByPhonesRequest.d.ts +4 -0
  16. package/bin/retailCustomer/dtos/requests/GetCustomersByPhonesRequest.js +28 -0
  17. package/bin/retailCustomer/dtos/requests/GetReferralsByPhoneQuery.d.ts +6 -0
  18. package/bin/retailCustomer/dtos/requests/GetReferralsByPhoneQuery.js +39 -0
  19. package/bin/retailCustomer/dtos/requests/UpdateCustomerReferralRequest.d.ts +8 -0
  20. package/bin/retailCustomer/dtos/requests/UpdateCustomerReferralRequest.js +53 -0
  21. package/bin/retailCustomer/dtos/requests/UpsertPromotionBonusRequest.d.ts +4 -0
  22. package/bin/retailCustomer/dtos/requests/UpsertPromotionBonusRequest.js +15 -0
  23. package/bin/retailCustomer/dtos/responses/CustomerReferralResponses.d.ts +39 -0
  24. package/bin/retailCustomer/dtos/responses/CustomerReferralResponses.js +2 -0
  25. package/bin/retailCustomer/enums/ReferralRoleEnum.d.ts +5 -0
  26. package/bin/retailCustomer/enums/ReferralRoleEnum.js +9 -0
  27. package/bin/retailCustomer/enums/ReferralSourceEnum.d.ts +6 -0
  28. package/bin/retailCustomer/enums/ReferralSourceEnum.js +10 -0
  29. package/bin/retailCustomer/enums/ReferralStatusEnum.d.ts +7 -0
  30. package/bin/retailCustomer/enums/ReferralStatusEnum.js +11 -0
  31. package/bin/retailCustomer/index.d.ts +9 -0
  32. package/bin/retailCustomer/index.js +9 -0
  33. package/bin/retailPromotions/constants/retailPromotionsErrorHttpStatus.js +2 -0
  34. package/bin/retailPromotions/dtos/ReferralPromotion.d.ts +33 -0
  35. package/bin/retailPromotions/dtos/ReferralPromotion.js +2 -0
  36. package/bin/retailPromotions/dtos/SalePromotion.d.ts +3 -0
  37. package/bin/retailPromotions/dtos/requests/CheckSalePromotionPaymentRequest.d.ts +6 -0
  38. package/bin/retailPromotions/dtos/requests/CheckSalePromotionPaymentRequest.js +25 -0
  39. package/bin/retailPromotions/dtos/requests/CreateSalePromotionRequest.d.ts +3 -0
  40. package/bin/retailPromotions/dtos/requests/CreateSalePromotionRequest.js +8 -0
  41. package/bin/retailPromotions/dtos/requests/EvaluateSalePromotionsRequest.d.ts +2 -0
  42. package/bin/retailPromotions/dtos/requests/EvaluateSalePromotionsRequest.js +7 -0
  43. package/bin/retailPromotions/dtos/requests/GetReferralRewardsByPhonesRequest.d.ts +5 -0
  44. package/bin/retailPromotions/dtos/requests/GetReferralRewardsByPhonesRequest.js +34 -0
  45. package/bin/retailPromotions/dtos/requests/ListLiveReferralPromotionsQuery.d.ts +10 -0
  46. package/bin/retailPromotions/dtos/requests/ListLiveReferralPromotionsQuery.js +38 -0
  47. package/bin/retailPromotions/dtos/requests/ListSalePromotionsQuery.d.ts +6 -1
  48. package/bin/retailPromotions/dtos/requests/ListSalePromotionsQuery.js +15 -1
  49. package/bin/retailPromotions/dtos/requests/ReferralPromotionInput.d.ts +24 -0
  50. package/bin/retailPromotions/dtos/requests/ReferralPromotionInput.js +119 -0
  51. package/bin/retailPromotions/dtos/requests/UpdateSalePromotionRequest.d.ts +3 -0
  52. package/bin/retailPromotions/dtos/requests/UpdateSalePromotionRequest.js +8 -0
  53. package/bin/retailPromotions/dtos/responses/LiveReferralPromotionsResponse.d.ts +24 -0
  54. package/bin/retailPromotions/dtos/responses/LiveReferralPromotionsResponse.js +2 -0
  55. package/bin/retailPromotions/dtos/responses/ReferralRewardsByPhonesResponses.d.ts +25 -0
  56. package/bin/retailPromotions/dtos/responses/ReferralRewardsByPhonesResponses.js +2 -0
  57. package/bin/retailPromotions/dtos/responses/SalePromotionPaymentCheckResponses.d.ts +16 -0
  58. package/bin/retailPromotions/dtos/responses/SalePromotionPaymentCheckResponses.js +2 -0
  59. package/bin/retailPromotions/dtos/responses/WizardSalePromotionResponses.d.ts +13 -0
  60. package/bin/retailPromotions/enums/ReferralPromotionChannelEnum.d.ts +5 -0
  61. package/bin/retailPromotions/enums/ReferralPromotionChannelEnum.js +9 -0
  62. package/bin/retailPromotions/enums/ReferralRewardStatusEnum.d.ts +9 -0
  63. package/bin/retailPromotions/enums/ReferralRewardStatusEnum.js +13 -0
  64. package/bin/retailPromotions/enums/ReferralRewardTypeEnum.d.ts +10 -0
  65. package/bin/retailPromotions/enums/ReferralRewardTypeEnum.js +14 -0
  66. package/bin/retailPromotions/enums/ReferralTriggerEnum.d.ts +13 -0
  67. package/bin/retailPromotions/enums/ReferralTriggerEnum.js +17 -0
  68. package/bin/retailPromotions/enums/RetailPromotionsErrorCodeEnum.d.ts +5 -1
  69. package/bin/retailPromotions/enums/RetailPromotionsErrorCodeEnum.js +4 -0
  70. package/bin/retailPromotions/enums/SalePromotionKindEnum.d.ts +3 -2
  71. package/bin/retailPromotions/enums/SalePromotionKindEnum.js +2 -1
  72. package/bin/retailPromotions/index.d.ts +12 -0
  73. package/bin/retailPromotions/index.js +12 -0
  74. package/bin/retailWizard/dtos/responses/BackofficeCustomerReferralsResponse.d.ts +58 -0
  75. package/bin/retailWizard/dtos/responses/BackofficeCustomerReferralsResponse.js +2 -0
  76. package/bin/retailWizard/enums/RetailPromotionInboundMessageTypeEnum.d.ts +4 -2
  77. package/bin/retailWizard/enums/RetailPromotionInboundMessageTypeEnum.js +3 -1
  78. package/bin/retailWizard/enums/WizardStepEnum.d.ts +3 -1
  79. package/bin/retailWizard/enums/WizardStepEnum.js +2 -0
  80. package/bin/retailWizard/events/RetailCommissionInboundMessage.d.ts +7 -0
  81. package/bin/retailWizard/events/RetailCommissionInboundMessage.js +22 -1
  82. package/bin/retailWizard/events/RetailPromotionAccountOpenedMessage.d.ts +15 -0
  83. package/bin/retailWizard/events/RetailPromotionAccountOpenedMessage.js +56 -0
  84. package/bin/retailWizard/events/RetailPromotionInboundMessage.d.ts +15 -0
  85. package/bin/retailWizard/events/RetailPromotionInboundMessage.js +41 -1
  86. package/bin/retailWizard/events/RetailPromotionInstallmentPaidMessage.d.ts +20 -0
  87. package/bin/retailWizard/events/RetailPromotionInstallmentPaidMessage.js +75 -0
  88. package/bin/retailWizard/events/RetailPromotionQueueMessage.d.ts +5 -0
  89. package/bin/retailWizard/events/RetailPromotionQueueMessage.js +2 -0
  90. package/bin/retailWizard/index.d.ts +4 -0
  91. package/bin/retailWizard/index.js +4 -0
  92. package/package.json +1 -1
  93. package/src/retailCustomer/dtos/CustomerReferral.ts +77 -0
  94. package/src/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.ts +91 -0
  95. package/src/retailCustomer/dtos/requests/GetCustomersByPhonesRequest.ts +15 -0
  96. package/src/retailCustomer/dtos/requests/GetReferralsByPhoneQuery.ts +23 -0
  97. package/src/retailCustomer/dtos/requests/UpdateCustomerReferralRequest.ts +38 -0
  98. package/src/retailCustomer/dtos/requests/UpsertPromotionBonusRequest.ts +15 -1
  99. package/src/retailCustomer/dtos/responses/CustomerReferralResponses.ts +46 -0
  100. package/src/retailCustomer/enums/ReferralRoleEnum.ts +5 -0
  101. package/src/retailCustomer/enums/ReferralSourceEnum.ts +6 -0
  102. package/src/retailCustomer/enums/ReferralStatusEnum.ts +7 -0
  103. package/src/retailCustomer/index.ts +9 -0
  104. package/src/retailPromotions/constants/retailPromotionsErrorHttpStatus.ts +2 -0
  105. package/src/retailPromotions/dtos/ReferralPromotion.ts +35 -0
  106. package/src/retailPromotions/dtos/SalePromotion.ts +3 -0
  107. package/src/retailPromotions/dtos/requests/CheckSalePromotionPaymentRequest.ts +12 -0
  108. package/src/retailPromotions/dtos/requests/CreateSalePromotionRequest.ts +8 -0
  109. package/src/retailPromotions/dtos/requests/EvaluateSalePromotionsRequest.ts +7 -0
  110. package/src/retailPromotions/dtos/requests/GetReferralRewardsByPhonesRequest.ts +20 -0
  111. package/src/retailPromotions/dtos/requests/ListLiveReferralPromotionsQuery.ts +24 -0
  112. package/src/retailPromotions/dtos/requests/ListSalePromotionsQuery.ts +14 -1
  113. package/src/retailPromotions/dtos/requests/ReferralPromotionInput.ts +93 -0
  114. package/src/retailPromotions/dtos/requests/UpdateSalePromotionRequest.ts +8 -0
  115. package/src/retailPromotions/dtos/responses/LiveReferralPromotionsResponse.ts +26 -0
  116. package/src/retailPromotions/dtos/responses/ReferralRewardsByPhonesResponses.ts +28 -0
  117. package/src/retailPromotions/dtos/responses/SalePromotionPaymentCheckResponses.ts +17 -0
  118. package/src/retailPromotions/dtos/responses/WizardSalePromotionResponses.ts +15 -0
  119. package/src/retailPromotions/enums/ReferralPromotionChannelEnum.ts +5 -0
  120. package/src/retailPromotions/enums/ReferralRewardStatusEnum.ts +9 -0
  121. package/src/retailPromotions/enums/ReferralRewardTypeEnum.ts +10 -0
  122. package/src/retailPromotions/enums/ReferralTriggerEnum.ts +13 -0
  123. package/src/retailPromotions/enums/RetailPromotionsErrorCodeEnum.ts +4 -0
  124. package/src/retailPromotions/enums/SalePromotionKindEnum.ts +2 -1
  125. package/src/retailPromotions/index.ts +12 -0
  126. package/src/retailWizard/dtos/responses/BackofficeCustomerReferralsResponse.ts +63 -0
  127. package/src/retailWizard/enums/RetailPromotionInboundMessageTypeEnum.ts +3 -1
  128. package/src/retailWizard/enums/WizardStepEnum.ts +2 -0
  129. package/src/retailWizard/events/RetailCommissionInboundMessage.ts +18 -0
  130. package/src/retailWizard/events/RetailPromotionAccountOpenedMessage.ts +38 -0
  131. package/src/retailWizard/events/RetailPromotionInboundMessage.ts +43 -1
  132. package/src/retailWizard/events/RetailPromotionInstallmentPaidMessage.ts +53 -0
  133. package/src/retailWizard/events/RetailPromotionQueueMessage.ts +9 -0
  134. package/src/retailWizard/index.ts +4 -0
@@ -0,0 +1,46 @@
1
+ import { CustomerReferral } from '../CustomerReferral';
2
+ import { AccountStatusEnum } from '../../enums/AccountStatusEnum';
3
+ import { ReferralSourceEnum } from '../../enums/ReferralSourceEnum';
4
+
5
+ /** Respuesta de `privateCreateCustomerReferrals`. */
6
+ export interface CreateCustomerReferralsResponse {
7
+ referrals: CustomerReferral[];
8
+ }
9
+
10
+ /** Respuesta de `privateUpdateCustomerReferral`. */
11
+ export interface UpdateCustomerReferralResponse {
12
+ referral: CustomerReferral;
13
+ }
14
+
15
+ /** Respuesta de `privateListCustomerReferrals`. */
16
+ export interface ListCustomerReferralsResponse {
17
+ referrals: CustomerReferral[];
18
+ }
19
+
20
+ /** Quién recomendó un teléfono. */
21
+ export interface ReferralByPhone {
22
+ referralId: string;
23
+ referrerCustomerId: string;
24
+ referrerName: string;
25
+ source: ReferralSourceEnum;
26
+ capturedAt: string;
27
+ }
28
+
29
+ /** Respuesta de `privateGetReferralsByPhone`, del más antiguo al más reciente. */
30
+ export interface ReferralsByPhoneResponse {
31
+ referrals: ReferralByPhone[];
32
+ }
33
+
34
+ /** Teléfono que ya es cliente. */
35
+ export interface CustomerByPhone {
36
+ phone: string;
37
+ retailCustomerId: string;
38
+ retailerId: string;
39
+ /** `null` si la cuenta PCF aún no se pide. */
40
+ accountStatus: AccountStatusEnum | null;
41
+ }
42
+
43
+ /** Respuesta de `privateGetCustomersByPhones`; los teléfonos que no son clientes no aparecen. */
44
+ export interface CustomersByPhonesResponse {
45
+ customers: CustomerByPhone[];
46
+ }
@@ -0,0 +1,5 @@
1
+ /** A quién premia una promo de referido: a quien recomienda o al recomendado. */
2
+ export enum ReferralRoleEnum {
3
+ REFERRER = 'REFERRER',
4
+ REFERRED = 'REFERRED',
5
+ }
@@ -0,0 +1,6 @@
1
+ /** Dónde se capturó un referido: en la venta, en la apertura sin venta o en el cajón del cliente. */
2
+ export enum ReferralSourceEnum {
3
+ SALE = 'SALE',
4
+ OPENING = 'OPENING',
5
+ BACKOFFICE = 'BACKOFFICE',
6
+ }
@@ -0,0 +1,7 @@
1
+ /** Estado del referido en el cajón: aún no compra, abrió su cuenta, ya compró o tiene crédito SureKeep. */
2
+ export enum ReferralStatusEnum {
3
+ NOT_PURCHASED = 'NOT_PURCHASED',
4
+ ACCOUNT_OPENED = 'ACCOUNT_OPENED',
5
+ PURCHASED = 'PURCHASED',
6
+ SUREKEEP_CREDIT = 'SUREKEEP_CREDIT',
7
+ }
@@ -9,11 +9,15 @@ export * from './enums/WelcomeBonusStatusEnum';
9
9
  export * from './enums/WelcomeBonusAmountSourceEnum';
10
10
  export * from './enums/WelcomeBonusSettlementStatusEnum';
11
11
  export * from './enums/BonusTypeEnum';
12
+ export * from './enums/ReferralSourceEnum';
13
+ export * from './enums/ReferralStatusEnum';
14
+ export * from './enums/ReferralRoleEnum';
12
15
 
13
16
  // Entidades (planas, con class-validator + @Expose)
14
17
  export * from './dtos/KycReview';
15
18
  export * from './dtos/RetailAddress';
16
19
  export * from './dtos/RetailCustomer';
20
+ export * from './dtos/CustomerReferral';
17
21
 
18
22
  // Request DTOs (input validado por endpoint)
19
23
  export * from './dtos/requests/CreateCustomerRequest';
@@ -24,6 +28,10 @@ export * from './dtos/requests/KycReviewRequest';
24
28
  export * from './dtos/requests/WelcomeAccreditationRequest';
25
29
  export * from './dtos/requests/WelcomeAccreditationResultRequest';
26
30
  export * from './dtos/requests/UpsertPromotionBonusRequest';
31
+ export * from './dtos/requests/CreateCustomerReferralsRequest';
32
+ export * from './dtos/requests/UpdateCustomerReferralRequest';
33
+ export * from './dtos/requests/GetCustomersByPhonesRequest';
34
+ export * from './dtos/requests/GetReferralsByPhoneQuery';
27
35
 
28
36
  // Response DTOs
29
37
  export * from './dtos/responses/CustomerResponse';
@@ -31,6 +39,7 @@ export * from './dtos/responses/Customer360Response';
31
39
  export * from './dtos/responses/WelcomeBonusResponse';
32
40
  export * from './dtos/responses/WelcomeAccreditationResponse';
33
41
  export * from './dtos/responses/PromotionBonusEntryResponse';
42
+ export * from './dtos/responses/CustomerReferralResponses';
34
43
 
35
44
  // Contratos de eventos (PascalCase + sufijo V1)
36
45
  export * from './events/CustomerCreatedV1';
@@ -36,4 +36,6 @@ export const RETAIL_PROMOTIONS_ERROR_HTTP_STATUS: Readonly<Record<C, 400 | 403 |
36
36
  [C.PROMOTION_PAYMENT_NOT_ELIGIBLE]: 422,
37
37
  [C.SYSTEM_PROMOTION_TRANSITION_NOT_ALLOWED]: 422,
38
38
  [C.SYSTEM_PROMOTION_FIELD_LOCKED]: 422,
39
+ [C.REFERRAL_REWARD_NEEDS_PURCHASE]: 422,
40
+ [C.INVALID_REFERRAL_TRIGGER]: 400,
39
41
  };
@@ -0,0 +1,35 @@
1
+ import { ReferralPromotionChannelEnum } from '../enums/ReferralPromotionChannelEnum';
2
+ import { ReferralRewardTypeEnum } from '../enums/ReferralRewardTypeEnum';
3
+ import { ReferralTriggerEnum } from '../enums/ReferralTriggerEnum';
4
+ import { CouponLever } from './SalePromotionLevers';
5
+
6
+ /** Premio de un rol; solo trae valor el campo que corresponde a su `type`. */
7
+ export interface ReferralReward {
8
+ type: ReferralRewardTypeEnum;
9
+ /** `FIXED_BONUS`. */
10
+ amountCents: number | null;
11
+ /** `PERCENT_BONUS` y `SALE_DISCOUNT`; 1000 = 10%. */
12
+ percentBps: number | null;
13
+ /** Tope del %; `null` = sin tope. */
14
+ maxAmountCents: number | null;
15
+ /** `COUPON`. */
16
+ coupon: CouponLever | null;
17
+ }
18
+
19
+ /** Evento, condiciones y premios de una promo `REFERRAL`; forma de pago, gama, vigencia y presupuesto son los de la promo. */
20
+ export interface ReferralPromotionConfig {
21
+ channel: ReferralPromotionChannelEnum;
22
+ trigger: ReferralTriggerEnum;
23
+ /** Solo en `NTH_PURCHASE`. */
24
+ purchaseNumber: number | null;
25
+ /** Solo en `INSTALLMENT_STREAK`. */
26
+ installmentStreak: number | null;
27
+ /** Monto mínimo de la compra o del crédito. */
28
+ minAmountCents: number | null;
29
+ /** Días desde la captura del referido. */
30
+ windowDays: number | null;
31
+ maxRewardsPerReferrer: number | null;
32
+ referrerReward: ReferralReward;
33
+ /** `null` = el recomendado no gana nada. */
34
+ referredReward: ReferralReward | null;
35
+ }
@@ -3,6 +3,7 @@ import { PromotionPaymentOptionEnum } from '../enums/PromotionPaymentOptionEnum'
3
3
  import { SalePromotionPhaseEnum } from '../enums/SalePromotionPhaseEnum';
4
4
  import { SalePromotionStatusEnum } from '../enums/SalePromotionStatusEnum';
5
5
  import { SalePromotionSystemKeyEnum } from '../enums/SalePromotionSystemKeyEnum';
6
+ import { ReferralPromotionConfig } from './ReferralPromotion';
6
7
  import { SalePromotionLevers, SalePromotionScope, SalePromotionSegmentation } from './SalePromotionLevers';
7
8
 
8
9
  /** Promo de venta tal como la devuelve el CRUD. Dinero en centavos, fechas ISO. */
@@ -31,6 +32,8 @@ export interface SalePromotion {
31
32
  oncePerCustomer: boolean;
32
33
  /** Si se puede sumar con otras promos en la misma línea. */
33
34
  stackable: boolean;
35
+ /** Solo en promos `REFERRAL`. */
36
+ referral?: ReferralPromotionConfig | null;
34
37
  status: SalePromotionStatusEnum;
35
38
  /** Derivada; `null` cuando el estado no es `ACTIVE`. */
36
39
  phase: SalePromotionPhaseEnum | null;
@@ -0,0 +1,12 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsOptional } from 'class-validator';
3
+ import { SalePaymentMethodEnum } from '../../../retailWizard/enums/SalePaymentMethodEnum';
4
+
5
+ /** Body de `POST /private/sessions/{sessionId}/sale-promotion/payment-check` (M2M). */
6
+ export class CheckSalePromotionPaymentRequest {
7
+ /** Medio del cobro de contado; ausente = se valida contra la forma de pago de la sesión (enganche o cierre a crédito). */
8
+ @Expose()
9
+ @IsOptional()
10
+ @IsEnum(SalePaymentMethodEnum)
11
+ method?: SalePaymentMethodEnum;
12
+ }
@@ -13,6 +13,7 @@ import {
13
13
  } from 'class-validator';
14
14
  import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
15
15
  import { PromotionPaymentOptionEnum } from '../../enums/PromotionPaymentOptionEnum';
16
+ import { ReferralPromotionInput } from './ReferralPromotionInput';
16
17
  import { SalePromotionLeversInput } from './SalePromotionLeversInput';
17
18
  import { SalePromotionScopeInput, SalePromotionSegmentationInput } from './SalePromotionScopeInput';
18
19
 
@@ -85,4 +86,11 @@ export class CreateSalePromotionRequest {
85
86
  @IsOptional()
86
87
  @IsBoolean()
87
88
  stackable?: boolean;
89
+
90
+ /** Evento, condiciones y premios de la promo de referido; ausente en las demás promos. */
91
+ @Expose()
92
+ @IsOptional()
93
+ @ValidateNested()
94
+ @Type(() => ReferralPromotionInput)
95
+ referral?: ReferralPromotionInput | null;
88
96
  }
@@ -13,4 +13,11 @@ export class EvaluateSalePromotionsRequest {
13
13
  @IsString()
14
14
  @IsNotEmpty()
15
15
  discountCode?: string | null;
16
+
17
+ /** Teléfono del cliente de la venta; con él se sabe si llegó recomendado. */
18
+ @Expose()
19
+ @IsOptional()
20
+ @IsString()
21
+ @IsNotEmpty()
22
+ phone?: string;
16
23
  }
@@ -0,0 +1,20 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { ArrayMaxSize, ArrayMinSize, IsArray, IsNotEmpty, IsString } from 'class-validator';
3
+
4
+ const REWARD_PHONES_MAX_BATCH = 100;
5
+
6
+ /** Body de la ruta privada de premios de referido por cadena y lote de teléfonos (normalizados a 10 dígitos). */
7
+ export class GetReferralRewardsByPhonesRequest {
8
+ @Expose()
9
+ @IsString()
10
+ @IsNotEmpty()
11
+ retailerId!: string;
12
+
13
+ @Expose()
14
+ @IsArray()
15
+ @ArrayMinSize(1)
16
+ @ArrayMaxSize(REWARD_PHONES_MAX_BATCH)
17
+ @IsString({ each: true })
18
+ @IsNotEmpty({ each: true })
19
+ phones!: string[];
20
+ }
@@ -0,0 +1,24 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
3
+ import { ReferralPromotionChannelEnum } from '../../enums/ReferralPromotionChannelEnum';
4
+ import { ReferralTriggerEnum } from '../../enums/ReferralTriggerEnum';
5
+
6
+ /** Query de las promos de referido vigentes del paso Referidos; la tienda sale de la sesión. */
7
+ export class ListLiveReferralPromotionsQuery {
8
+ @Expose()
9
+ @IsString()
10
+ @IsNotEmpty()
11
+ sessionId!: string;
12
+
13
+ /** Sin canal: venta y crédito. */
14
+ @Expose()
15
+ @IsOptional()
16
+ @IsEnum(ReferralPromotionChannelEnum)
17
+ channel?: ReferralPromotionChannelEnum;
18
+
19
+ /** `ACCOUNT_OPENED` en una apertura sin venta: solo las que se ganan al abrir cuenta. */
20
+ @Expose()
21
+ @IsOptional()
22
+ @IsEnum(ReferralTriggerEnum)
23
+ trigger?: ReferralTriggerEnum;
24
+ }
@@ -1,14 +1,27 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
2
  import { IsEnum, IsInt, IsOptional, IsString, Max, Min } from 'class-validator';
3
+ import { ReferralPromotionChannelEnum } from '../../enums/ReferralPromotionChannelEnum';
4
+ import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
3
5
  import { SalePromotionStatusEnum } from '../../enums/SalePromotionStatusEnum';
4
6
 
5
- /** Query de publicListSalePromotions; sin `status` excluye las archivadas. */
7
+ /** Query de publicListSalePromotions; sin `status` excluye las archivadas y sin `kind` las de referido. */
6
8
  export class ListSalePromotionsQuery {
7
9
  @Expose()
8
10
  @IsOptional()
9
11
  @IsEnum(SalePromotionStatusEnum)
10
12
  status?: SalePromotionStatusEnum;
11
13
 
14
+ @Expose()
15
+ @IsOptional()
16
+ @IsEnum(SalePromotionKindEnum)
17
+ kind?: SalePromotionKindEnum;
18
+
19
+ /** Canal de las promos de referido. */
20
+ @Expose()
21
+ @IsOptional()
22
+ @IsEnum(ReferralPromotionChannelEnum)
23
+ channel?: ReferralPromotionChannelEnum;
24
+
12
25
  @Expose()
13
26
  @IsOptional()
14
27
  @Type(() => Number)
@@ -0,0 +1,93 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsDefined, IsEnum, IsInt, IsOptional, Max, Min, ValidateIf, ValidateNested } from 'class-validator';
3
+ import { ReferralPromotionChannelEnum } from '../../enums/ReferralPromotionChannelEnum';
4
+ import { ReferralRewardTypeEnum } from '../../enums/ReferralRewardTypeEnum';
5
+ import { ReferralTriggerEnum } from '../../enums/ReferralTriggerEnum';
6
+ import { CouponLeverInput } from './SalePromotionLeversInput';
7
+
8
+ const isPercentReward = (o: ReferralRewardInput): boolean =>
9
+ o.type === ReferralRewardTypeEnum.PERCENT_BONUS || o.type === ReferralRewardTypeEnum.SALE_DISCOUNT;
10
+
11
+ /** Premio de un rol en el body: exige el campo de su `type`. Qué premio vale con qué evento lo valida el lambda (422). */
12
+ export class ReferralRewardInput {
13
+ @Expose()
14
+ @IsEnum(ReferralRewardTypeEnum)
15
+ type!: ReferralRewardTypeEnum;
16
+
17
+ @Expose()
18
+ @ValidateIf((o: ReferralRewardInput) => o.type === ReferralRewardTypeEnum.FIXED_BONUS)
19
+ @IsInt()
20
+ @Min(1)
21
+ amountCents?: number | null;
22
+
23
+ @Expose()
24
+ @ValidateIf(isPercentReward)
25
+ @IsInt()
26
+ @Min(1)
27
+ @Max(10000)
28
+ percentBps?: number | null;
29
+
30
+ @Expose()
31
+ @IsOptional()
32
+ @IsInt()
33
+ @Min(1)
34
+ maxAmountCents?: number | null;
35
+
36
+ @Expose()
37
+ @ValidateIf((o: ReferralRewardInput) => o.type === ReferralRewardTypeEnum.COUPON)
38
+ @IsDefined()
39
+ @ValidateNested()
40
+ @Type(() => CouponLeverInput)
41
+ coupon?: CouponLeverInput | null;
42
+ }
43
+
44
+ /** Bloque `referral` del body de la promo; su presencia la vuelve `REFERRAL`. Compra N y racha ≥ 2 los valida el lambda. */
45
+ export class ReferralPromotionInput {
46
+ @Expose()
47
+ @IsEnum(ReferralPromotionChannelEnum)
48
+ channel!: ReferralPromotionChannelEnum;
49
+
50
+ @Expose()
51
+ @IsEnum(ReferralTriggerEnum)
52
+ trigger!: ReferralTriggerEnum;
53
+
54
+ @Expose()
55
+ @IsOptional()
56
+ @IsInt()
57
+ purchaseNumber?: number | null;
58
+
59
+ @Expose()
60
+ @IsOptional()
61
+ @IsInt()
62
+ installmentStreak?: number | null;
63
+
64
+ @Expose()
65
+ @IsOptional()
66
+ @IsInt()
67
+ @Min(1)
68
+ minAmountCents?: number | null;
69
+
70
+ @Expose()
71
+ @IsOptional()
72
+ @IsInt()
73
+ @Min(1)
74
+ windowDays?: number | null;
75
+
76
+ @Expose()
77
+ @IsOptional()
78
+ @IsInt()
79
+ @Min(1)
80
+ maxRewardsPerReferrer?: number | null;
81
+
82
+ @Expose()
83
+ @IsDefined()
84
+ @ValidateNested()
85
+ @Type(() => ReferralRewardInput)
86
+ referrerReward!: ReferralRewardInput;
87
+
88
+ @Expose()
89
+ @IsOptional()
90
+ @ValidateNested()
91
+ @Type(() => ReferralRewardInput)
92
+ referredReward?: ReferralRewardInput | null;
93
+ }
@@ -12,6 +12,7 @@ import {
12
12
  } from 'class-validator';
13
13
  import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
14
14
  import { PromotionPaymentOptionEnum } from '../../enums/PromotionPaymentOptionEnum';
15
+ import { ReferralPromotionInput } from './ReferralPromotionInput';
15
16
  import { SalePromotionLeversInput } from './SalePromotionLeversInput';
16
17
  import { SalePromotionScopeInput, SalePromotionSegmentationInput } from './SalePromotionScopeInput';
17
18
 
@@ -86,4 +87,11 @@ export class UpdateSalePromotionRequest {
86
87
  @IsOptional()
87
88
  @IsBoolean()
88
89
  stackable?: boolean;
90
+
91
+ /** Evento, condiciones y premios de la promo de referido; ausente en las demás promos. */
92
+ @Expose()
93
+ @IsOptional()
94
+ @ValidateNested()
95
+ @Type(() => ReferralPromotionInput)
96
+ referral?: ReferralPromotionInput | null;
89
97
  }
@@ -0,0 +1,26 @@
1
+ import { ReferralPromotionChannelEnum } from '../../enums/ReferralPromotionChannelEnum';
2
+ import { ReferralTriggerEnum } from '../../enums/ReferralTriggerEnum';
3
+ import { ReferralReward } from '../ReferralPromotion';
4
+
5
+ /** Promo de referido vigente para el paso Referidos: «tú ganas» y «tu amigo gana». */
6
+ export interface LiveReferralPromotionItem {
7
+ promotionId: string;
8
+ version: number;
9
+ name: string;
10
+ customerText: string;
11
+ channel: ReferralPromotionChannelEnum;
12
+ trigger: ReferralTriggerEnum;
13
+ /** Solo en `NTH_PURCHASE`. */
14
+ purchaseNumber: number | null;
15
+ /** Solo en `INSTALLMENT_STREAK`. */
16
+ installmentStreak: number | null;
17
+ /** Fin de vigencia; `null` = sin fecha de fin. */
18
+ validUntil: string | null;
19
+ referrerReward: ReferralReward;
20
+ /** `null` = el recomendado no gana nada. */
21
+ referredReward: ReferralReward | null;
22
+ }
23
+
24
+ export interface ListLiveReferralPromotionsResponse {
25
+ items: LiveReferralPromotionItem[];
26
+ }
@@ -0,0 +1,28 @@
1
+ import { ReferralRoleEnum } from '../../../retailCustomer/enums/ReferralRoleEnum';
2
+ import { ReferralRewardStatusEnum } from '../../enums/ReferralRewardStatusEnum';
3
+ import { ReferralRewardTypeEnum } from '../../enums/ReferralRewardTypeEnum';
4
+
5
+ /** Premio de referido de un teléfono en una promo (candado REWARD#). Sin PII. */
6
+ export interface ReferralRewardByPhone {
7
+ promotionId: string;
8
+ promotionName: string;
9
+ referralId: string;
10
+ role: ReferralRoleEnum;
11
+ rewardType: ReferralRewardTypeEnum;
12
+ /** `null` si el premio no tiene monto en centavos. */
13
+ amountCents: number | null;
14
+ status: ReferralRewardStatusEnum;
15
+ /** Fecha del estado: pago, reserva o anulación. */
16
+ statusAt: string;
17
+ }
18
+
19
+ /** Premios de un teléfono; vacío si no tiene. */
20
+ export interface ReferralRewardsOfPhone {
21
+ phone: string;
22
+ rewards: ReferralRewardByPhone[];
23
+ }
24
+
25
+ /** Respuesta de la ruta privada de premios por cadena y lote de teléfonos. */
26
+ export interface ReferralRewardsByPhonesResponse {
27
+ phones: ReferralRewardsOfPhone[];
28
+ }
@@ -0,0 +1,17 @@
1
+ /** 200 de privateCheckSalePromotionPayment: todas las promos apartadas admiten el medio. */
2
+ export interface PrivateSalePromotionPaymentCheckResponse {
3
+ sessionId: string;
4
+ /** Promos apartadas que se revisaron; vacía si la sesión no tiene promo. */
5
+ checkedPromotionIds: string[];
6
+ }
7
+
8
+ /** `data` del 422 PROMOTION_PAYMENT_NOT_ELIGIBLE; las listas van separadas por coma. */
9
+ export interface PromotionPaymentNotEligibleDetails {
10
+ /** Todas las promos que no admiten el medio. */
11
+ promotionIds: string;
12
+ /** La primera de ellas, para el copy. */
13
+ promotionId: string;
14
+ promotionName: string;
15
+ /** `PromotionPaymentOptionEnum` que acepta esa promo. */
16
+ acceptedOptions: string;
17
+ }
@@ -9,6 +9,7 @@ import { SaleCouponAvailabilityEnum } from '../../enums/SaleCouponAvailabilityEn
9
9
  import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
10
10
  import { SalePromotionLeverEnum } from '../../enums/SalePromotionLeverEnum';
11
11
  import { DiscountValue } from '../DiscountValue';
12
+ import { ReferralReward } from '../ReferralPromotion';
12
13
  import { LinePromotionDiscount } from '../LinePromotionDiscount';
13
14
  import { SalePromotionLevers, SalePromotionScope } from '../SalePromotionLevers';
14
15
 
@@ -99,9 +100,23 @@ export interface EvaluatedDiscountCode {
99
100
  totalDiscountCents: number;
100
101
  }
101
102
 
103
+ /** Lo que gana el recomendado en una promo de referido vigente. */
104
+ export interface EvaluatedReferredReward {
105
+ promotionId: string;
106
+ promotionName: string;
107
+ reward: ReferralReward;
108
+ }
109
+
110
+ /** Quién recomendó al cliente; solo viene si alguna promo vigente le da algo al recomendado. */
111
+ export interface EvaluatedReferredBy {
112
+ name: string;
113
+ rewards?: EvaluatedReferredReward[];
114
+ }
115
+
102
116
  export interface EvaluateSalePromotionsResponse {
103
117
  promotions: EvaluatedSalePromotion[];
104
118
  discountCode: EvaluatedDiscountCode | null;
119
+ referredBy?: EvaluatedReferredBy | null;
105
120
  }
106
121
 
107
122
  /** Promo de regalo del teléfono que quedó apartada. */
@@ -0,0 +1,5 @@
1
+ /** Dónde vive la promo de referido: en promos de venta o en promos de crédito. */
2
+ export enum ReferralPromotionChannelEnum {
3
+ SALE = 'SALE',
4
+ CREDIT = 'CREDIT',
5
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Estado del premio de referido en el cajón. Del libro: ACCREDITED → PAID; PENDING y UNVERIFIED → PENDING;
3
+ * FAILED o entrega anulada → NOT_APPLICABLE.
4
+ */
5
+ export enum ReferralRewardStatusEnum {
6
+ PAID = 'PAID',
7
+ PENDING = 'PENDING',
8
+ NOT_APPLICABLE = 'NOT_APPLICABLE',
9
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Premio de referido: bono fijo o % de lo que paga el referido (con tope) a cuenta PCF, cupón (solo venta)
3
+ * o descuento en esta venta (solo el recomendado, solo venta).
4
+ */
5
+ export enum ReferralRewardTypeEnum {
6
+ FIXED_BONUS = 'FIXED_BONUS',
7
+ PERCENT_BONUS = 'PERCENT_BONUS',
8
+ COUPON = 'COUPON',
9
+ SALE_DISCOUNT = 'SALE_DISCOUNT',
10
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Evento del referido que paga la promo. Venta: FIRST_PURCHASE, ACCOUNT_OPENED, ANY_PURCHASE, NTH_PURCHASE.
3
+ * Crédito: CREDIT_ACTIVATED, FIRST_INSTALLMENT, INSTALLMENT_STREAK.
4
+ */
5
+ export enum ReferralTriggerEnum {
6
+ FIRST_PURCHASE = 'FIRST_PURCHASE',
7
+ ACCOUNT_OPENED = 'ACCOUNT_OPENED',
8
+ ANY_PURCHASE = 'ANY_PURCHASE',
9
+ NTH_PURCHASE = 'NTH_PURCHASE',
10
+ CREDIT_ACTIVATED = 'CREDIT_ACTIVATED',
11
+ FIRST_INSTALLMENT = 'FIRST_INSTALLMENT',
12
+ INSTALLMENT_STREAK = 'INSTALLMENT_STREAK',
13
+ }
@@ -53,4 +53,8 @@ export enum RetailPromotionsErrorCodeEnum {
53
53
  SYSTEM_PROMOTION_TRANSITION_NOT_ALLOWED = 'SYSTEM_PROMOTION_TRANSITION_NOT_ALLOWED',
54
54
  /** De la promo de sistema solo se edita el monto del bono. */
55
55
  SYSTEM_PROMOTION_FIELD_LOCKED = 'SYSTEM_PROMOTION_FIELD_LOCKED',
56
+ /** La promo de apertura de cuenta eligió un premio que depende de la compra. */
57
+ REFERRAL_REWARD_NEEDS_PURCHASE = 'REFERRAL_REWARD_NEEDS_PURCHASE',
58
+ /** Evento de referido inválido: compra N o racha menor a 2, o evento de otro canal. */
59
+ INVALID_REFERRAL_TRIGGER = 'INVALID_REFERRAL_TRIGGER',
56
60
  }
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Tipo de promo en el apartado: GIFT solo trae regalo y va ligada al teléfono; SALE es cualquier otra.
2
+ * Tipo de promo: GIFT solo trae regalo y va ligada al teléfono; REFERRAL premia por un referido; SALE es cualquier otra.
3
3
  * @enum {string}
4
4
  */
5
5
  export enum SalePromotionKindEnum {
6
6
  GIFT = 'GIFT',
7
7
  SALE = 'SALE',
8
+ REFERRAL = 'REFERRAL',
8
9
  }
@@ -21,6 +21,10 @@ export * from './enums/RetailPromotionsErrorCodeEnum';
21
21
  export * from './enums/SalePromotionKindEnum';
22
22
  export * from './enums/SkuSalePromotionLookupStatusEnum';
23
23
  export * from './enums/SalePromotionSystemKeyEnum';
24
+ export * from './enums/ReferralPromotionChannelEnum';
25
+ export * from './enums/ReferralTriggerEnum';
26
+ export * from './enums/ReferralRewardTypeEnum';
27
+ export * from './enums/ReferralRewardStatusEnum';
24
28
 
25
29
  // Constantes y helpers puros
26
30
  export * from './constants/retailPromotionsErrorHttpStatus';
@@ -40,6 +44,7 @@ export * from './dtos/DiscountCode';
40
44
  export * from './dtos/LinePromotionDiscount';
41
45
  export * from './dtos/LinePromotionAmount';
42
46
  export * from './dtos/SalePromotionRef';
47
+ export * from './dtos/ReferralPromotion';
43
48
 
44
49
  // Validadores
45
50
  export * from './validators/IsHoldModeExclusiveConstraint';
@@ -48,6 +53,7 @@ export * from './validators/IsHoldModeExclusiveConstraint';
48
53
  export * from './dtos/requests/DiscountValueInput';
49
54
  export * from './dtos/requests/SalePromotionLeversInput';
50
55
  export * from './dtos/requests/SalePromotionScopeInput';
56
+ export * from './dtos/requests/ReferralPromotionInput';
51
57
  export * from './dtos/requests/CreateSalePromotionRequest';
52
58
  export * from './dtos/requests/UpdateSalePromotionRequest';
53
59
  export * from './dtos/requests/ChangeSalePromotionStatusRequest';
@@ -64,6 +70,9 @@ export * from './dtos/requests/HoldSalePromotionRequest';
64
70
  export * from './dtos/requests/GetSaleCouponQuery';
65
71
  export * from './dtos/requests/SkuSalePromotionsQuery';
66
72
  export * from './dtos/requests/ActiveSalePromotionsBySkusRequest';
73
+ export * from './dtos/requests/CheckSalePromotionPaymentRequest';
74
+ export * from './dtos/requests/GetReferralRewardsByPhonesRequest';
75
+ export * from './dtos/requests/ListLiveReferralPromotionsQuery';
67
76
 
68
77
  // Response DTOs
69
78
  export * from './dtos/responses/SalePromotionCrudResponses';
@@ -73,3 +82,6 @@ export * from './dtos/responses/SkuSalePromotionsResponse';
73
82
  export * from './dtos/responses/SalePromotionSegmentsResponse';
74
83
  export * from './dtos/responses/ActiveSalePromotionsBySkusResponse';
75
84
  export * from './dtos/responses/WelcomeBonusPromotionResponse';
85
+ export * from './dtos/responses/SalePromotionPaymentCheckResponses';
86
+ export * from './dtos/responses/ReferralRewardsByPhonesResponses';
87
+ export * from './dtos/responses/LiveReferralPromotionsResponse';