@voucherify/sdk 2.0.3 → 2.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f411c1a`](https://github.com/voucherifyio/voucherify-js-sdk/commit/f411c1a56085d80560fdca634e5fdc059a556091) [#119](https://github.com/voucherifyio/voucherify-js-sdk/pull/119) Thanks [@darekg11](https://github.com/darekg11)! - Added support for stackable API methods - validation, redemptions, rollback for both Server Side and Client Side SDKs. Added some missing fields in already existing types definitions and cleaned up other definitions by reusing interfaces
8
+
3
9
  ## 2.0.3
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -362,6 +362,7 @@ Methods are provided within `client.validations.*` or `client.promotions.*` name
362
362
 
363
363
  - [Validate Voucher](#validate-voucher)
364
364
  - [Validate Promotion Campaign](#validate-promotion-campaign)
365
+ - [Validate Stackable](#validate-stackable)
365
366
 
366
367
  #### [Validate Voucher](https://docs.voucherify.io/reference/validate-voucher)
367
368
 
@@ -389,6 +390,11 @@ Other possibility
389
390
  client.validations.validate(params)
390
391
  ```
391
392
 
393
+ #### [Validate Stackable](https://docs.voucherify.io/reference/validate-stacked-discounts-1)
394
+ ```javascript
395
+ client.validations.validateStackable(params)
396
+ ```
397
+
392
398
  ---
393
399
 
394
400
  ### Redemptions
@@ -396,12 +402,14 @@ client.validations.validate(params)
396
402
  Methods are provided within `client.redemptions.*` namespace.
397
403
 
398
404
  - [Redeem Voucher](#redeem-voucher)
405
+ - [Redeem Stackable](#redeem-stackable)
399
406
  - [Get Redemption](#get-redemption)
400
407
  - [Redeem Promotion's Tier](#redeem-promotions-tier)
401
408
  - [Redeem Loyalty Card](#redeem-loyalty-card)
402
409
  - [List Redemptions](#list-redemptions)
403
410
  - [Get Voucher's Redemptions](#get-vouchers-redemptions)
404
411
  - [Rollback Redemption](#rollback-redemption)
412
+ - [Rollback Stackable](#rollback-stackable)
405
413
 
406
414
  #### [Redeem Voucher](https://docs.voucherify.io/reference/redeem-voucher)
407
415
 
@@ -410,6 +418,11 @@ client.redemptions.redeem(code)
410
418
  client.redemptions.redeem(code, params)
411
419
  ```
412
420
 
421
+ #### [Redeem Stackable](https://docs.voucherify.io/reference/redeem-stacked-discounts)
422
+ ```javascript
423
+ client.redemptions.redeemStackable(params)
424
+ ```
425
+
413
426
  #### [Get Redemption](https://docs.voucherify.io/reference/get-redemption)
414
427
 
415
428
  ```javascript
@@ -436,6 +449,12 @@ client.redemptions.rollback(redemptionId)
436
449
  client.redemptions.rollback(redemptionId, params)
437
450
  ```
438
451
 
452
+ #### [Rollback Stackable](https://docs.voucherify.io/reference/rollback-stackable-redemptions)
453
+ ```javascript
454
+ client.redemptions.rollbackStackable(parentRedemptionId)
455
+ client.redemptions.rollbackStackable(parentRedemptionId, params, queryParams)
456
+ ```
457
+
439
458
  Check [redemption rollback object](https://docs.voucherify.io/reference/the-redemption-rollback-object).
440
459
 
441
460
  ---
@@ -1137,7 +1156,9 @@ Methods are provided within `client.*` namespace.
1137
1156
 
1138
1157
  - [Set Identity](#set-identity)
1139
1158
  - [Validate](#validate)
1159
+ - [Validate Stackable](#validate-stackable-client-side)
1140
1160
  - [Redeem](#redeem)
1161
+ - [Redeem Stackable](#redeem-stackable-client-side)
1141
1162
  - [Publish](#publish)
1142
1163
  - [List vouchers](#list-vouchers)
1143
1164
  - [Create customer](#create-customer)
@@ -1157,12 +1178,24 @@ client.setIdentity(trackingId)
1157
1178
  client.validate(params)
1158
1179
  ```
1159
1180
 
1181
+ #### [Validate Stackable Client Side](https://docs.voucherify.io/reference/validate-stackable-discounts-client-side)
1182
+
1183
+ ```javascript
1184
+ client.validateStackable(params)
1185
+ ```
1186
+
1160
1187
  #### [Redeem](https://docs.voucherify.io/reference/redeem-voucher-client-side)
1161
1188
 
1162
1189
  ```javascript
1163
1190
  client.redeem(code, payload)
1164
1191
  ```
1165
1192
 
1193
+ #### [Redeem Stackable Client Side](https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side)
1194
+
1195
+ ```javascript
1196
+ client.redeemStackable(params)
1197
+ ```
1198
+
1166
1199
  #### Publish
1167
1200
 
1168
1201
  ```javascript
@@ -37,4 +37,12 @@ export declare class ClientSide {
37
37
  * @see https://docs.voucherify.io/reference/update-customers-consents-client
38
38
  */
39
39
  updateConsents(idOrSourceId: string, consents: T.ClientSideCustomersUpdateConsentsBody): Promise<undefined>;
40
+ /**
41
+ * @see https://docs.voucherify.io/reference/validate-stackable-discounts-client-side
42
+ */
43
+ validateStackable(params: T.ClientSideValidationsValidateStackableParams): Promise<import("./types").ValidationValidateStackableResponse>;
44
+ /**
45
+ * @see https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side
46
+ */
47
+ redeemStackable(params: T.ClientSideRedemptionsRedeemStackableParams): Promise<import("./types").RedemptionsRedeemStackableResponse>;
40
48
  }
@@ -7,6 +7,10 @@ export declare class Redemptions {
7
7
  * @see https://docs.voucherify.io/reference/redeem-voucher
8
8
  */
9
9
  redeem(code: string, body?: T.RedemptionsRedeemBody): Promise<T.RedemptionsRedeemResponse>;
10
+ /**
11
+ * @see https://docs.voucherify.io/reference/redeem-stacked-discounts
12
+ */
13
+ redeemStackable(params: T.RedemptionsRedeemStackableParams): Promise<T.RedemptionsRedeemStackableResponse>;
10
14
  /**
11
15
  * @see https://docs.voucherify.io/reference/get-redemption
12
16
  */
@@ -23,4 +27,9 @@ export declare class Redemptions {
23
27
  * @see https://docs.voucherify.io/reference/rollback-redemption
24
28
  */
25
29
  rollback(redemptionId: string, params?: T.RedemptionsRollbackParams): Promise<T.RedemptionsRollbackResponse>;
30
+ /**
31
+ * @see https://docs.voucherify.io/reference/rollback-stackable-redemptions
32
+ * Types of params and queryParams WILL be changed in future - please do not depend on it!
33
+ */
34
+ rollbackStackable(parentRedemptionId: string, params?: any, queryParams?: any): Promise<T.RedemptionsRollbackStackableResponse>;
26
35
  }
@@ -10,4 +10,8 @@ export declare class Validations {
10
10
  */
11
11
  validateVoucher(code: string, params?: T.ValidationsValidateVoucherParams): Promise<T.ValidationsValidateVoucherResponse>;
12
12
  validate(code: string | T.ValidationsValidateCode, context?: T.ValidationsValidateContext): Promise<T.ValidationsValidateVoucherResponse> | Promise<import("./types").PromotionsValidateResponse>;
13
+ /**
14
+ * @see https://docs.voucherify.io/reference/validate-stacked-discounts-1
15
+ */
16
+ validateStackable(params: T.ValidationsValidateStackableParams): Promise<T.ValidationValidateStackableResponse>;
13
17
  }
@@ -0,0 +1,15 @@
1
+ export declare type ApplicableToEffect = 'APPLY_TO_EVERY' | 'APPLY_TO_CHEAPEST' | 'APPLY_TO_MOST_EXPENSIVE';
2
+ export interface ApplicableTo {
3
+ object: 'product' | 'sku' | 'products_collection';
4
+ id: string;
5
+ source_id?: string;
6
+ strict: boolean;
7
+ price?: number;
8
+ price_formula?: number;
9
+ effect: ApplicableToEffect;
10
+ }
11
+ export interface ApplicableToResultList {
12
+ object: 'list';
13
+ total: number;
14
+ data: ApplicableTo[];
15
+ }
@@ -1,9 +1,14 @@
1
1
  import { CustomerRequest, CustomersCreateBody, CustomersCreateResponse, CustomersUpdateConsentsBody } from './Customers';
2
- import { DiscountAmount, DiscountPercent, DiscountUnit, VouchersListParams, VouchersResponse } from './Vouchers';
2
+ import { VouchersListParams, VouchersResponse } from './Vouchers';
3
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './DiscountVoucher';
3
4
  import { OrdersCreateResponse, OrdersItem } from './Orders';
4
5
  import { ConsentsListResponse } from './Consents';
5
6
  import { DistributionsPublicationsCreateResponse } from './Distributions';
6
7
  import { SimplePromotionTier } from './PromotionTiers';
8
+ import { ValidationSessionReleaseParams } from './ValidateSession';
9
+ import { ApplicableToResultList } from './ApplicableTo';
10
+ import { ValidationsValidateStackableParams, ValidationValidateStackableResponse } from './Validations';
11
+ import { RedemptionsRedeemStackableParams, RedemptionsRedeemStackableResponse } from './Redemptions';
7
12
  declare type ClientSideItem = Pick<OrdersItem, 'source_id' | 'sku_id' | 'product_id' | 'sku' | 'quantity' | 'related_object' | 'amount'>;
8
13
  export declare type ClientSideCustomersUpdateConsentsBody = CustomersUpdateConsentsBody;
9
14
  export declare type ClientSideCustomersCreateParams = CustomersCreateBody;
@@ -36,15 +41,7 @@ export interface ClientSideValidateResponse {
36
41
  code?: string;
37
42
  valid: boolean;
38
43
  discount?: DiscountUnit | DiscountAmount | DiscountPercent;
39
- applicable_to?: {
40
- object: 'list';
41
- total: number;
42
- data?: {
43
- id: string;
44
- object: 'product';
45
- source_id?: string;
46
- }[];
47
- };
44
+ applicable_to?: ApplicableToResultList;
48
45
  order?: {
49
46
  amount: number;
50
47
  discount_amount: number;
@@ -71,9 +68,7 @@ export interface ClientSideRedeemPayload {
71
68
  reward?: {
72
69
  id: string;
73
70
  };
74
- session?: {
75
- key: string;
76
- };
71
+ session?: ValidationSessionReleaseParams;
77
72
  }
78
73
  export interface ClientSideRedeemResponse {
79
74
  id: string;
@@ -132,4 +127,8 @@ export interface ClientSideRedeemWidgetPayload {
132
127
  }
133
128
  export declare type ClientSideTrackCustomer = CustomerRequest;
134
129
  export declare type ClientSideConsentsListResponse = ConsentsListResponse;
130
+ export declare type ClientSideValidationsValidateStackableParams = ValidationsValidateStackableParams;
131
+ export declare type ClientSideValidationValidateStackableResponse = ValidationValidateStackableResponse;
132
+ export declare type ClientSideRedemptionsRedeemStackableParams = RedemptionsRedeemStackableParams;
133
+ export declare type ClientSideRedemptionsRedeemStackableResponse = RedemptionsRedeemStackableResponse;
135
134
  export {};
@@ -0,0 +1,27 @@
1
+ export declare type DiscountVouchersTypes = 'AMOUNT' | 'PERCENT' | 'UNIT' | 'FIXED';
2
+ export declare enum DiscountVouchersTypesEnum {
3
+ AMOUNT = "AMOUNT",
4
+ PERCENT = "PERCENT",
5
+ UNIT = "UNIT",
6
+ FIXED = "FIXED"
7
+ }
8
+ export declare type DiscountVouchersEffectTypes = 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS' | 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY';
9
+ export declare type DiscountUnitVouchersEffectTypes = 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS';
10
+ export declare type DiscountAmountVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY';
11
+ export declare type DiscountPercentVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS';
12
+ export declare type DiscountFixedVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS';
13
+ export interface DiscountUnit {
14
+ type?: DiscountVouchersTypesEnum.UNIT;
15
+ unit_off?: number;
16
+ effect?: DiscountUnitVouchersEffectTypes;
17
+ unit_type?: string;
18
+ }
19
+ export interface DiscountAmount {
20
+ type?: DiscountVouchersTypesEnum.AMOUNT;
21
+ amount_off?: number;
22
+ }
23
+ export interface DiscountPercent {
24
+ type?: DiscountVouchersTypesEnum.PERCENT;
25
+ percent_off?: number;
26
+ amount_limit?: number;
27
+ }
@@ -0,0 +1,3 @@
1
+ export interface GiftRedemptionParams {
2
+ credits?: number;
3
+ }
@@ -459,4 +459,8 @@ export interface LoyaltiesRedeemRewardResponse {
459
459
  };
460
460
  };
461
461
  }
462
+ export interface LoyaltyPointsTransfer {
463
+ code: string;
464
+ points: number;
465
+ }
462
466
  export {};
@@ -18,8 +18,11 @@ export interface OrdersItem {
18
18
  };
19
19
  }
20
20
  export interface OrdersCreate {
21
+ source_id?: string;
22
+ status?: 'CREATED' | 'PAID' | 'CANCELLED' | 'FULFILLED';
21
23
  customer?: CustomerRequest;
22
24
  amount?: number;
25
+ discount_amount?: number;
23
26
  items?: OrdersItem[];
24
27
  metadata?: Record<string, any>;
25
28
  }
@@ -30,7 +33,13 @@ export interface OrdersCreateResponse {
30
33
  updated_at?: string;
31
34
  status?: 'CREATED' | 'PAID' | 'PROCESSING' | 'CANCELED' | 'FULFILLED';
32
35
  amount?: number;
36
+ initial_amount?: number;
33
37
  discount_amount?: number;
38
+ items_discount_amount?: number;
39
+ total_discount_amount?: number;
40
+ applied_discount_amount?: number;
41
+ items_applied_discount_amount?: number;
42
+ total_applied_discount_amount?: number;
34
43
  items?: OrdersItem[];
35
44
  metadata?: Record<string, any>;
36
45
  customer?: CustomerRequest;
@@ -43,6 +52,7 @@ export interface OrdersUpdate {
43
52
  status?: 'CREATED' | 'PAID' | 'CANCELLED' | 'FULFILLED';
44
53
  items?: OrdersItem[];
45
54
  amount?: number;
55
+ discount_amount?: number;
46
56
  metadata?: Record<string, any>;
47
57
  customer?: {
48
58
  id: string;
@@ -93,3 +93,13 @@ export interface ProductsListSkus {
93
93
  total: number;
94
94
  skus: ProductsGetSkuResponse[];
95
95
  }
96
+ export interface SimpleProduct {
97
+ id: string;
98
+ source_id?: string;
99
+ name?: string;
100
+ }
101
+ export interface SimpleSku {
102
+ id: string;
103
+ source_id?: string;
104
+ sku?: string;
105
+ }
@@ -1,7 +1,8 @@
1
- import { DiscountAmount, DiscountPercent, DiscountUnit } from './Vouchers';
1
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './DiscountVoucher';
2
2
  import { OrdersCreateResponse, OrdersItem } from './Orders';
3
3
  import { SimpleCustomer } from './Customers';
4
4
  import { ValidationRulesListAssignmentsResponse } from './ValidationRules';
5
+ import { ValidationSessionReleaseParams } from './ValidateSession';
5
6
  export interface SimplePromotionTier {
6
7
  tracking_id: string;
7
8
  metadata?: Record<string, any>;
@@ -66,9 +67,7 @@ export interface PromotionTiersRedeemParams {
66
67
  metadata?: Record<string, any>;
67
68
  };
68
69
  metadata?: Record<string, any>;
69
- session?: {
70
- key: string;
71
- };
70
+ session?: ValidationSessionReleaseParams;
72
71
  }
73
72
  export interface PromotionTiersRedeemResponse {
74
73
  id: string;
@@ -1,4 +1,4 @@
1
- import { DiscountAmount, DiscountPercent, DiscountUnit } from './Vouchers';
1
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './DiscountVoucher';
2
2
  import { OrdersItem } from './Orders';
3
3
  import { PromotionTier } from './PromotionTiers';
4
4
  import { SimpleCustomer } from './Customers';
@@ -1,7 +1,10 @@
1
- import { OrdersCreateResponse } from './Orders';
2
- import { RewardsCreateResponse } from './Rewards';
3
- import { SimpleCustomer } from './Customers';
1
+ import { OrdersCreateResponse, OrdersCreate } from './Orders';
2
+ import { RewardsCreateResponse, RewardRedemptionParams } from './Rewards';
3
+ import { CustomersCreateBody, SimpleCustomer } from './Customers';
4
4
  import { VouchersResponse } from './Vouchers';
5
+ import { GiftRedemptionParams } from './Gift';
6
+ import { ValidationSessionParams, ValidationSessionReleaseParams } from './ValidateSession';
7
+ import { StackableOptions, StackableRedeemableParams } from './Stackable';
5
8
  export interface RedemptionsRedeemBody {
6
9
  tracking_id?: string;
7
10
  customer?: SimpleCustomer & {
@@ -9,16 +12,9 @@ export interface RedemptionsRedeemBody {
9
12
  };
10
13
  order?: Pick<Partial<OrdersCreateResponse>, 'id' | 'source_id' | 'amount' | 'items' | 'status' | 'metadata'>;
11
14
  metadata?: Record<string, any>;
12
- reward?: {
13
- id?: string;
14
- points?: number;
15
- };
16
- gift?: {
17
- credits: number;
18
- };
19
- session?: {
20
- key: string;
21
- };
15
+ reward?: RewardRedemptionParams;
16
+ gift?: GiftRedemptionParams;
17
+ session?: ValidationSessionReleaseParams;
22
18
  }
23
19
  export interface RedemptionsRedeemResponse {
24
20
  id: string;
@@ -148,3 +144,57 @@ export declare type SimpleRollback = Pick<RedemptionsRollbackResponse, 'id' | 'o
148
144
  points: number;
149
145
  };
150
146
  };
147
+ export interface RedemptionsRedeemStackableParams {
148
+ options?: StackableOptions;
149
+ redeemables: StackableRedeemableParams[];
150
+ session?: ValidationSessionParams;
151
+ order?: OrdersCreate;
152
+ customer?: CustomersCreateBody;
153
+ metadata?: Record<string, any>;
154
+ }
155
+ export declare type RedemptionsRedeemStackableRedemptionResult = RedemptionsRedeemResponse & {
156
+ redemption: string;
157
+ };
158
+ export declare type RedemptionsRedeemStackableOrderResponse = OrdersCreateResponse & {
159
+ redemptions?: Record<string, {
160
+ date: string;
161
+ rollback_id?: string;
162
+ rollback_date?: string;
163
+ related_object_type: 'redemption';
164
+ related_object_id: string;
165
+ stacked: string[];
166
+ rollback_stacked?: string[];
167
+ }>;
168
+ };
169
+ export interface RedemptionsRedeemStackableResponse {
170
+ redemptions: RedemptionsRedeemStackableRedemptionResult[];
171
+ parent_redemption: {
172
+ id: string;
173
+ object: 'redemption';
174
+ date: string;
175
+ customer_id?: string;
176
+ tracking_id?: string;
177
+ metadata?: Record<string, any>;
178
+ result: 'SUCCESS' | 'FAILURE';
179
+ order?: RedemptionsRedeemStackableOrderResponse;
180
+ customer?: SimpleCustomer;
181
+ related_object_type: 'redemption';
182
+ related_object_id: string;
183
+ };
184
+ order?: RedemptionsRedeemStackableOrderResponse;
185
+ }
186
+ export interface RedemptionsRollbackStackableResponse {
187
+ rollbacks: RedemptionsRedeemStackableRedemptionResult[];
188
+ parent_rollback: {
189
+ id: string;
190
+ date: string;
191
+ customer_id?: string;
192
+ tracking_id?: string;
193
+ metadata?: Record<string, any>;
194
+ result: 'SUCCESS' | 'FAILURE';
195
+ order?: OrdersCreateResponse;
196
+ customer?: SimpleCustomer;
197
+ redemption: string;
198
+ };
199
+ order?: RedemptionsRedeemStackableOrderResponse;
200
+ }
@@ -111,4 +111,9 @@ export declare type RewardsUpdateAssignment = RewardsCreateAssignment & {
111
111
  id: string;
112
112
  };
113
113
  export declare type RewardsUpdateAssignmentResponse = RewardsAssignmentObject;
114
+ export interface RewardRedemptionParams {
115
+ points?: number;
116
+ assignment_id?: string;
117
+ id?: string;
118
+ }
114
119
  export {};
@@ -0,0 +1,63 @@
1
+ import { RewardRedemptionParams } from './Rewards';
2
+ import { GiftRedemptionParams } from './Gift';
3
+ import { OrdersCreateResponse } from './Orders';
4
+ import { ApplicableToResultList } from './ApplicableTo';
5
+ import { DiscountVouchersTypes, DiscountVouchersEffectTypes, DiscountUnitVouchersEffectTypes } from './DiscountVoucher';
6
+ import { SimpleProduct, SimpleSku } from './Products';
7
+ import { LoyaltyPointsTransfer } from './Loyalties';
8
+ declare type ExpandOption = 'order' | 'redeemable' | 'redemption';
9
+ export interface StackableOptions {
10
+ expand: ExpandOption[];
11
+ }
12
+ export declare type StackableRedeemableObject = 'promotion_stack' | 'promotion_tier' | 'voucher';
13
+ export interface StackableRedeemableParams {
14
+ object: StackableRedeemableObject;
15
+ id: string;
16
+ reward?: RewardRedemptionParams;
17
+ gift?: GiftRedemptionParams;
18
+ }
19
+ export declare type StackableRedeemableResponseStatus = 'APPLICABLE' | 'INAPPLICABLE' | 'SKIPPED';
20
+ export interface StackableRedeemableResultDiscountUnit {
21
+ effect: DiscountUnitVouchersEffectTypes;
22
+ unit_off: number;
23
+ unit_type: string;
24
+ sku?: SimpleSku;
25
+ product?: SimpleProduct;
26
+ }
27
+ export interface StackableRedeemableResultDiscount {
28
+ type: DiscountVouchersTypes;
29
+ effect: DiscountVouchersEffectTypes;
30
+ amount_off?: number;
31
+ percent_off?: number;
32
+ amount_limit?: number;
33
+ fixed_amount?: number;
34
+ unit_off?: number;
35
+ unit_type?: string;
36
+ sku?: SimpleSku;
37
+ product?: SimpleProduct;
38
+ units?: StackableRedeemableResultDiscountUnit[];
39
+ }
40
+ export interface StackableRedeemableResultGift {
41
+ credits?: number;
42
+ }
43
+ export interface StackableRedeemableResultLoyaltyCard {
44
+ points?: number;
45
+ transfers?: LoyaltyPointsTransfer[];
46
+ }
47
+ export interface StackableRedeemableResultResponse {
48
+ discount?: StackableRedeemableResultDiscount;
49
+ gift?: StackableRedeemableResultGift;
50
+ loyalty_card?: StackableRedeemableResultLoyaltyCard;
51
+ error?: any;
52
+ }
53
+ export interface StackableRedeemableResponse {
54
+ status: StackableRedeemableResponseStatus;
55
+ id: string;
56
+ object: StackableRedeemableObject;
57
+ order?: OrdersCreateResponse;
58
+ applicable_to?: ApplicableToResultList;
59
+ inapplicable_to?: ApplicableToResultList;
60
+ result?: StackableRedeemableResultResponse;
61
+ metadata?: Record<string, any>;
62
+ }
63
+ export {};
@@ -0,0 +1,17 @@
1
+ export declare type ValidationSessionType = 'LOCK';
2
+ export declare type ValidationSessionTTLUnit = 'DAYS' | 'HOURS' | 'MICROSECONDS' | 'MILLISECONDS' | 'MINUTES' | 'NANOSECONDS' | 'SECONDS';
3
+ export interface ValidationSessionParams {
4
+ key?: string;
5
+ type?: ValidationSessionType;
6
+ ttl?: number;
7
+ ttl_unit?: ValidationSessionTTLUnit;
8
+ }
9
+ export interface ValidationSessionResponse {
10
+ key: string;
11
+ type: ValidationSessionType;
12
+ ttl: number;
13
+ ttl_unit: ValidationSessionTTLUnit;
14
+ }
15
+ export interface ValidationSessionReleaseParams {
16
+ key: string;
17
+ }
@@ -1,3 +1,4 @@
1
+ import { ApplicableToResultList } from './ApplicableTo';
1
2
  export interface ValidationRulesCreate {
2
3
  name: string;
3
4
  error?: {
@@ -25,11 +26,7 @@ export interface ValidationRulesCreateResponse {
25
26
  export interface ValidationRulesValidateResponse {
26
27
  valid: boolean;
27
28
  rule_id: string;
28
- applicable_to: {
29
- data: any[];
30
- object: 'list';
31
- total: number;
32
- };
29
+ applicable_to: ApplicableToResultList;
33
30
  }
34
31
  export declare type ValidationRulesGetResponse = ValidationRulesCreateResponse & {
35
32
  assignments_count?: string;
@@ -1,5 +1,9 @@
1
- import { DiscountAmount, DiscountPercent, DiscountUnit } from './Vouchers';
2
- import { OrdersItem } from './Orders';
1
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './DiscountVoucher';
2
+ import { CustomersCreateBody } from './Customers';
3
+ import { StackableOptions, StackableRedeemableParams, StackableRedeemableResponse } from './Stackable';
4
+ import { ValidationSessionParams, ValidationSessionResponse } from './ValidateSession';
5
+ import { ApplicableToResultList } from './ApplicableTo';
6
+ import { OrdersItem, OrdersCreate, OrdersCreateResponse } from './Orders';
3
7
  import { PromotionsValidateParams } from './Promotions';
4
8
  export interface ValidationsValidateVoucherParams {
5
9
  customer?: {
@@ -23,23 +27,10 @@ export interface ValidationsValidateVoucherParams {
23
27
  reward?: {
24
28
  id: string;
25
29
  };
26
- session?: {
27
- type: 'LOCK';
28
- key?: string;
29
- ttl?: number;
30
- ttl_unit?: 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS';
31
- };
30
+ session?: ValidationSessionParams;
32
31
  }
33
32
  export interface ValidationsValidateVoucherResponse {
34
- applicable_to?: {
35
- object: 'list';
36
- total: number;
37
- data?: {
38
- id: string;
39
- object: 'product';
40
- source_id?: string;
41
- }[];
42
- };
33
+ applicable_to?: ApplicableToResultList;
43
34
  campaign?: string;
44
35
  campaign_id?: string;
45
36
  metadata?: Record<string, any>;
@@ -62,5 +53,20 @@ export interface ValidationsValidateVoucherResponse {
62
53
  };
63
54
  tracking_id: string;
64
55
  }
56
+ export interface ValidationsValidateStackableParams {
57
+ options?: StackableOptions;
58
+ redeemables: StackableRedeemableParams[];
59
+ session?: ValidationSessionParams;
60
+ order?: OrdersCreate;
61
+ customer?: CustomersCreateBody;
62
+ metadata?: Record<string, any>;
63
+ }
64
+ export interface ValidationValidateStackableResponse {
65
+ valid: boolean;
66
+ tracking_id?: string;
67
+ session?: ValidationSessionResponse;
68
+ order?: OrdersCreateResponse;
69
+ redeemables?: StackableRedeemableResponse[];
70
+ }
65
71
  export declare type ValidationsValidateCode = PromotionsValidateParams;
66
72
  export declare type ValidationsValidateContext = ValidationsValidateVoucherParams;
@@ -1,5 +1,6 @@
1
1
  import { OrdersGetResponse } from './Orders';
2
2
  import { SimpleCustomer } from './Customers';
3
+ import { DiscountUnit, DiscountAmount, DiscountPercent } from './DiscountVoucher';
3
4
  export declare type VoucherType = 'GIFT' | 'DISCOUNT' | 'LOYALTY_CARD' | 'LUCKY_DRAW';
4
5
  export interface SimpleVoucher {
5
6
  code_config?: {
@@ -20,21 +21,6 @@ export interface SimpleVoucher {
20
21
  quantity: number;
21
22
  };
22
23
  }
23
- export interface DiscountUnit {
24
- type?: 'UNIT';
25
- unit_off?: number;
26
- effect?: 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS';
27
- unit_type?: string;
28
- }
29
- export interface DiscountAmount {
30
- type?: 'AMOUNT';
31
- amount_off?: number;
32
- }
33
- export interface DiscountPercent {
34
- type?: 'PERCENT';
35
- percent_off?: number;
36
- amount_limit?: number;
37
- }
38
24
  export interface VouchersResponse {
39
25
  id: string;
40
26
  code: string;
@@ -17,3 +17,8 @@ export * from './Exports';
17
17
  export * from './Orders';
18
18
  export * from './Consents';
19
19
  export * from './Events';
20
+ export * from './Stackable';
21
+ export * from './Gift';
22
+ export * from './ValidateSession';
23
+ export * from './ApplicableTo';
24
+ export * from './DiscountVoucher';