@voucherify/sdk 2.0.2 → 2.0.5

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,23 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a7811e7`](https://github.com/voucherifyio/voucherify-js-sdk/commit/a7811e7e2939efe7a4c59c004dbc9591fcd73030) [#121](https://github.com/voucherifyio/voucherify-js-sdk/pull/121) Thanks [@jkaliszuk](https://github.com/jkaliszuk)! - Added logic that allow to storage lastResponseHeaders data and get apiLimit through ApiLimitsHandler
8
+
9
+ ## 2.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`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
14
+
15
+ ## 2.0.3
16
+
17
+ ### Patch Changes
18
+
19
+ - [`da9e103`](https://github.com/voucherifyio/voucherify-js-sdk/commit/da9e103a43590b55cb80d64e1743f7ede1e09946) [#117](https://github.com/voucherifyio/voucherify-js-sdk/pull/117) Thanks [@darekg11](https://github.com/darekg11)! - Added support for listing customer activities by customerId. Additionally user can pass query params allowing for better filtering. API Reference: https://docs.voucherify.io/reference/get-customer-activities
20
+
3
21
  ## 2.0.2
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -66,6 +66,8 @@ Server side:
66
66
  <a href="#events">Events</a>
67
67
  |
68
68
  <a href="#async-actions">Async Actions</a>
69
+ |
70
+ <a href="#api-limits-handler">Api Limits Handler</a>
69
71
  </p>
70
72
 
71
73
  <p align="center">
@@ -362,6 +364,7 @@ Methods are provided within `client.validations.*` or `client.promotions.*` name
362
364
 
363
365
  - [Validate Voucher](#validate-voucher)
364
366
  - [Validate Promotion Campaign](#validate-promotion-campaign)
367
+ - [Validate Stackable](#validate-stackable)
365
368
 
366
369
  #### [Validate Voucher](https://docs.voucherify.io/reference/validate-voucher)
367
370
 
@@ -389,6 +392,11 @@ Other possibility
389
392
  client.validations.validate(params)
390
393
  ```
391
394
 
395
+ #### [Validate Stackable](https://docs.voucherify.io/reference/validate-stacked-discounts-1)
396
+ ```javascript
397
+ client.validations.validateStackable(params)
398
+ ```
399
+
392
400
  ---
393
401
 
394
402
  ### Redemptions
@@ -396,12 +404,14 @@ client.validations.validate(params)
396
404
  Methods are provided within `client.redemptions.*` namespace.
397
405
 
398
406
  - [Redeem Voucher](#redeem-voucher)
407
+ - [Redeem Stackable](#redeem-stackable)
399
408
  - [Get Redemption](#get-redemption)
400
409
  - [Redeem Promotion's Tier](#redeem-promotions-tier)
401
410
  - [Redeem Loyalty Card](#redeem-loyalty-card)
402
411
  - [List Redemptions](#list-redemptions)
403
412
  - [Get Voucher's Redemptions](#get-vouchers-redemptions)
404
413
  - [Rollback Redemption](#rollback-redemption)
414
+ - [Rollback Stackable](#rollback-stackable)
405
415
 
406
416
  #### [Redeem Voucher](https://docs.voucherify.io/reference/redeem-voucher)
407
417
 
@@ -410,6 +420,11 @@ client.redemptions.redeem(code)
410
420
  client.redemptions.redeem(code, params)
411
421
  ```
412
422
 
423
+ #### [Redeem Stackable](https://docs.voucherify.io/reference/redeem-stacked-discounts)
424
+ ```javascript
425
+ client.redemptions.redeemStackable(params)
426
+ ```
427
+
413
428
  #### [Get Redemption](https://docs.voucherify.io/reference/get-redemption)
414
429
 
415
430
  ```javascript
@@ -436,6 +451,12 @@ client.redemptions.rollback(redemptionId)
436
451
  client.redemptions.rollback(redemptionId, params)
437
452
  ```
438
453
 
454
+ #### [Rollback Stackable](https://docs.voucherify.io/reference/rollback-stackable-redemptions)
455
+ ```javascript
456
+ client.redemptions.rollbackStackable(parentRedemptionId)
457
+ client.redemptions.rollbackStackable(parentRedemptionId, params, queryParams)
458
+ ```
459
+
439
460
  Check [redemption rollback object](https://docs.voucherify.io/reference/the-redemption-rollback-object).
440
461
 
441
462
  ---
@@ -514,6 +535,7 @@ Methods are provided within `client.customers.*` namespace.
514
535
  - [Delete Customer](#delete-customer)
515
536
  - [List Customers](#list-customers)
516
537
  - [Update Customer's Consents](#update-customers-consents)
538
+ - [List Customer's Activities](#list-customers-activities)
517
539
 
518
540
  #### [Create Customer](https://docs.voucherify.io/reference/create-customer)
519
541
 
@@ -588,6 +610,13 @@ Keep in mind this operation may drain your API call limits fairly quickly - each
588
610
  client.customers.updateConsents(customer, consents)
589
611
  ```
590
612
 
613
+ #### [List Customers Activities](https://docs.voucherify.io/reference/get-customer-activities)
614
+
615
+ ```javascript
616
+ client.customers.listActivities(customerId)
617
+ client.customers.listActivities(customerId, params)
618
+ ```
619
+
591
620
  ---
592
621
 
593
622
  ### Consents
@@ -1097,6 +1126,37 @@ client.asyncActions.list()
1097
1126
  client.asyncActions.list(params)
1098
1127
  ```
1099
1128
 
1129
+ ---
1130
+
1131
+ ### Api Limits Handler
1132
+
1133
+ Methods are provided within `client.apiLimitsHandler.*` namespace.
1134
+
1135
+ - [Are Limits Available](#are-limits-available)
1136
+ - [Get Rate Limit](#get-rate-limit)
1137
+ - [Get Rate Limit Remaining](#get-rate-limit-remaining)
1138
+
1139
+ #### Are Limits Available
1140
+ ```javascript
1141
+ client.apiLimitsHandler.areLimitsAvailable()
1142
+ ```
1143
+
1144
+ This method should be called each time beforehand [Get Rate Limit](#get-rate-limit) or [Get Rate Limit Remaining](#get-rate-limit-remaining) to ensure limit data are available.
1145
+
1146
+ #### Get Rate Limit
1147
+ ```javascript
1148
+ if(client.apiLimitsHandler.areLimitsAvailable()){
1149
+ client.apiLimitsHandler.getRateLimit()
1150
+ }
1151
+ ```
1152
+
1153
+ #### Get Rate Limit Remaining
1154
+ ```javascript
1155
+ if(client.apiLimitsHandler.areLimitsAvailable()){
1156
+ client.apiLimitsHandler.getRateLimitRemaining()
1157
+ }
1158
+ ```
1159
+
1100
1160
  ---
1101
1161
 
1102
1162
  # 💅 Client Side
@@ -1129,7 +1189,9 @@ Methods are provided within `client.*` namespace.
1129
1189
 
1130
1190
  - [Set Identity](#set-identity)
1131
1191
  - [Validate](#validate)
1192
+ - [Validate Stackable](#validate-stackable-client-side)
1132
1193
  - [Redeem](#redeem)
1194
+ - [Redeem Stackable](#redeem-stackable-client-side)
1133
1195
  - [Publish](#publish)
1134
1196
  - [List vouchers](#list-vouchers)
1135
1197
  - [Create customer](#create-customer)
@@ -1149,12 +1211,24 @@ client.setIdentity(trackingId)
1149
1211
  client.validate(params)
1150
1212
  ```
1151
1213
 
1214
+ #### [Validate Stackable Client Side](https://docs.voucherify.io/reference/validate-stackable-discounts-client-side)
1215
+
1216
+ ```javascript
1217
+ client.validateStackable(params)
1218
+ ```
1219
+
1152
1220
  #### [Redeem](https://docs.voucherify.io/reference/redeem-voucher-client-side)
1153
1221
 
1154
1222
  ```javascript
1155
1223
  client.redeem(code, payload)
1156
1224
  ```
1157
1225
 
1226
+ #### [Redeem Stackable Client Side](https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side)
1227
+
1228
+ ```javascript
1229
+ client.redeemStackable(params)
1230
+ ```
1231
+
1158
1232
  #### Publish
1159
1233
 
1160
1234
  ```javascript
@@ -0,0 +1,9 @@
1
+ import { RequestController } from './RequestController';
2
+ export declare class ApiLimitsHandler {
3
+ private readonly requestController;
4
+ constructor(requestController: RequestController);
5
+ private getLastResponseHeadersFromController;
6
+ areLimitsAvailable(): boolean;
7
+ getRateLimit(): number;
8
+ getRateLimitRemaining(): number;
9
+ }
@@ -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
  }
@@ -39,5 +39,9 @@ declare class Customers {
39
39
  * @see https://docs.voucherify.io/reference/update-customers-consents
40
40
  */
41
41
  updateConsents(idOrSourceId: string, consents: T.CustomersUpdateConsentsBody): Promise<undefined>;
42
+ /**
43
+ * @see https://docs.voucherify.io/reference/get-customer-activities
44
+ */
45
+ listActivities(customerId: string, params?: T.CustomerActivitiesListQueryParams): Promise<T.CustomerActivitiesListResponse>;
42
46
  }
43
47
  export { Customers };
@@ -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
  }
@@ -11,7 +11,12 @@ export declare class RequestController {
11
11
  private basePath;
12
12
  private headers;
13
13
  private request;
14
+ private lastResponseHeaders;
15
+ private isLastResponseHeadersSet;
14
16
  constructor({ basePath, baseURL, headers }: RequestControllerOptions);
17
+ isLastReponseHeadersSet(): boolean;
18
+ getLastResponseHeaders(): Record<string, string>;
19
+ private setLastResponseHeaders;
15
20
  setBaseUrl(baseURL: string): void;
16
21
  get<T>(path: string, params?: Record<string, any>): Promise<T>;
17
22
  post<T>(path: string, body: Record<string, any>, params?: Record<string, any>, headers?: Record<string, any>): Promise<T>;
@@ -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
  }
@@ -14,6 +14,7 @@ import { Rewards } from './Rewards';
14
14
  import { Loyalties } from './Loyalties';
15
15
  import { ValidationRules } from './ValidationRules';
16
16
  import { Segments } from './Segments';
17
+ import { ApiLimitsHandler } from './ApiLimitsHandler';
17
18
  export interface VoucherifyServerSideOptions {
18
19
  /**
19
20
  * Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
@@ -108,4 +109,5 @@ export declare function VoucherifyServerSide(options: VoucherifyServerSideOption
108
109
  validationRules: ValidationRules;
109
110
  events: Events;
110
111
  asyncActions: AsyncActions;
112
+ apiLimitsHandler: ApiLimitsHandler;
111
113
  };
@@ -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 {};
@@ -94,6 +94,20 @@ export interface CustomersCommonListResponse {
94
94
  customers: CustomerObject[];
95
95
  has_more?: boolean;
96
96
  }
97
+ export interface CustomerActivitiesListQueryParams {
98
+ limit?: number;
99
+ order?: 'created_at' | '-created_at';
100
+ starting_after?: string;
101
+ starting_after_id?: string;
102
+ campaign_type?: 'LOYALTY_PROGRAM' | 'PROMOTION' | 'DISCOUNT_COUPONS' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
103
+ campaign_id?: string;
104
+ }
105
+ export interface CustomerActivitiesListResponse {
106
+ object: 'list';
107
+ total: number;
108
+ data_ref: 'data';
109
+ data: Record<string, any>[];
110
+ }
97
111
  export declare type CustomersCreateBody = CustomerRequest;
98
112
  export declare type CustomersCreateResponse = CustomerObject | CustomerUnconfirmed;
99
113
  export declare type CustomersGetResponse = CustomerObject | CustomerUnconfirmed;
@@ -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 {};