@voucherify/sdk 2.6.0 → 2.7.1
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 +19 -0
- package/README.md +21 -0
- package/dist/ClientSide.d.ts +5 -0
- package/dist/Qualifications.d.ts +10 -0
- package/dist/VoucherifyError.d.ts +3 -0
- package/dist/VoucherifyServerSide.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/ApplicableTo.d.ts +15 -0
- package/dist/types/Customers.d.ts +88 -3
- package/dist/types/DiscountVoucher.d.ts +44 -2
- package/dist/types/Orders.d.ts +110 -1
- package/dist/types/Qualifications.d.ts +86 -0
- package/dist/types/ValidationRules.d.ts +1 -0
- package/dist/types/Vouchers.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/voucherifysdk.esm.js +57 -8
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +57 -8
- 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 +2 -2
|
@@ -30,6 +30,7 @@ class VoucherifyError extends Error {
|
|
|
30
30
|
this.related_object_ids = void 0;
|
|
31
31
|
this.related_object_type = void 0;
|
|
32
32
|
this.related_object_total = void 0;
|
|
33
|
+
this.error = void 0;
|
|
33
34
|
this.cause = void 0;
|
|
34
35
|
this.code = body.code;
|
|
35
36
|
this.key = body.key;
|
|
@@ -40,6 +41,7 @@ class VoucherifyError extends Error {
|
|
|
40
41
|
this.related_object_ids = body.related_object_ids;
|
|
41
42
|
this.related_object_type = body.related_object_type;
|
|
42
43
|
this.related_object_total = body.related_object_total;
|
|
44
|
+
this.error = body.error;
|
|
43
45
|
this.cause = axiosError;
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -105,7 +107,13 @@ class RequestController {
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
setLastResponseHeaders(headers) {
|
|
108
|
-
|
|
110
|
+
const result = {};
|
|
111
|
+
|
|
112
|
+
for (const key in headers) {
|
|
113
|
+
result[key] = String(headers[key]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.lastResponseHeaders = result;
|
|
109
117
|
this.isLastResponseHeadersSet = true;
|
|
110
118
|
}
|
|
111
119
|
|
|
@@ -323,7 +331,10 @@ class Campaigns {
|
|
|
323
331
|
const fileStream = fs.createReadStream(filePath);
|
|
324
332
|
const form = new FormData();
|
|
325
333
|
form.append('file', fileStream);
|
|
326
|
-
|
|
334
|
+
const headers = {
|
|
335
|
+
'Content-Type': 'multipart/form-data'
|
|
336
|
+
};
|
|
337
|
+
return this.client.post(`/campaigns/${campaignId}/importCSV`, form, undefined, headers);
|
|
327
338
|
}
|
|
328
339
|
/**
|
|
329
340
|
* @see https://docs.voucherify.io/reference/enable-campaign
|
|
@@ -584,7 +595,10 @@ class Vouchers {
|
|
|
584
595
|
const fileStream = fs.createReadStream(filePath);
|
|
585
596
|
const form = new FormData();
|
|
586
597
|
form.append('file', fileStream);
|
|
587
|
-
|
|
598
|
+
const headers = {
|
|
599
|
+
'Content-Type': 'multipart/form-data'
|
|
600
|
+
};
|
|
601
|
+
return this.client.post('/vouchers/importCSV', form, undefined, headers);
|
|
588
602
|
}
|
|
589
603
|
/**
|
|
590
604
|
* @see https://docs.voucherify.io/reference/list-voucher-transactions
|
|
@@ -954,7 +968,10 @@ class Customers {
|
|
|
954
968
|
const fileStream = fs.createReadStream(filePath);
|
|
955
969
|
const form = new FormData();
|
|
956
970
|
form.append('file', fileStream);
|
|
957
|
-
|
|
971
|
+
const headers = {
|
|
972
|
+
'Content-Type': 'multipart/form-data'
|
|
973
|
+
};
|
|
974
|
+
return this.client.post(`/customers/importCSV`, form, undefined, headers);
|
|
958
975
|
}
|
|
959
976
|
|
|
960
977
|
}
|
|
@@ -1135,7 +1152,10 @@ class Products {
|
|
|
1135
1152
|
const fileStream = fs.createReadStream(filePath);
|
|
1136
1153
|
const form = new FormData();
|
|
1137
1154
|
form.append('file', fileStream);
|
|
1138
|
-
|
|
1155
|
+
const headers = {
|
|
1156
|
+
'Content-Type': 'multipart/form-data'
|
|
1157
|
+
};
|
|
1158
|
+
return this.client.post(`/skus/importCSV`, form, undefined, headers);
|
|
1139
1159
|
}
|
|
1140
1160
|
/**
|
|
1141
1161
|
* @see https://docs.voucherify.io/reference/import-products-using-csv
|
|
@@ -1148,7 +1168,10 @@ class Products {
|
|
|
1148
1168
|
const fileStream = fs.createReadStream(filePath);
|
|
1149
1169
|
const form = new FormData();
|
|
1150
1170
|
form.append('file', fileStream);
|
|
1151
|
-
|
|
1171
|
+
const headers = {
|
|
1172
|
+
'Content-Type': 'multipart/form-data'
|
|
1173
|
+
};
|
|
1174
|
+
return this.client.post(`/products/importCSV`, form, undefined, headers);
|
|
1152
1175
|
}
|
|
1153
1176
|
|
|
1154
1177
|
}
|
|
@@ -1875,6 +1898,22 @@ class ProductCollections {
|
|
|
1875
1898
|
|
|
1876
1899
|
}
|
|
1877
1900
|
|
|
1901
|
+
class Qualifications {
|
|
1902
|
+
constructor(client) {
|
|
1903
|
+
this.client = void 0;
|
|
1904
|
+
this.client = client;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
1908
|
+
*/
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
checkEligibility(body) {
|
|
1912
|
+
return this.client.post('/qualifications', body);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1878
1917
|
// apiLimitsHandler: ApiLimitsHandler
|
|
1879
1918
|
// campaigns: Campaigns
|
|
1880
1919
|
// consents: Consents
|
|
@@ -1905,7 +1944,7 @@ function VoucherifyServerSide(options) {
|
|
|
1905
1944
|
let headers = {
|
|
1906
1945
|
'X-App-Id': options.applicationId,
|
|
1907
1946
|
'X-App-Token': options.secretKey,
|
|
1908
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.
|
|
1947
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.1"}`,
|
|
1909
1948
|
'Content-Type': 'application/json'
|
|
1910
1949
|
};
|
|
1911
1950
|
|
|
@@ -1947,6 +1986,7 @@ function VoucherifyServerSide(options) {
|
|
|
1947
1986
|
const promotions = new Promotions(client, promotionTiers, promotionStack);
|
|
1948
1987
|
const validations = new Validations(client, promotions);
|
|
1949
1988
|
const redemptions = new Redemptions(client);
|
|
1989
|
+
const qualifications = new Qualifications(client);
|
|
1950
1990
|
const customers = new Customers(client);
|
|
1951
1991
|
const consents = new Consents(client);
|
|
1952
1992
|
const orders = new Orders(client);
|
|
@@ -1971,6 +2011,7 @@ function VoucherifyServerSide(options) {
|
|
|
1971
2011
|
orders,
|
|
1972
2012
|
products,
|
|
1973
2013
|
productCollections,
|
|
2014
|
+
qualifications,
|
|
1974
2015
|
rewards,
|
|
1975
2016
|
loyalties,
|
|
1976
2017
|
segments,
|
|
@@ -2147,6 +2188,14 @@ class ClientSide {
|
|
|
2147
2188
|
redeemStackable(params) {
|
|
2148
2189
|
return this.client.post(`/redemptions`, params);
|
|
2149
2190
|
}
|
|
2191
|
+
/**
|
|
2192
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
|
|
2196
|
+
qualifications(body) {
|
|
2197
|
+
return this.client.post('/qualifications', body);
|
|
2198
|
+
}
|
|
2150
2199
|
|
|
2151
2200
|
}
|
|
2152
2201
|
|
|
@@ -2161,7 +2210,7 @@ function VoucherifyClientSide(options) {
|
|
|
2161
2210
|
let headers = {
|
|
2162
2211
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
2163
2212
|
'X-Client-Token': options.clientSecretKey,
|
|
2164
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.
|
|
2213
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.1"}`
|
|
2165
2214
|
};
|
|
2166
2215
|
|
|
2167
2216
|
if (environment().startsWith('Node')) {
|