@voucherify/sdk 2.5.0 → 2.7.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.
@@ -109,7 +109,13 @@
109
109
  }
110
110
 
111
111
  setLastResponseHeaders(headers) {
112
- this.lastResponseHeaders = headers;
112
+ const result = {};
113
+
114
+ for (const key in headers) {
115
+ result[key] = String(headers[key]);
116
+ }
117
+
118
+ this.lastResponseHeaders = result;
113
119
  this.isLastResponseHeadersSet = true;
114
120
  }
115
121
 
@@ -327,7 +333,10 @@
327
333
  const fileStream = fs.createReadStream(filePath);
328
334
  const form = new FormData();
329
335
  form.append('file', fileStream);
330
- return this.client.post(`/campaigns/${campaignId}/importCSV`, form);
336
+ const headers = {
337
+ 'Content-Type': 'multipart/form-data'
338
+ };
339
+ return this.client.post(`/campaigns/${campaignId}/importCSV`, form, undefined, headers);
331
340
  }
332
341
  /**
333
342
  * @see https://docs.voucherify.io/reference/enable-campaign
@@ -588,7 +597,26 @@
588
597
  const fileStream = fs.createReadStream(filePath);
589
598
  const form = new FormData();
590
599
  form.append('file', fileStream);
591
- return this.client.post('/vouchers/importCSV', form);
600
+ const headers = {
601
+ 'Content-Type': 'multipart/form-data'
602
+ };
603
+ return this.client.post('/vouchers/importCSV', form, undefined, headers);
604
+ }
605
+ /**
606
+ * @see https://docs.voucherify.io/reference/list-voucher-transactions
607
+ */
608
+
609
+
610
+ listTransactions(code, params) {
611
+ return this.client.get(`/vouchers/${encode(code)}/transactions`, params);
612
+ }
613
+ /**
614
+ * @see https://docs.voucherify.io/reference/export-voucher-transactions
615
+ */
616
+
617
+
618
+ exportTransactions(code, body) {
619
+ return this.client.post(`/vouchers/${encode(code)}/transactions/export`, body);
592
620
  }
593
621
 
594
622
  }
@@ -777,11 +805,13 @@
777
805
  }
778
806
 
779
807
  class Promotions {
780
- constructor(client, tiers) {
808
+ constructor(client, tiers, stack) {
781
809
  this.client = void 0;
782
810
  this.tiers = void 0;
811
+ this.stack = void 0;
783
812
  this.client = client;
784
813
  this.tiers = tiers;
814
+ this.stack = stack;
785
815
  }
786
816
  /**
787
817
  * @see https://docs.voucherify.io/reference/create-promotion-campaign
@@ -940,7 +970,10 @@
940
970
  const fileStream = fs.createReadStream(filePath);
941
971
  const form = new FormData();
942
972
  form.append('file', fileStream);
943
- return this.client.post(`/customers/importCSV`, form);
973
+ const headers = {
974
+ 'Content-Type': 'multipart/form-data'
975
+ };
976
+ return this.client.post(`/customers/importCSV`, form, undefined, headers);
944
977
  }
945
978
 
946
979
  }
@@ -1121,7 +1154,10 @@
1121
1154
  const fileStream = fs.createReadStream(filePath);
1122
1155
  const form = new FormData();
1123
1156
  form.append('file', fileStream);
1124
- return this.client.post(`/skus/importCSV`, form);
1157
+ const headers = {
1158
+ 'Content-Type': 'multipart/form-data'
1159
+ };
1160
+ return this.client.post(`/skus/importCSV`, form, undefined, headers);
1125
1161
  }
1126
1162
  /**
1127
1163
  * @see https://docs.voucherify.io/reference/import-products-using-csv
@@ -1134,7 +1170,10 @@
1134
1170
  const fileStream = fs.createReadStream(filePath);
1135
1171
  const form = new FormData();
1136
1172
  form.append('file', fileStream);
1137
- return this.client.post(`/products/importCSV`, form);
1173
+ const headers = {
1174
+ 'Content-Type': 'multipart/form-data'
1175
+ };
1176
+ return this.client.post(`/products/importCSV`, form, undefined, headers);
1138
1177
  }
1139
1178
 
1140
1179
  }
@@ -1184,6 +1223,14 @@
1184
1223
  delete(rewardId) {
1185
1224
  return this.client.delete(`/rewards/${encode(rewardId)}`);
1186
1225
  }
1226
+ /**
1227
+ * @see https://docs.voucherify.io/reference/get-reward-assignment
1228
+ */
1229
+
1230
+
1231
+ getAssignment(rewardId, assignmentId) {
1232
+ return this.client.get(`/rewards/${encode(rewardId)}/assignments/${encode(assignmentId)}`);
1233
+ }
1187
1234
  /**
1188
1235
  * @see https://docs.voucherify.io/reference/list-reward-assignments
1189
1236
  */
@@ -1292,6 +1339,14 @@
1292
1339
  deleteRewardAssignment(campaignId, assignmentId) {
1293
1340
  return this.client.delete(`/loyalties/${encode(campaignId)}/rewards/${assignmentId}`);
1294
1341
  }
1342
+ /**
1343
+ * @see https://docs.voucherify.io/reference/get-reward-assignment-2
1344
+ */
1345
+
1346
+
1347
+ getRewardAssignment(campaignId, assignmentId) {
1348
+ return this.client.get(`/loyalties/${encode(campaignId)}/rewards/${encode(assignmentId)}`);
1349
+ }
1295
1350
  /**
1296
1351
  * @see https://docs.voucherify.io/reference/list-earning-rules
1297
1352
  */
@@ -1431,6 +1486,14 @@
1431
1486
  redeemReward(campaignId, memberId, params) {
1432
1487
  return this.client.post(`/loyalties/${encode(campaignId)}/members/${encode(memberId)}/redemption`, params);
1433
1488
  }
1489
+ /**
1490
+ * @see https://docs.voucherify.io/reference/list-loyalty-tier-rewards
1491
+ */
1492
+
1493
+
1494
+ listLoyaltyTierRewards(campaignId, tierId) {
1495
+ return this.client.get(`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}/rewards`);
1496
+ }
1434
1497
  /**
1435
1498
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions
1436
1499
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions-1
@@ -1449,14 +1512,6 @@
1449
1512
  exportCardTransactions(memberId, campaignId, params = {}) {
1450
1513
  return this.client.post(campaignId ? `/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transactions/export` : `/loyalties/members/${encode(memberId)}/transactions/export`, params);
1451
1514
  }
1452
- /**
1453
- * @see https://docs.voucherify.io/reference/get-reward-assignment-1
1454
- */
1455
-
1456
-
1457
- getRewardAssignment(campaignId, assignmentId) {
1458
- return this.client.get(`/loyalties/${encode(campaignId)}/reward-assignments/${encode(assignmentId)}`);
1459
- }
1460
1515
  /**
1461
1516
  * @see https://docs.voucherify.io/reference/get-reward-details
1462
1517
  */
@@ -1573,6 +1628,14 @@
1573
1628
  list(params = {}) {
1574
1629
  return this.client.get('/validation-rules', params);
1575
1630
  }
1631
+ /**
1632
+ * @see https://docs.voucherify.io/reference/list-validation-rules-assignments
1633
+ */
1634
+
1635
+
1636
+ listRulesAssignments(params = {}) {
1637
+ return this.client.get(`/validation-rules-assignments`, params);
1638
+ }
1576
1639
  /**
1577
1640
  * @see https://docs.voucherify.io/reference/list-validation-rule-assignments
1578
1641
  */
@@ -1695,8 +1758,8 @@
1695
1758
  */
1696
1759
 
1697
1760
 
1698
- list() {
1699
- return this.client.get('/categories');
1761
+ list(params = {}) {
1762
+ return this.client.get('/categories', params);
1700
1763
  }
1701
1764
  /**
1702
1765
  * @see https://docs.voucherify.io/reference/create-category
@@ -1733,6 +1796,62 @@
1733
1796
 
1734
1797
  }
1735
1798
 
1799
+ class PromotionsStacks {
1800
+ constructor(client) {
1801
+ this.client = void 0;
1802
+ this.client = client;
1803
+ }
1804
+ /**
1805
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1806
+ */
1807
+
1808
+
1809
+ listInCampaign(campaignId) {
1810
+ return this.client.get(`/promotions/${campaignId}/stacks`);
1811
+ }
1812
+ /**
1813
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1814
+ */
1815
+
1816
+
1817
+ createInCampaign(campaignId, body) {
1818
+ return this.client.post(`/promotions/${campaignId}/stacks`, body);
1819
+ }
1820
+ /**
1821
+ * @see https://docs.voucherify.io/reference/delete-promotion-stack
1822
+ */
1823
+
1824
+
1825
+ delete(campaignId, stackId) {
1826
+ return this.client.delete(`/promotions/${campaignId}/stacks/${stackId}`);
1827
+ }
1828
+ /**
1829
+ * @see https://docs.voucherify.io/reference/get-promotion-stack
1830
+ */
1831
+
1832
+
1833
+ get(campaignId, stackId) {
1834
+ return this.client.get(`/promotions/${campaignId}/stacks/${stackId}`);
1835
+ }
1836
+ /**
1837
+ * @see https://docs.voucherify.io/reference/update-promotion-stack
1838
+ */
1839
+
1840
+
1841
+ update(campaignId, stackId, body) {
1842
+ return this.client.put(`/promotions/${campaignId}/stacks/${stackId}`, body);
1843
+ }
1844
+ /**
1845
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1846
+ */
1847
+
1848
+
1849
+ list(params) {
1850
+ return this.client.get(`/promotions/stacks`, params);
1851
+ }
1852
+
1853
+ }
1854
+
1736
1855
  class ProductCollections {
1737
1856
  constructor(client) {
1738
1857
  this.client = void 0;
@@ -1781,6 +1900,22 @@
1781
1900
 
1782
1901
  }
1783
1902
 
1903
+ class Qualifications {
1904
+ constructor(client) {
1905
+ this.client = void 0;
1906
+ this.client = client;
1907
+ }
1908
+ /**
1909
+ * @see https://docs.voucherify.io/reference/check-eligibility
1910
+ */
1911
+
1912
+
1913
+ checkEligibility(body) {
1914
+ return this.client.post('/qualifications', body);
1915
+ }
1916
+
1917
+ }
1918
+
1784
1919
  // apiLimitsHandler: ApiLimitsHandler
1785
1920
  // campaigns: Campaigns
1786
1921
  // consents: Consents
@@ -1811,7 +1946,7 @@
1811
1946
  let headers = {
1812
1947
  'X-App-Id': options.applicationId,
1813
1948
  'X-App-Token': options.secretKey,
1814
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.5.0"}`,
1949
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.0"}`,
1815
1950
  'Content-Type': 'application/json'
1816
1951
  };
1817
1952
 
@@ -1849,9 +1984,11 @@
1849
1984
  const events = new Events(client);
1850
1985
  const distributions = new Distributions(client, exportsNamespace);
1851
1986
  const promotionTiers = new PromotionTiers(client);
1852
- const promotions = new Promotions(client, promotionTiers);
1987
+ const promotionStack = new PromotionsStacks(client);
1988
+ const promotions = new Promotions(client, promotionTiers, promotionStack);
1853
1989
  const validations = new Validations(client, promotions);
1854
1990
  const redemptions = new Redemptions(client);
1991
+ const qualifications = new Qualifications(client);
1855
1992
  const customers = new Customers(client);
1856
1993
  const consents = new Consents(client);
1857
1994
  const orders = new Orders(client);
@@ -1876,6 +2013,7 @@
1876
2013
  orders,
1877
2014
  products,
1878
2015
  productCollections,
2016
+ qualifications,
1879
2017
  rewards,
1880
2018
  loyalties,
1881
2019
  segments,
@@ -2052,6 +2190,14 @@
2052
2190
  redeemStackable(params) {
2053
2191
  return this.client.post(`/redemptions`, params);
2054
2192
  }
2193
+ /**
2194
+ * @see https://docs.voucherify.io/reference/check-eligibility
2195
+ */
2196
+
2197
+
2198
+ qualifications(body) {
2199
+ return this.client.post('/qualifications', body);
2200
+ }
2055
2201
 
2056
2202
  }
2057
2203
 
@@ -2066,7 +2212,7 @@
2066
2212
  let headers = {
2067
2213
  'X-Client-Application-Id': options.clientApplicationId,
2068
2214
  'X-Client-Token': options.clientSecretKey,
2069
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.5.0"}`
2215
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.0"}`
2070
2216
  };
2071
2217
 
2072
2218
  if (environment().startsWith('Node')) {