@voucherify/sdk 2.2.5 → 2.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`644aa84`](https://github.com/voucherifyio/voucherify-js-sdk/commit/644aa8479843b8625192aa295eb07aa19ba651d7) [#227](https://github.com/voucherifyio/voucherify-js-sdk/pull/227) Thanks [@marcin-slezak](https://github.com/marcin-slezak)! - Added support for missing CSV import endpoints ([(examples of usage available in readme.md)](..%2F..%2Fpackages%2Fsdk%2FREADME.md)):
8
+ - `POST /skus/importCSV`
9
+ - `POST /products/importCSV`
10
+ - `POST /vouchers/importCSV`
11
+ - `POST /customers/importCSV`
12
+ - `POST /campaigns/campaignId/importCSV`
13
+ - Added form-data `4.0.0` to SDK package
14
+
15
+ * [`7720e31`](https://github.com/voucherifyio/voucherify-js-sdk/commit/7720e31baea0db19a7543ae12661fab77176e5ff) [#228](https://github.com/voucherifyio/voucherify-js-sdk/pull/228) Thanks [@marcin-slezak](https://github.com/marcin-slezak)! - Add missing methods covering Categories and Campaigns API.
16
+ - Added support for new endpoints [(examples of usage available in readme.md)](..%2F..%2Fpackages%2Fsdk%2FREADME.md):
17
+ - `POST /campaigns/campaignId/enable`,
18
+ - `POST /campaigns/campaignId/disable`,
19
+ - `GET, POST DELETE /categories`,
20
+ - `GET PUT /categories/id`.
21
+ - New exported types/interfaces in `Categories.ts`:
22
+ - `ListCategories`,
23
+ - `CategoryObject`,
24
+ - `CreateCategory`,
25
+ - `ResponseCreateCategory`,
26
+ - `ResponseUpdateCategory`,
27
+ - `UpdateCategoryRequest`.
28
+
29
+ - [`52e7f5e`](https://github.com/voucherifyio/voucherify-js-sdk/commit/52e7f5e8d4ea6be4ba1b9d0550cba3ec3d893672) [#221](https://github.com/voucherifyio/voucherify-js-sdk/pull/221) Thanks [@p-zielinski](https://github.com/p-zielinski)! - Implementing the following changes:
30
+ - Update axios from `0.21.4` to `0.27.2` in SDK package
31
+ - Added dotenv `16.3.1` to SDK package dev dependencies.
32
+ - Added frame for integration tests [(more info available in README.md, section "🧪 SDK Tests")](..%2F..%2FREADME.md)
33
+
34
+ ## 2.2.6
35
+
36
+ ### Patch Changes
37
+
38
+ - [`a266c2a`](https://github.com/voucherifyio/voucherify-js-sdk/commit/a266c2a9a4a1942e2b6d8ef54021e04d36ddb02c) [#223](https://github.com/voucherifyio/voucherify-js-sdk/pull/223) Thanks [@darekg11](https://github.com/darekg11)! - Add optional timeoutMs option to VoucherifyServerSide and VoucherifyClientSide classes defiing timeout in miliseconds after which Axios is going to abort the request. By default this is equal to 0 meaining that there is no timeout beside default Voucherify's Load balancer timeout which is set to 3 minutes
39
+
3
40
  ## 2.2.5
4
41
 
5
42
  ### Patch Changes
package/README.md CHANGED
@@ -131,6 +131,7 @@ const client = VoucherifyServerSide({
131
131
  apiVersion: 'v2018-08-01', // optional
132
132
  channel: 'e-commerce', // optional
133
133
  customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
134
+ timeoutMs: 10000 // optional
134
135
  })
135
136
  ```
136
137
 
@@ -153,6 +154,7 @@ Methods are provided within `client.vouchers.*` namespace.
153
154
  - [Update Vouchers Metadata in bulk](#update-vouchers-metadata-in-bulk)
154
155
  - [Update Vouchers in bulk](#update-vouchers-in-bulk)
155
156
  - [Release Validation Session](#release-validation-session)
157
+ - [Import Vouchers using CSV](#import-vouchers-using-csv)
156
158
 
157
159
  #### [Create Voucher](https://docs.voucherify.io/reference/create-voucher)
158
160
 
@@ -236,6 +238,12 @@ client.vouchers.bulkUpdate(vouchers)
236
238
  client.vouchers.releaseValidationSession(code, sessionKey)
237
239
  ```
238
240
 
241
+ #### [Import Vouchers using CSV](https://docs.voucherify.io/reference/import-vouchers-using-csv)
242
+
243
+ ```javascript
244
+ client.vouchers.importCSV(filePath)
245
+ ```
246
+
239
247
  ---
240
248
 
241
249
  ### Campaigns
@@ -248,7 +256,10 @@ Methods are provided within `client.campaigns.*` namespace.
248
256
  - [Add Voucher to Campaign](#add-voucher-to-campaign)
249
257
  - [Import Vouchers to Campaign](#import-vouchers-to-campaign)
250
258
  - [List Campaigns](#list-campaigns)
259
+ - [Import Vouchers using CSV](#import-vouchers-using-csv)
251
260
  - [Examine Campaigns Qualification](#examine-campaigns-qualification)
261
+ - [Enable campaign](#enable-campaign)
262
+ - [Disable campaign](#disable-campaign)
252
263
 
253
264
  #### [Create Campaign](https://docs.voucherify.io/reference/create-campaign)
254
265
 
@@ -306,13 +317,30 @@ client.campaigns.list()
306
317
  client.campaigns.list(params)
307
318
  ```
308
319
 
320
+ #### [Import Vouchers to Campaign by CSV](https://docs.voucherify.io/reference/import-vouchers-to-campaign-using-csv)
321
+
322
+ ```javascript
323
+ client.campaigns.importVouchersCSV(campaignId, filePath)
324
+ ```
325
+
326
+ #### [Enable campaign](https://docs.voucherify.io/reference/enable-campaign)
327
+
328
+ ```javascript
329
+ client.campaigns.enable(campaignId)
330
+ ```
331
+
332
+ #### [Disable campaign](https://docs.voucherify.io/reference/disable-campaign)
333
+
334
+ ```javascript
335
+ client.campaigns.disable(campaignId)
336
+ ```
337
+
309
338
  #### [Examine Campaigns Qualification](https://docs.voucherify.io/reference/create-qualification-request)
310
339
 
311
340
  ```javascript
312
341
  client.campaigns.qualifications.examine(body)
313
342
  client.campaigns.qualifications.examine(body, params)
314
343
  ```
315
-
316
344
  ---
317
345
 
318
346
  ### Distributions
@@ -358,6 +386,46 @@ client.distributions.publications.list(params)
358
386
  client.distributions.publications.create(params)
359
387
  ```
360
388
 
389
+ ### Categories
390
+
391
+ Methods are provided within `client.categories.*` namespace.
392
+
393
+ - [Create Category](#create-category)
394
+ - [Update Category](#update-category)
395
+ - [Get Category](#get-category)
396
+ - [Delete Category](#delete-category)
397
+ - [List Categories](#list-categories)
398
+
399
+ #### [Create Category](https://docs.voucherify.io/reference/create-category)
400
+
401
+ ```javascript
402
+ client.categories.create(params)
403
+ ```
404
+
405
+ #### [Update Category](https://docs.voucherify.io/reference/update-category)
406
+
407
+ ```javascript
408
+ client.categories.update(categoryId, params)
409
+ ```
410
+
411
+ #### [Get Category](https://docs.voucherify.io/reference/get-category)
412
+
413
+ ```javascript
414
+ client.categories.get(categoryId)
415
+ ```
416
+
417
+ #### [Delete Category](https://docs.voucherify.io/reference/delete-category)
418
+
419
+ ```javascript
420
+ client.categories.delete(categoryId)
421
+ ```
422
+
423
+ #### [List Categories](https://docs.voucherify.io/reference/list-categories)
424
+
425
+ ```javascript
426
+ client.categories.list()
427
+ ```
428
+
361
429
  ---
362
430
 
363
431
  ### Validations
@@ -546,6 +614,7 @@ Methods are provided within `client.customers.*` namespace.
546
614
  - [List Customers](#list-customers)
547
615
  - [Update Customer's Consents](#update-customers-consents)
548
616
  - [List Customer's Activities](#list-customers-activities)
617
+ - [Import and Update Customers using CSV](#import-and-update-customers-using-csv)
549
618
 
550
619
  #### [Create Customer](https://docs.voucherify.io/reference/create-customer)
551
620
 
@@ -627,6 +696,12 @@ client.customers.listActivities(customerId)
627
696
  client.customers.listActivities(customerId, params)
628
697
  ```
629
698
 
699
+ #### [Import and Update Customers using CSV](https://docs.voucherify.io/reference/import-customers-using-csv)
700
+
701
+ ```javascript
702
+ client.customers.importCSV(filePath)
703
+ ```
704
+
630
705
  ---
631
706
 
632
707
  ### Consents
@@ -706,6 +781,8 @@ Methods are provided within `client.products.*` namespace.
706
781
  - [Update SKU](#update-sku)
707
782
  - [Delete SKU](#delete-sku)
708
783
  - [List all product SKUs](#list-all-product-skus)
784
+ - [Import SKUs using CSV](#import-skus-using-csv)
785
+ - [Import Products using CSV](#import-products-using-csv)
709
786
 
710
787
  #### [Create Product](https://docs.voucherify.io/reference/create-product)
711
788
 
@@ -780,6 +857,18 @@ client.products.deleteSku(productId, skuId, { force: true })
780
857
  client.products.listSkus(productId)
781
858
  ```
782
859
 
860
+ #### [Import SKUs using CSV](https://docs.voucherify.io/reference/import-skus-using-csv)
861
+
862
+ ```javascript
863
+ client.products.importSkusCSV(filePath)
864
+ ```
865
+
866
+ #### [Import Products using CSV](https://docs.voucherify.io/reference/import-products-using-csv)
867
+
868
+ ```javascript
869
+ client.products.importCSV(filePath)
870
+ ```
871
+
783
872
  ---
784
873
 
785
874
  ### Rewards
@@ -1214,6 +1303,7 @@ const client = VoucherifyClientSide({
1214
1303
  apiUrl: 'https://<region>.api.voucherify.io', // optional
1215
1304
  origin: 'example.com', // read more below
1216
1305
  customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
1306
+ timeoutMs: 10000 // optional
1217
1307
  })
1218
1308
  ```
1219
1309
 
@@ -1,4 +1,5 @@
1
1
  import * as T from './types/Campaigns';
2
+ import * as AAT from './types/AsyncActions';
2
3
  import type { RequestController } from './RequestController';
3
4
  declare class CampaignsQualifications {
4
5
  private client;
@@ -41,5 +42,17 @@ export declare class Campaigns {
41
42
  * @see https://docs.voucherify.io/reference/list-campaigns
42
43
  */
43
44
  list(params?: T.CampaignsListParams): Promise<T.CampaignsListResponse>;
45
+ /**
46
+ * @see https://api.voucherify.io/v1/campaigns/{campaignId}/importCSV
47
+ */
48
+ importVouchersCSV(campaignId: string, filePath: string): Promise<AAT.AsyncActionCreateResponse>;
49
+ /**
50
+ * @see https://docs.voucherify.io/reference/enable-campaign
51
+ */
52
+ enable(campaignId: string): Promise<{}>;
53
+ /**
54
+ * @see https://docs.voucherify.io/reference/disable-campaign
55
+ */
56
+ disable(campaignId: string): Promise<{}>;
44
57
  }
45
58
  export {};
@@ -0,0 +1,26 @@
1
+ import * as T from './types/Categories';
2
+ import type { RequestController } from './RequestController';
3
+ export declare class Categories {
4
+ private client;
5
+ constructor(client: RequestController);
6
+ /**
7
+ * @see https://docs.voucherify.io/reference/list-categories
8
+ */
9
+ list(): Promise<T.ListCategories>;
10
+ /**
11
+ * @see https://docs.voucherify.io/reference/create-category
12
+ */
13
+ create(createCategory: T.CreateCategory): Promise<T.ResponseCreateCategory>;
14
+ /**
15
+ * @see https://docs.voucherify.io/reference/get-category
16
+ */
17
+ get(categoryId: string): Promise<T.CategoryObject>;
18
+ /**
19
+ * @see https://docs.voucherify.io/reference/delete-category
20
+ */
21
+ delete(categoryId: string): Promise<{}>;
22
+ /**
23
+ * @see https://docs.voucherify.io/reference/update-category
24
+ */
25
+ update(categoryId: string, updateCategory: T.UpdateCategoryRequest): Promise<T.ResponseUpdateCategory>;
26
+ }
@@ -1,4 +1,5 @@
1
1
  import * as T from './types/Customers';
2
+ import * as AAT from './types/AsyncActions';
2
3
  import type { RequestController } from './RequestController';
3
4
  declare class Customers {
4
5
  private client;
@@ -43,5 +44,9 @@ declare class Customers {
43
44
  * @see https://docs.voucherify.io/reference/get-customer-activities
44
45
  */
45
46
  listActivities(customerId: string, params?: T.CustomerActivitiesListQueryParams): Promise<T.CustomerActivitiesListResponse>;
47
+ /**
48
+ * @see https://docs.voucherify.io/reference/import-customers-using-csv
49
+ */
50
+ importCSV(filePath: string): Promise<AAT.AsyncActionCreateResponse>;
46
51
  }
47
52
  export { Customers };
@@ -1,4 +1,5 @@
1
1
  import * as T from './types/Products';
2
+ import * as AAT from './types/AsyncActions';
2
3
  import type { RequestController } from './RequestController';
3
4
  export declare class Products {
4
5
  private client;
@@ -51,4 +52,12 @@ export declare class Products {
51
52
  * @see https://docs.voucherify.io/reference/list-skus
52
53
  */
53
54
  listSkus(productId: string): Promise<T.ProductsListSkus>;
55
+ /**
56
+ * @see https://docs.voucherify.io/reference/import-skus-using-csv
57
+ */
58
+ importSkusCSV(filePath: string): Promise<AAT.AsyncActionCreateResponse>;
59
+ /**
60
+ * @see https://docs.voucherify.io/reference/import-products-using-csv
61
+ */
62
+ importCSV(filePath: string): Promise<AAT.AsyncActionCreateResponse>;
54
63
  }
@@ -3,6 +3,7 @@ export interface RequestControllerOptions {
3
3
  basePath: string;
4
4
  headers: Record<string, any>;
5
5
  exposeErrorCause: boolean;
6
+ timeoutMs: number;
6
7
  }
7
8
  /**
8
9
  * @internal
@@ -15,7 +16,8 @@ export declare class RequestController {
15
16
  private lastResponseHeaders;
16
17
  private isLastResponseHeadersSet;
17
18
  private exposeErrorCause;
18
- constructor({ basePath, baseURL, headers, exposeErrorCause }: RequestControllerOptions);
19
+ private timeoutMs;
20
+ constructor({ basePath, baseURL, headers, exposeErrorCause, timeoutMs }: RequestControllerOptions);
19
21
  isLastReponseHeadersSet(): boolean;
20
22
  getLastResponseHeaders(): Record<string, string>;
21
23
  private setLastResponseHeaders;
@@ -78,5 +78,9 @@ export interface VoucherifyClientSideOptions {
78
78
  * The original Axios error will be included in cause property of VoucherifyError
79
79
  */
80
80
  exposeErrorCause?: boolean;
81
+ /**
82
+ * Optionally, you can set timeout in miliseconds. After this time request will be aborted. By default Voucherify's API has timeout value of 3 minutes.
83
+ */
84
+ timeoutMs?: number;
81
85
  }
82
86
  export declare function VoucherifyClientSide(options: VoucherifyClientSideOptions): ClientSide;
@@ -16,6 +16,7 @@ import { ValidationRules } from './ValidationRules';
16
16
  import { Segments } from './Segments';
17
17
  import { ApiLimitsHandler } from './ApiLimitsHandler';
18
18
  import { MetadataSchemas } from './MetadataSchemas';
19
+ import { Categories } from './Categories';
19
20
  export interface VoucherifyServerSideOptions {
20
21
  /**
21
22
  * Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
@@ -98,10 +99,15 @@ export interface VoucherifyServerSideOptions {
98
99
  * The original Axios error will be included in cause property of VoucherifyError
99
100
  */
100
101
  exposeErrorCause?: boolean;
102
+ /**
103
+ * Optionally, you can set timeout in miliseconds. After this time request will be aborted. By default Voucherify's API has timeout value of 3 minutes.
104
+ */
105
+ timeoutMs?: number;
101
106
  }
102
107
  export declare function VoucherifyServerSide(options: VoucherifyServerSideOptions): {
103
108
  vouchers: Vouchers;
104
109
  campaigns: Campaigns;
110
+ categories: Categories;
105
111
  distributions: Distributions;
106
112
  validations: Validations;
107
113
  redemptions: Redemptions;
@@ -1,4 +1,5 @@
1
1
  import * as T from './types/Vouchers';
2
+ import * as AAT from './types/AsyncActions';
2
3
  import type { RequestController } from './RequestController';
3
4
  import type { Balance } from './Balance';
4
5
  declare class VouchersQualification {
@@ -61,5 +62,9 @@ export declare class Vouchers {
61
62
  * @see https://docs.voucherify.io/reference/release-validation-session
62
63
  */
63
64
  releaseValidationSession(code: string, sessionKey: string): Promise<unknown>;
65
+ /**
66
+ * @see https://docs.voucherify.io/reference/import-vouchers-using-csv
67
+ */
68
+ importCSV(filePath: string): Promise<AAT.AsyncActionCreateResponse>;
64
69
  }
65
70
  export {};
@@ -0,0 +1,24 @@
1
+ export interface ListCategories {
2
+ object: 'list';
3
+ data_ref: 'data';
4
+ data: CategoryObject[];
5
+ total: number;
6
+ }
7
+ export declare type CategoryObject = ResponseCreateCategory & {
8
+ updated_at?: string;
9
+ };
10
+ export interface CreateCategory {
11
+ name: string;
12
+ hierarchy: number;
13
+ }
14
+ export interface ResponseCreateCategory {
15
+ id: string;
16
+ name: string;
17
+ hierarchy: number;
18
+ created_at: string;
19
+ object: 'category';
20
+ }
21
+ export declare type ResponseUpdateCategory = ResponseCreateCategory & {
22
+ updated_at: string;
23
+ };
24
+ export declare type UpdateCategoryRequest = CreateCategory;