@voucherify/sdk 2.7.1 → 2.7.3

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,17 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d532cc4`](https://github.com/voucherifyio/voucherify-js-sdk/commit/d532cc4dd6ccc1ea6cab120b8a3cec7d86598ffd) [#270](https://github.com/voucherifyio/voucherify-js-sdk/pull/270) Thanks [@p-zielinski](https://github.com/p-zielinski)! - Type support for partial redemptions. General update to responses of /validations and /redemptions endpoints.
8
+
9
+ ## 2.7.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`3d23881`](https://github.com/voucherifyio/voucherify-js-sdk/commit/3d23881738f317903dae3373642cc7151159ca26) [#268](https://github.com/voucherifyio/voucherify-js-sdk/pull/268) Thanks [@darekg11](https://github.com/darekg11)! - New endpoint support - `customer-redeemable`
14
+
3
15
  ## 2.7.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -654,6 +654,7 @@ Methods are provided within `client.customers.*` namespace.
654
654
  - [Update Customers in bulk](#update-customers-in-bulk)
655
655
  - [Update Customers' Metadata in bulk](#update-customers-metadata-in-bulk)
656
656
  - [Import and Update Customers using CSV](#import-and-update-customers-using-csv)
657
+ - [List Redeemables](#list-redeemables)
657
658
 
658
659
  #### [Create Customer](https://docs.voucherify.io/reference/create-customer)
659
660
 
@@ -759,6 +760,12 @@ client.customers.updateInBulk(customers)
759
760
  client.customers.updateMetadataInBulk(sourceIdsAndMetadata)
760
761
  ```
761
762
 
763
+ #### [List Redeemables](https://docs.voucherify.io/reference/list-customer-redeemables)
764
+
765
+ ```javascript
766
+ client.customers.listRedeemables(id, params)
767
+ ```
768
+
762
769
  ---
763
770
 
764
771
  ### Consents
@@ -60,5 +60,9 @@ declare class Customers {
60
60
  * @see https://docs.voucherify.io/reference/import-customers-using-csv
61
61
  */
62
62
  importCSV(filePath: string): Promise<AAT.AsyncActionCreateResponse>;
63
+ /**
64
+ * @see https://docs.voucherify.io/reference/list-customer-redeemables
65
+ */
66
+ listRedeemables(id: string, params?: T.CustomerRedeemablesListQueryParams): Promise<T.CustomerRedeemablesListResponse>;
63
67
  }
64
68
  export { Customers };
@@ -30,6 +30,7 @@ export declare type Category = {
30
30
  created_at: string;
31
31
  updated_at?: string;
32
32
  object: 'category';
33
+ stacking_rules_type?: 'JOINT' | 'EXCLUSIVE';
33
34
  };
34
35
  export declare type CategoriesListRequestQuery = {
35
36
  limit?: number;
@@ -1,3 +1,4 @@
1
+ import { DiscountUnit, DiscountAmount, DiscountPercent, DiscountFixed } from './DiscountVoucher';
1
2
  export interface SimpleCustomer {
2
3
  id: string;
3
4
  name?: string;
@@ -110,6 +111,94 @@ export interface CustomerActivitiesListResponse {
110
111
  data_ref: 'data';
111
112
  data: Record<string, any>[];
112
113
  }
114
+ export interface CustomerRedeemablesListQueryParams {
115
+ limit?: number;
116
+ order?: 'created_at' | '-created_at' | 'id' | '-id';
117
+ starting_after_id?: string;
118
+ filters?: Record<string, any>;
119
+ }
120
+ export interface CustomerRedeemablesListResponse {
121
+ object: 'list';
122
+ total: number;
123
+ data_ref: 'data';
124
+ data: CustomerRedeemablesListItemResponse[];
125
+ has_more: boolean;
126
+ more_starting_after?: string;
127
+ }
128
+ export interface CustomerRedeemablesListItemResponse {
129
+ id: string;
130
+ created_at: string;
131
+ redeemable_id: string;
132
+ redeemable_object: string;
133
+ customer_id: string;
134
+ holder_role: 'OWNER' | 'REFERRER' | 'REFEREE';
135
+ campaign_id: string;
136
+ campaign_type: 'LOYALTY_PROGRAM' | 'PROMOTION' | 'DISCOUNT_COUPONS' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
137
+ voucher_type: 'GIFT_VOUCHER' | 'DISCOUNT_VOUCHER' | 'LOYALTY_CARD';
138
+ redeemable: CustomerRedeemablesListItemContainerResponse;
139
+ }
140
+ export interface CustomerRedeemablesListItemContainerVoucherResponse {
141
+ id: string;
142
+ code: string;
143
+ campaign?: string;
144
+ camapign_id?: string;
145
+ category_id?: string;
146
+ type: 'GIFT_VOUCHER' | 'DISCOUNT_VOUCHER' | 'LOYALTY_CARD';
147
+ discount?: DiscountAmount | DiscountPercent | DiscountUnit | DiscountFixed;
148
+ gift?: {
149
+ amount: number;
150
+ balance: number;
151
+ effect: string;
152
+ };
153
+ loyalty_card?: {
154
+ points: number;
155
+ balance: number;
156
+ next_expiration_date?: string;
157
+ next_expiration_points?: number;
158
+ };
159
+ start_date?: string;
160
+ expiration_date?: string;
161
+ validity_timeframe?: {
162
+ interval: string;
163
+ duration: string;
164
+ };
165
+ validity_day_of_week?: number[];
166
+ publish?: {
167
+ object: 'list';
168
+ count: number;
169
+ url: string;
170
+ };
171
+ redemption?: {
172
+ object: 'list';
173
+ quantity?: number;
174
+ redeemed_quantity: number;
175
+ url: string;
176
+ redeemed_points?: number;
177
+ };
178
+ active?: boolean;
179
+ additional_info?: string;
180
+ metadata?: Record<string, any>;
181
+ assets: {
182
+ qr: {
183
+ id: string;
184
+ url: string;
185
+ };
186
+ barcode: {
187
+ id: string;
188
+ url: string;
189
+ };
190
+ };
191
+ is_referral_code: boolean;
192
+ holder_id?: string;
193
+ updated_at?: string;
194
+ created_at: string;
195
+ object: 'voucher';
196
+ }
197
+ export interface CustomerRedeemablesListItemContainerResponse {
198
+ type: 'voucher';
199
+ voucher?: CustomerRedeemablesListItemContainerVoucherResponse;
200
+ status: 'ACTIVE' | 'USED' | 'DISABLED' | 'NOT_ACTIVE_YET' | 'EXPIRED' | 'NO_BALANCE';
201
+ }
113
202
  export declare type CustomersCreateBody = CustomerRequest;
114
203
  export declare type CustomersCreateResponse = CustomerObject | CustomerUnconfirmed;
115
204
  export declare type CustomersGetResponse = CustomerObject | CustomerUnconfirmed;
@@ -4,7 +4,7 @@ import { CustomersCreateBody, SimpleCustomer } from './Customers';
4
4
  import { VouchersResponse } from './Vouchers';
5
5
  import { GiftRedemptionParams } from './Gift';
6
6
  import { ValidationSessionParams, ValidationSessionReleaseParams } from './ValidateSession';
7
- import { StackableOptions, StackableRedeemableParams } from './Stackable';
7
+ import { StackableOptions, StackableRedeemableInapplicableResponse, StackableRedeemableParams, StackableRedeemableSkippedResponse } from './Stackable';
8
8
  import { PromotionTierRedeemDetailsSimple, PromotionTierRedeemDetails } from './PromotionTiers';
9
9
  export interface RedemptionsRedeemBody {
10
10
  tracking_id?: string;
@@ -185,6 +185,8 @@ export interface RedemptionsRedeemStackableResponse {
185
185
  related_object_id: string;
186
186
  };
187
187
  order?: RedemptionsRedeemStackableOrderResponse;
188
+ skipped_redeemables?: StackableRedeemableSkippedResponse;
189
+ inapplicable_redeemables?: StackableRedeemableInapplicableResponse;
188
190
  }
189
191
  export interface RedemptionsRollbackStackableResponse {
190
192
  rollbacks: RedemptionsRedeemStackableRedemptionResult[];
@@ -6,6 +6,7 @@ import { DiscountVouchersTypes, DiscountVouchersEffectTypes, DiscountUnitVoucher
6
6
  import { SimpleProduct, SimpleSku } from './Products';
7
7
  import { LoyaltyPointsTransfer } from './Loyalties';
8
8
  import { ValidationError } from './ValidationError';
9
+ import { Category } from './Categories';
9
10
  declare type ExpandOption = 'order' | 'redeemable' | 'redemption';
10
11
  export interface StackableOptions {
11
12
  expand: ExpandOption[];
@@ -54,6 +55,10 @@ export interface StackableRedeemableResultResponse {
54
55
  gift?: StackableRedeemableResultGift;
55
56
  loyalty_card?: StackableRedeemableResultLoyaltyCard;
56
57
  error?: ValidationError;
58
+ details?: {
59
+ key?: string;
60
+ message?: string;
61
+ };
57
62
  }
58
63
  export interface StackableRedeemableResponse {
59
64
  status: StackableRedeemableResponseStatus;
@@ -64,5 +69,33 @@ export interface StackableRedeemableResponse {
64
69
  inapplicable_to?: ApplicableToResultList;
65
70
  result?: StackableRedeemableResultResponse;
66
71
  metadata?: Record<string, any>;
72
+ categories?: Category[];
67
73
  }
74
+ export declare type StackableRedeemableInapplicableResponse = {
75
+ status: 'INAPPLICABLE';
76
+ id: string;
77
+ object: 'voucher' | 'promotion_tier';
78
+ result: {
79
+ error?: ValidationError;
80
+ details?: {
81
+ key?: string;
82
+ message?: string;
83
+ };
84
+ };
85
+ metadata?: Record<string, unknown>;
86
+ categories?: Category[];
87
+ };
88
+ export declare type StackableRedeemableSkippedResponse = {
89
+ status: 'SKIPPED';
90
+ id: string;
91
+ object: 'voucher' | 'promotion_tier';
92
+ result: {
93
+ details?: {
94
+ key?: string;
95
+ message?: string;
96
+ };
97
+ };
98
+ metadata?: Record<string, unknown>;
99
+ categories?: Category[];
100
+ };
68
101
  export {};
@@ -1,6 +1,6 @@
1
1
  import { DiscountAmount, DiscountPercent, DiscountUnit, DiscountFixed } from './DiscountVoucher';
2
2
  import { CustomersCreateBody } from './Customers';
3
- import { StackableOptions, StackableRedeemableParams, StackableRedeemableResponse } from './Stackable';
3
+ import { StackableOptions, StackableRedeemableInapplicableResponse, StackableRedeemableParams, StackableRedeemableResponse, StackableRedeemableSkippedResponse } from './Stackable';
4
4
  import { ValidationSessionParams, ValidationSessionResponse } from './ValidateSession';
5
5
  import { ApplicableToResultList } from './ApplicableTo';
6
6
  import { ValidationError } from './ValidationError';
@@ -79,6 +79,20 @@ export interface ValidationValidateStackableResponse {
79
79
  session?: ValidationSessionResponse;
80
80
  order?: OrdersCreateResponse;
81
81
  redeemables?: StackableRedeemableResponse[];
82
+ skipped_redeemables?: StackableRedeemableSkippedResponse;
83
+ inapplicable_redeemables?: StackableRedeemableInapplicableResponse;
84
+ stacking_rules: ValidationsStackingRules;
82
85
  }
86
+ export declare type ValidationsStackingRules = {
87
+ redeemables_limit: number;
88
+ applicable_redeemables_limit: number;
89
+ applicable_redeemables_per_category_limit?: number;
90
+ applicable_exclusive_redeemables_limit: number;
91
+ applicable_exclusive_redeemables_per_category_limit?: number;
92
+ exclusive_categories: string[];
93
+ joint_categories: string[];
94
+ redeemables_application_mode: 'ALL' | 'PARTIAL';
95
+ redeemables_sorting_rule: 'CATEGORY_HIERARCHY' | 'REQUESTED_ORDER';
96
+ };
83
97
  export declare type ValidationsValidateCode = PromotionsValidateParams;
84
98
  export declare type ValidationsValidateContext = ValidationsValidateVoucherParams;
@@ -973,6 +973,14 @@ class Customers {
973
973
  };
974
974
  return this.client.post(`/customers/importCSV`, form, undefined, headers);
975
975
  }
976
+ /**
977
+ * @see https://docs.voucherify.io/reference/list-customer-redeemables
978
+ */
979
+
980
+
981
+ listRedeemables(id, params) {
982
+ return this.client.get(`/customers/${encode(id)}/redeemables`, params);
983
+ }
976
984
 
977
985
  }
978
986
 
@@ -1944,7 +1952,7 @@ function VoucherifyServerSide(options) {
1944
1952
  let headers = {
1945
1953
  'X-App-Id': options.applicationId,
1946
1954
  'X-App-Token': options.secretKey,
1947
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.1"}`,
1955
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.3"}`,
1948
1956
  'Content-Type': 'application/json'
1949
1957
  };
1950
1958
 
@@ -2210,7 +2218,7 @@ function VoucherifyClientSide(options) {
2210
2218
  let headers = {
2211
2219
  'X-Client-Application-Id': options.clientApplicationId,
2212
2220
  'X-Client-Token': options.clientSecretKey,
2213
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.1"}`
2221
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.3"}`
2214
2222
  };
2215
2223
 
2216
2224
  if (environment().startsWith('Node')) {