@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.
- package/CHANGELOG.md +53 -0
- package/README.md +133 -3
- package/dist/Campaigns.d.ts +13 -0
- package/dist/Categories.d.ts +26 -0
- package/dist/Customers.d.ts +17 -0
- package/dist/Loyalties.d.ts +12 -0
- package/dist/Products.d.ts +9 -0
- package/dist/VoucherifyServerSide.d.ts +2 -0
- package/dist/Vouchers.d.ts +5 -0
- package/dist/types/Categories.d.ts +24 -0
- package/dist/types/Customers.d.ts +42 -0
- package/dist/types/Loyalties.d.ts +141 -0
- package/dist/voucherifysdk.esm.js +182 -2
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +186 -6
- package/dist/voucherifysdk.umd.development.js.map +1 -1
- package/dist/voucherifysdk.umd.production.min.js +1 -1
- package/dist/voucherifysdk.umd.production.min.js.map +1 -1
- package/package.json +10 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import Qs from 'qs';
|
|
3
|
+
import FormData from 'form-data';
|
|
3
4
|
|
|
4
5
|
var DiscountVouchersTypesEnum;
|
|
5
6
|
|
|
@@ -311,6 +312,35 @@ class Campaigns {
|
|
|
311
312
|
list(params = {}) {
|
|
312
313
|
return this.client.get('/campaigns', params);
|
|
313
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* @see https://api.voucherify.io/v1/campaigns/{campaignId}/importCSV
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
async importVouchersCSV(campaignId, filePath) {
|
|
321
|
+
assert(environment().startsWith('Node'), `Method "client.campaigns.importVouchersCSV(campaignId, filePath)" is only for Node environment`);
|
|
322
|
+
const fs = (await import('fs')).default;
|
|
323
|
+
const fileStream = fs.createReadStream(filePath);
|
|
324
|
+
const form = new FormData();
|
|
325
|
+
form.append('file', fileStream);
|
|
326
|
+
return this.client.post(`/campaigns/${campaignId}/importCSV`, form);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* @see https://docs.voucherify.io/reference/enable-campaign
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
enable(campaignId) {
|
|
334
|
+
return this.client.post(`/campaigns/${encode(campaignId)}/enable`, {});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* @see https://docs.voucherify.io/reference/disable-campaign
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
disable(campaignId) {
|
|
342
|
+
return this.client.post(`/campaigns/${encode(campaignId)}/disable`, {});
|
|
343
|
+
}
|
|
314
344
|
|
|
315
345
|
}
|
|
316
346
|
|
|
@@ -535,6 +565,19 @@ class Vouchers {
|
|
|
535
565
|
releaseValidationSession(code, sessionKey) {
|
|
536
566
|
return this.client.delete(`/vouchers/${encode(code)}/sessions/${encode(sessionKey)}`);
|
|
537
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* @see https://docs.voucherify.io/reference/import-vouchers-using-csv
|
|
570
|
+
*/
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
async importCSV(filePath) {
|
|
574
|
+
assert(environment().startsWith('Node'), `Method "client.vouchers.importCSV(filePath)" is only for Node environment`);
|
|
575
|
+
const fs = (await import('fs')).default;
|
|
576
|
+
const fileStream = fs.createReadStream(filePath);
|
|
577
|
+
const form = new FormData();
|
|
578
|
+
form.append('file', fileStream);
|
|
579
|
+
return this.client.post('/vouchers/importCSV', form);
|
|
580
|
+
}
|
|
538
581
|
|
|
539
582
|
}
|
|
540
583
|
|
|
@@ -826,6 +869,22 @@ class Customers {
|
|
|
826
869
|
const customerWithoutId = omit(customer, ['id']);
|
|
827
870
|
return this.client.put(`/customers/${encode(id)}`, customerWithoutId);
|
|
828
871
|
}
|
|
872
|
+
/**
|
|
873
|
+
* @see https://docs.voucherify.io/reference/update-customers-in-bulk
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
updateInBulk(customers) {
|
|
878
|
+
return this.client.post(`/customers/bulk/async`, customers);
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* @see https://docs.voucherify.io/reference/update-customers-metadata-in-bulk
|
|
882
|
+
*/
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
updateMetadataInBulk(sourceIdsAndMetadata) {
|
|
886
|
+
return this.client.post(`/customers/metadata/async`, sourceIdsAndMetadata);
|
|
887
|
+
}
|
|
829
888
|
/**
|
|
830
889
|
* @see https://docs.voucherify.io/reference/delete-customer
|
|
831
890
|
*/
|
|
@@ -834,6 +893,14 @@ class Customers {
|
|
|
834
893
|
delete(customerId) {
|
|
835
894
|
return this.client.delete(`/customers/${encode(customerId)}`);
|
|
836
895
|
}
|
|
896
|
+
/**
|
|
897
|
+
* @see https://docs.voucherify.io/reference/delete-customer-permanently
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
deletePermanently(customerId) {
|
|
902
|
+
return this.client.post(`/customers/${encode(customerId)}/permanent-deletion`, {});
|
|
903
|
+
}
|
|
837
904
|
/**
|
|
838
905
|
* @see https://docs.voucherify.io/reference/update-customers-consents
|
|
839
906
|
*/
|
|
@@ -850,6 +917,19 @@ class Customers {
|
|
|
850
917
|
listActivities(customerId, params) {
|
|
851
918
|
return this.client.get(`/customers/${encode(customerId)}/activities`, params);
|
|
852
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* @see https://docs.voucherify.io/reference/import-customers-using-csv
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
async importCSV(filePath) {
|
|
926
|
+
assert(environment().startsWith('Node'), `Method "client.customers.importCSV(filePath)" is only for Node environment`);
|
|
927
|
+
const fs = (await import('fs')).default;
|
|
928
|
+
const fileStream = fs.createReadStream(filePath);
|
|
929
|
+
const form = new FormData();
|
|
930
|
+
form.append('file', fileStream);
|
|
931
|
+
return this.client.post(`/customers/importCSV`, form);
|
|
932
|
+
}
|
|
853
933
|
|
|
854
934
|
}
|
|
855
935
|
|
|
@@ -1018,6 +1098,32 @@ class Products {
|
|
|
1018
1098
|
listSkus(productId) {
|
|
1019
1099
|
return this.client.get(`/products/${encode(productId)}/skus`);
|
|
1020
1100
|
}
|
|
1101
|
+
/**
|
|
1102
|
+
* @see https://docs.voucherify.io/reference/import-skus-using-csv
|
|
1103
|
+
*/
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
async importSkusCSV(filePath) {
|
|
1107
|
+
assert(environment().startsWith('Node'), `Method "client.products.importSkusCSV(filePath)" is only for Node environment`);
|
|
1108
|
+
const fs = (await import('fs')).default;
|
|
1109
|
+
const fileStream = fs.createReadStream(filePath);
|
|
1110
|
+
const form = new FormData();
|
|
1111
|
+
form.append('file', fileStream);
|
|
1112
|
+
return this.client.post(`/skus/importCSV`, form);
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* @see https://docs.voucherify.io/reference/import-products-using-csv
|
|
1116
|
+
*/
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
async importCSV(filePath) {
|
|
1120
|
+
assert(environment().startsWith('Node'), `Method "client.products.importCSV(filePath)" is only for Node environment`);
|
|
1121
|
+
const fs = (await import('fs')).default;
|
|
1122
|
+
const fileStream = fs.createReadStream(filePath);
|
|
1123
|
+
const form = new FormData();
|
|
1124
|
+
form.append('file', fileStream);
|
|
1125
|
+
return this.client.post(`/products/importCSV`, form);
|
|
1126
|
+
}
|
|
1021
1127
|
|
|
1022
1128
|
}
|
|
1023
1129
|
|
|
@@ -1206,6 +1312,30 @@ class Loyalties {
|
|
|
1206
1312
|
deleteEarningRule(campaignId, earningRuleId) {
|
|
1207
1313
|
return this.client.delete(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}`);
|
|
1208
1314
|
}
|
|
1315
|
+
/**
|
|
1316
|
+
* @see https://docs.voucherify.io/reference/get-earning-rule
|
|
1317
|
+
*/
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
getEarningRule(campaignId, earningRuleId) {
|
|
1321
|
+
return this.client.get(`/loyalties/${encode(campaignId)}/earning-rules/${encode(earningRuleId)}`);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* @see https://docs.voucherify.io/reference/enable-earning-rule
|
|
1325
|
+
*/
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
enableEarningRule(campaignId, earningRuleId) {
|
|
1329
|
+
return this.client.post(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/enable`, {});
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* @see https://docs.voucherify.io/reference/disable-earning-rule
|
|
1333
|
+
*/
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
disableEarningRule(campaignId, earningRuleId) {
|
|
1337
|
+
return this.client.post(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/disable`, {});
|
|
1338
|
+
}
|
|
1209
1339
|
/**
|
|
1210
1340
|
* @see https://docs.voucherify.io/reference/list-members
|
|
1211
1341
|
*/
|
|
@@ -1434,6 +1564,54 @@ class MetadataSchemas {
|
|
|
1434
1564
|
|
|
1435
1565
|
}
|
|
1436
1566
|
|
|
1567
|
+
class Categories {
|
|
1568
|
+
constructor(client) {
|
|
1569
|
+
this.client = void 0;
|
|
1570
|
+
this.client = client;
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* @see https://docs.voucherify.io/reference/list-categories
|
|
1574
|
+
*/
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
list() {
|
|
1578
|
+
return this.client.get('/categories');
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* @see https://docs.voucherify.io/reference/create-category
|
|
1582
|
+
*/
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
create(createCategory) {
|
|
1586
|
+
return this.client.post('/categories', createCategory);
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* @see https://docs.voucherify.io/reference/get-category
|
|
1590
|
+
*/
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
get(categoryId) {
|
|
1594
|
+
return this.client.get(`/categories/${encode(categoryId)}`);
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* @see https://docs.voucherify.io/reference/delete-category
|
|
1598
|
+
*/
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
delete(categoryId) {
|
|
1602
|
+
return this.client.delete(`/categories/${encode(categoryId)}`);
|
|
1603
|
+
}
|
|
1604
|
+
/**
|
|
1605
|
+
* @see https://docs.voucherify.io/reference/update-category
|
|
1606
|
+
*/
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
update(categoryId, updateCategory) {
|
|
1610
|
+
return this.client.put(`/categories/${encode(categoryId)}`, updateCategory);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1437
1615
|
// apiLimitsHandler: ApiLimitsHandler
|
|
1438
1616
|
// campaigns: Campaigns
|
|
1439
1617
|
// consents: Consents
|
|
@@ -1464,7 +1642,7 @@ function VoucherifyServerSide(options) {
|
|
|
1464
1642
|
let headers = {
|
|
1465
1643
|
'X-App-Id': options.applicationId,
|
|
1466
1644
|
'X-App-Token': options.secretKey,
|
|
1467
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.
|
|
1645
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.4.0"}`,
|
|
1468
1646
|
'Content-Type': 'application/json'
|
|
1469
1647
|
};
|
|
1470
1648
|
|
|
@@ -1497,6 +1675,7 @@ function VoucherifyServerSide(options) {
|
|
|
1497
1675
|
const balance = new Balance(client);
|
|
1498
1676
|
const vouchers = new Vouchers(client, balance);
|
|
1499
1677
|
const campaigns = new Campaigns(client);
|
|
1678
|
+
const categories = new Categories(client);
|
|
1500
1679
|
const exportsNamespace = new Exports(client);
|
|
1501
1680
|
const events = new Events(client);
|
|
1502
1681
|
const distributions = new Distributions(client, exportsNamespace);
|
|
@@ -1517,6 +1696,7 @@ function VoucherifyServerSide(options) {
|
|
|
1517
1696
|
return {
|
|
1518
1697
|
vouchers,
|
|
1519
1698
|
campaigns,
|
|
1699
|
+
categories,
|
|
1520
1700
|
distributions,
|
|
1521
1701
|
validations,
|
|
1522
1702
|
redemptions,
|
|
@@ -1715,7 +1895,7 @@ function VoucherifyClientSide(options) {
|
|
|
1715
1895
|
let headers = {
|
|
1716
1896
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
1717
1897
|
'X-Client-Token': options.clientSecretKey,
|
|
1718
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.
|
|
1898
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.4.0"}`
|
|
1719
1899
|
};
|
|
1720
1900
|
|
|
1721
1901
|
if (environment().startsWith('Node')) {
|