@voucherify/sdk 2.2.6 → 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.
@@ -1,11 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios'), require('qs')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'axios', 'qs'], factory) :
4
- (global = global || self, factory(global.VoucherifySDK = {}, global.axios, global.Qs));
5
- }(this, (function (exports, axios, Qs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios'), require('qs'), require('form-data')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'axios', 'qs', 'form-data'], factory) :
4
+ (global = global || self, factory(global.VoucherifySDK = {}, global.axios, global.Qs, global.FormData));
5
+ }(this, (function (exports, axios, Qs, FormData) { 'use strict';
6
6
 
7
7
  axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
8
8
  Qs = Qs && Object.prototype.hasOwnProperty.call(Qs, 'default') ? Qs['default'] : Qs;
9
+ FormData = FormData && Object.prototype.hasOwnProperty.call(FormData, 'default') ? FormData['default'] : FormData;
9
10
 
10
11
  (function (DiscountVouchersTypesEnum) {
11
12
  DiscountVouchersTypesEnum["AMOUNT"] = "AMOUNT";
@@ -315,6 +316,35 @@
315
316
  list(params = {}) {
316
317
  return this.client.get('/campaigns', params);
317
318
  }
319
+ /**
320
+ * @see https://api.voucherify.io/v1/campaigns/{campaignId}/importCSV
321
+ */
322
+
323
+
324
+ async importVouchersCSV(campaignId, filePath) {
325
+ assert(environment().startsWith('Node'), `Method "client.campaigns.importVouchersCSV(campaignId, filePath)" is only for Node environment`);
326
+ const fs = (await import('fs')).default;
327
+ const fileStream = fs.createReadStream(filePath);
328
+ const form = new FormData();
329
+ form.append('file', fileStream);
330
+ return this.client.post(`/campaigns/${campaignId}/importCSV`, form);
331
+ }
332
+ /**
333
+ * @see https://docs.voucherify.io/reference/enable-campaign
334
+ */
335
+
336
+
337
+ enable(campaignId) {
338
+ return this.client.post(`/campaigns/${encode(campaignId)}/enable`, {});
339
+ }
340
+ /**
341
+ * @see https://docs.voucherify.io/reference/disable-campaign
342
+ */
343
+
344
+
345
+ disable(campaignId) {
346
+ return this.client.post(`/campaigns/${encode(campaignId)}/disable`, {});
347
+ }
318
348
 
319
349
  }
320
350
 
@@ -539,6 +569,19 @@
539
569
  releaseValidationSession(code, sessionKey) {
540
570
  return this.client.delete(`/vouchers/${encode(code)}/sessions/${encode(sessionKey)}`);
541
571
  }
572
+ /**
573
+ * @see https://docs.voucherify.io/reference/import-vouchers-using-csv
574
+ */
575
+
576
+
577
+ async importCSV(filePath) {
578
+ assert(environment().startsWith('Node'), `Method "client.vouchers.importCSV(filePath)" is only for Node environment`);
579
+ const fs = (await import('fs')).default;
580
+ const fileStream = fs.createReadStream(filePath);
581
+ const form = new FormData();
582
+ form.append('file', fileStream);
583
+ return this.client.post('/vouchers/importCSV', form);
584
+ }
542
585
 
543
586
  }
544
587
 
@@ -854,6 +897,19 @@
854
897
  listActivities(customerId, params) {
855
898
  return this.client.get(`/customers/${encode(customerId)}/activities`, params);
856
899
  }
900
+ /**
901
+ * @see https://docs.voucherify.io/reference/import-customers-using-csv
902
+ */
903
+
904
+
905
+ async importCSV(filePath) {
906
+ assert(environment().startsWith('Node'), `Method "client.customers.importCSV(filePath)" is only for Node environment`);
907
+ const fs = (await import('fs')).default;
908
+ const fileStream = fs.createReadStream(filePath);
909
+ const form = new FormData();
910
+ form.append('file', fileStream);
911
+ return this.client.post(`/customers/importCSV`, form);
912
+ }
857
913
 
858
914
  }
859
915
 
@@ -1022,6 +1078,32 @@
1022
1078
  listSkus(productId) {
1023
1079
  return this.client.get(`/products/${encode(productId)}/skus`);
1024
1080
  }
1081
+ /**
1082
+ * @see https://docs.voucherify.io/reference/import-skus-using-csv
1083
+ */
1084
+
1085
+
1086
+ async importSkusCSV(filePath) {
1087
+ assert(environment().startsWith('Node'), `Method "client.products.importSkusCSV(filePath)" is only for Node environment`);
1088
+ const fs = (await import('fs')).default;
1089
+ const fileStream = fs.createReadStream(filePath);
1090
+ const form = new FormData();
1091
+ form.append('file', fileStream);
1092
+ return this.client.post(`/skus/importCSV`, form);
1093
+ }
1094
+ /**
1095
+ * @see https://docs.voucherify.io/reference/import-products-using-csv
1096
+ */
1097
+
1098
+
1099
+ async importCSV(filePath) {
1100
+ assert(environment().startsWith('Node'), `Method "client.products.importCSV(filePath)" is only for Node environment`);
1101
+ const fs = (await import('fs')).default;
1102
+ const fileStream = fs.createReadStream(filePath);
1103
+ const form = new FormData();
1104
+ form.append('file', fileStream);
1105
+ return this.client.post(`/products/importCSV`, form);
1106
+ }
1025
1107
 
1026
1108
  }
1027
1109
 
@@ -1438,6 +1520,54 @@
1438
1520
 
1439
1521
  }
1440
1522
 
1523
+ class Categories {
1524
+ constructor(client) {
1525
+ this.client = void 0;
1526
+ this.client = client;
1527
+ }
1528
+ /**
1529
+ * @see https://docs.voucherify.io/reference/list-categories
1530
+ */
1531
+
1532
+
1533
+ list() {
1534
+ return this.client.get('/categories');
1535
+ }
1536
+ /**
1537
+ * @see https://docs.voucherify.io/reference/create-category
1538
+ */
1539
+
1540
+
1541
+ create(createCategory) {
1542
+ return this.client.post('/categories', createCategory);
1543
+ }
1544
+ /**
1545
+ * @see https://docs.voucherify.io/reference/get-category
1546
+ */
1547
+
1548
+
1549
+ get(categoryId) {
1550
+ return this.client.get(`/categories/${encode(categoryId)}`);
1551
+ }
1552
+ /**
1553
+ * @see https://docs.voucherify.io/reference/delete-category
1554
+ */
1555
+
1556
+
1557
+ delete(categoryId) {
1558
+ return this.client.delete(`/categories/${encode(categoryId)}`);
1559
+ }
1560
+ /**
1561
+ * @see https://docs.voucherify.io/reference/update-category
1562
+ */
1563
+
1564
+
1565
+ update(categoryId, updateCategory) {
1566
+ return this.client.put(`/categories/${encode(categoryId)}`, updateCategory);
1567
+ }
1568
+
1569
+ }
1570
+
1441
1571
  // apiLimitsHandler: ApiLimitsHandler
1442
1572
  // campaigns: Campaigns
1443
1573
  // consents: Consents
@@ -1468,7 +1598,7 @@
1468
1598
  let headers = {
1469
1599
  'X-App-Id': options.applicationId,
1470
1600
  'X-App-Token': options.secretKey,
1471
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.2.6"}`,
1601
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.3.0"}`,
1472
1602
  'Content-Type': 'application/json'
1473
1603
  };
1474
1604
 
@@ -1501,6 +1631,7 @@
1501
1631
  const balance = new Balance(client);
1502
1632
  const vouchers = new Vouchers(client, balance);
1503
1633
  const campaigns = new Campaigns(client);
1634
+ const categories = new Categories(client);
1504
1635
  const exportsNamespace = new Exports(client);
1505
1636
  const events = new Events(client);
1506
1637
  const distributions = new Distributions(client, exportsNamespace);
@@ -1521,6 +1652,7 @@
1521
1652
  return {
1522
1653
  vouchers,
1523
1654
  campaigns,
1655
+ categories,
1524
1656
  distributions,
1525
1657
  validations,
1526
1658
  redemptions,
@@ -1719,7 +1851,7 @@
1719
1851
  let headers = {
1720
1852
  'X-Client-Application-Id': options.clientApplicationId,
1721
1853
  'X-Client-Token': options.clientSecretKey,
1722
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.2.6"}`
1854
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.3.0"}`
1723
1855
  };
1724
1856
 
1725
1857
  if (environment().startsWith('Node')) {