@voucherify/sdk 2.2.6 → 2.4.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
 
@@ -830,6 +873,22 @@
830
873
  const customerWithoutId = omit(customer, ['id']);
831
874
  return this.client.put(`/customers/${encode(id)}`, customerWithoutId);
832
875
  }
876
+ /**
877
+ * @see https://docs.voucherify.io/reference/update-customers-in-bulk
878
+ */
879
+
880
+
881
+ updateInBulk(customers) {
882
+ return this.client.post(`/customers/bulk/async`, customers);
883
+ }
884
+ /**
885
+ * @see https://docs.voucherify.io/reference/update-customers-metadata-in-bulk
886
+ */
887
+
888
+
889
+ updateMetadataInBulk(sourceIdsAndMetadata) {
890
+ return this.client.post(`/customers/metadata/async`, sourceIdsAndMetadata);
891
+ }
833
892
  /**
834
893
  * @see https://docs.voucherify.io/reference/delete-customer
835
894
  */
@@ -838,6 +897,14 @@
838
897
  delete(customerId) {
839
898
  return this.client.delete(`/customers/${encode(customerId)}`);
840
899
  }
900
+ /**
901
+ * @see https://docs.voucherify.io/reference/delete-customer-permanently
902
+ */
903
+
904
+
905
+ deletePermanently(customerId) {
906
+ return this.client.post(`/customers/${encode(customerId)}/permanent-deletion`, {});
907
+ }
841
908
  /**
842
909
  * @see https://docs.voucherify.io/reference/update-customers-consents
843
910
  */
@@ -854,6 +921,19 @@
854
921
  listActivities(customerId, params) {
855
922
  return this.client.get(`/customers/${encode(customerId)}/activities`, params);
856
923
  }
924
+ /**
925
+ * @see https://docs.voucherify.io/reference/import-customers-using-csv
926
+ */
927
+
928
+
929
+ async importCSV(filePath) {
930
+ assert(environment().startsWith('Node'), `Method "client.customers.importCSV(filePath)" is only for Node environment`);
931
+ const fs = (await import('fs')).default;
932
+ const fileStream = fs.createReadStream(filePath);
933
+ const form = new FormData();
934
+ form.append('file', fileStream);
935
+ return this.client.post(`/customers/importCSV`, form);
936
+ }
857
937
 
858
938
  }
859
939
 
@@ -1022,6 +1102,32 @@
1022
1102
  listSkus(productId) {
1023
1103
  return this.client.get(`/products/${encode(productId)}/skus`);
1024
1104
  }
1105
+ /**
1106
+ * @see https://docs.voucherify.io/reference/import-skus-using-csv
1107
+ */
1108
+
1109
+
1110
+ async importSkusCSV(filePath) {
1111
+ assert(environment().startsWith('Node'), `Method "client.products.importSkusCSV(filePath)" is only for Node environment`);
1112
+ const fs = (await import('fs')).default;
1113
+ const fileStream = fs.createReadStream(filePath);
1114
+ const form = new FormData();
1115
+ form.append('file', fileStream);
1116
+ return this.client.post(`/skus/importCSV`, form);
1117
+ }
1118
+ /**
1119
+ * @see https://docs.voucherify.io/reference/import-products-using-csv
1120
+ */
1121
+
1122
+
1123
+ async importCSV(filePath) {
1124
+ assert(environment().startsWith('Node'), `Method "client.products.importCSV(filePath)" is only for Node environment`);
1125
+ const fs = (await import('fs')).default;
1126
+ const fileStream = fs.createReadStream(filePath);
1127
+ const form = new FormData();
1128
+ form.append('file', fileStream);
1129
+ return this.client.post(`/products/importCSV`, form);
1130
+ }
1025
1131
 
1026
1132
  }
1027
1133
 
@@ -1210,6 +1316,30 @@
1210
1316
  deleteEarningRule(campaignId, earningRuleId) {
1211
1317
  return this.client.delete(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}`);
1212
1318
  }
1319
+ /**
1320
+ * @see https://docs.voucherify.io/reference/get-earning-rule
1321
+ */
1322
+
1323
+
1324
+ getEarningRule(campaignId, earningRuleId) {
1325
+ return this.client.get(`/loyalties/${encode(campaignId)}/earning-rules/${encode(earningRuleId)}`);
1326
+ }
1327
+ /**
1328
+ * @see https://docs.voucherify.io/reference/enable-earning-rule
1329
+ */
1330
+
1331
+
1332
+ enableEarningRule(campaignId, earningRuleId) {
1333
+ return this.client.post(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/enable`, {});
1334
+ }
1335
+ /**
1336
+ * @see https://docs.voucherify.io/reference/disable-earning-rule
1337
+ */
1338
+
1339
+
1340
+ disableEarningRule(campaignId, earningRuleId) {
1341
+ return this.client.post(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/disable`, {});
1342
+ }
1213
1343
  /**
1214
1344
  * @see https://docs.voucherify.io/reference/list-members
1215
1345
  */
@@ -1438,6 +1568,54 @@
1438
1568
 
1439
1569
  }
1440
1570
 
1571
+ class Categories {
1572
+ constructor(client) {
1573
+ this.client = void 0;
1574
+ this.client = client;
1575
+ }
1576
+ /**
1577
+ * @see https://docs.voucherify.io/reference/list-categories
1578
+ */
1579
+
1580
+
1581
+ list() {
1582
+ return this.client.get('/categories');
1583
+ }
1584
+ /**
1585
+ * @see https://docs.voucherify.io/reference/create-category
1586
+ */
1587
+
1588
+
1589
+ create(createCategory) {
1590
+ return this.client.post('/categories', createCategory);
1591
+ }
1592
+ /**
1593
+ * @see https://docs.voucherify.io/reference/get-category
1594
+ */
1595
+
1596
+
1597
+ get(categoryId) {
1598
+ return this.client.get(`/categories/${encode(categoryId)}`);
1599
+ }
1600
+ /**
1601
+ * @see https://docs.voucherify.io/reference/delete-category
1602
+ */
1603
+
1604
+
1605
+ delete(categoryId) {
1606
+ return this.client.delete(`/categories/${encode(categoryId)}`);
1607
+ }
1608
+ /**
1609
+ * @see https://docs.voucherify.io/reference/update-category
1610
+ */
1611
+
1612
+
1613
+ update(categoryId, updateCategory) {
1614
+ return this.client.put(`/categories/${encode(categoryId)}`, updateCategory);
1615
+ }
1616
+
1617
+ }
1618
+
1441
1619
  // apiLimitsHandler: ApiLimitsHandler
1442
1620
  // campaigns: Campaigns
1443
1621
  // consents: Consents
@@ -1468,7 +1646,7 @@
1468
1646
  let headers = {
1469
1647
  'X-App-Id': options.applicationId,
1470
1648
  'X-App-Token': options.secretKey,
1471
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.2.6"}`,
1649
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.4.0"}`,
1472
1650
  'Content-Type': 'application/json'
1473
1651
  };
1474
1652
 
@@ -1501,6 +1679,7 @@
1501
1679
  const balance = new Balance(client);
1502
1680
  const vouchers = new Vouchers(client, balance);
1503
1681
  const campaigns = new Campaigns(client);
1682
+ const categories = new Categories(client);
1504
1683
  const exportsNamespace = new Exports(client);
1505
1684
  const events = new Events(client);
1506
1685
  const distributions = new Distributions(client, exportsNamespace);
@@ -1521,6 +1700,7 @@
1521
1700
  return {
1522
1701
  vouchers,
1523
1702
  campaigns,
1703
+ categories,
1524
1704
  distributions,
1525
1705
  validations,
1526
1706
  redemptions,
@@ -1719,7 +1899,7 @@
1719
1899
  let headers = {
1720
1900
  'X-Client-Application-Id': options.clientApplicationId,
1721
1901
  'X-Client-Token': options.clientSecretKey,
1722
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.2.6"}`
1902
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.4.0"}`
1723
1903
  };
1724
1904
 
1725
1905
  if (environment().startsWith('Node')) {