@voucherify/sdk 2.7.0 → 2.7.2

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.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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`
8
+
9
+ ## 2.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`25c3f13`](https://github.com/voucherifyio/voucherify-js-sdk/commit/25c3f13d10cd8ed4a6eee50082f302efd18e1268) [#260](https://github.com/voucherifyio/voucherify-js-sdk/pull/260) Thanks [@jkaliszuk](https://github.com/jkaliszuk)! - Added `error` object in `VoucherifyError`. Added `validation_rules` in VouchersCreateParameters.
14
+
3
15
  ## 2.7.0
4
16
 
5
17
  ### Minor 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 };
@@ -12,6 +12,9 @@ export declare class VoucherifyError extends Error {
12
12
  related_object_ids?: string[];
13
13
  related_object_type?: string;
14
14
  related_object_total?: number;
15
+ error?: {
16
+ message: string;
17
+ };
15
18
  cause?: AxiosError;
16
19
  constructor(statusCode: number, body?: unknown, axiosError?: AxiosError);
17
20
  }
@@ -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;
@@ -128,6 +128,7 @@ export interface VouchersCreateParameters {
128
128
  redemption?: {
129
129
  quantity: number;
130
130
  };
131
+ validation_rules?: string[];
131
132
  }
132
133
  export declare type VouchersCreate = VouchersCreateParameters & Pick<VouchersResponse, 'type' | 'discount' | 'gift' | 'category' | 'additional_info' | 'start_date' | 'expiration_date' | 'metadata'>;
133
134
  export declare type VouchersCreateResponse = Omit<VouchersResponse, 'validation_rules_assignments'>;
@@ -30,6 +30,7 @@ class VoucherifyError extends Error {
30
30
  this.related_object_ids = void 0;
31
31
  this.related_object_type = void 0;
32
32
  this.related_object_total = void 0;
33
+ this.error = void 0;
33
34
  this.cause = void 0;
34
35
  this.code = body.code;
35
36
  this.key = body.key;
@@ -40,6 +41,7 @@ class VoucherifyError extends Error {
40
41
  this.related_object_ids = body.related_object_ids;
41
42
  this.related_object_type = body.related_object_type;
42
43
  this.related_object_total = body.related_object_total;
44
+ this.error = body.error;
43
45
  this.cause = axiosError;
44
46
  }
45
47
 
@@ -971,6 +973,14 @@ class Customers {
971
973
  };
972
974
  return this.client.post(`/customers/importCSV`, form, undefined, headers);
973
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
+ }
974
984
 
975
985
  }
976
986
 
@@ -1942,7 +1952,7 @@ function VoucherifyServerSide(options) {
1942
1952
  let headers = {
1943
1953
  'X-App-Id': options.applicationId,
1944
1954
  'X-App-Token': options.secretKey,
1945
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.0"}`,
1955
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.2"}`,
1946
1956
  'Content-Type': 'application/json'
1947
1957
  };
1948
1958
 
@@ -2208,7 +2218,7 @@ function VoucherifyClientSide(options) {
2208
2218
  let headers = {
2209
2219
  'X-Client-Application-Id': options.clientApplicationId,
2210
2220
  'X-Client-Token': options.clientSecretKey,
2211
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.0"}`
2221
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.2"}`
2212
2222
  };
2213
2223
 
2214
2224
  if (environment().startsWith('Node')) {