@voucherify/sdk 2.1.6 → 2.1.7
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 +8 -0
- package/README.md +19 -0
- package/dist/RequestController.d.ts +3 -1
- package/dist/VoucherifyClientSide.d.ts +6 -0
- package/dist/VoucherifyError.d.ts +12 -1
- package/dist/VoucherifyServerSide.d.ts +6 -0
- package/dist/voucherifysdk.esm.js +34 -10
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +34 -10
- 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 +1 -1
|
@@ -18,13 +18,32 @@
|
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
20
|
class VoucherifyError extends Error {
|
|
21
|
-
constructor(statusCode, body) {
|
|
21
|
+
constructor(statusCode, body, axiosError) {
|
|
22
22
|
var _body, _body2;
|
|
23
23
|
|
|
24
24
|
body = (_body = body) != null ? _body : {};
|
|
25
25
|
const message = ((_body2 = body) == null ? void 0 : _body2.message) || generateMessage(body, statusCode);
|
|
26
26
|
super(message);
|
|
27
|
-
|
|
27
|
+
this.code = void 0;
|
|
28
|
+
this.key = void 0;
|
|
29
|
+
this.details = void 0;
|
|
30
|
+
this.request_id = void 0;
|
|
31
|
+
this.resource_id = void 0;
|
|
32
|
+
this.resource_type = void 0;
|
|
33
|
+
this.related_object_ids = void 0;
|
|
34
|
+
this.related_object_type = void 0;
|
|
35
|
+
this.related_object_total = void 0;
|
|
36
|
+
this.cause = void 0;
|
|
37
|
+
this.code = body.code;
|
|
38
|
+
this.key = body.key;
|
|
39
|
+
this.details = body.details;
|
|
40
|
+
this.request_id = body.request_id;
|
|
41
|
+
this.resource_id = body.resource_id;
|
|
42
|
+
this.resource_type = body.resource_type;
|
|
43
|
+
this.related_object_ids = body.related_object_ids;
|
|
44
|
+
this.related_object_type = body.related_object_type;
|
|
45
|
+
this.related_object_total = body.related_object_total;
|
|
46
|
+
this.cause = axiosError;
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
}
|
|
@@ -42,7 +61,8 @@
|
|
|
42
61
|
constructor({
|
|
43
62
|
basePath,
|
|
44
63
|
baseURL,
|
|
45
|
-
headers
|
|
64
|
+
headers,
|
|
65
|
+
exposeErrorCause
|
|
46
66
|
}) {
|
|
47
67
|
this.baseURL = void 0;
|
|
48
68
|
this.basePath = void 0;
|
|
@@ -50,9 +70,11 @@
|
|
|
50
70
|
this.request = void 0;
|
|
51
71
|
this.lastResponseHeaders = void 0;
|
|
52
72
|
this.isLastResponseHeadersSet = void 0;
|
|
73
|
+
this.exposeErrorCause = void 0;
|
|
53
74
|
this.basePath = basePath;
|
|
54
75
|
this.baseURL = baseURL;
|
|
55
76
|
this.headers = headers;
|
|
77
|
+
this.exposeErrorCause = exposeErrorCause;
|
|
56
78
|
this.lastResponseHeaders = {};
|
|
57
79
|
this.isLastResponseHeadersSet = false;
|
|
58
80
|
this.request = axios.create({
|
|
@@ -67,7 +89,7 @@
|
|
|
67
89
|
* Handle any HTTP response error (status code outside of 2xx) as a VoucherifyError
|
|
68
90
|
*/
|
|
69
91
|
if (error != null && (_error$response = error.response) != null && _error$response.status) {
|
|
70
|
-
return Promise.reject(new VoucherifyError(error.response.status, error.response.data));
|
|
92
|
+
return Promise.reject(new VoucherifyError(error.response.status, error.response.data, this.exposeErrorCause === true ? error : undefined));
|
|
71
93
|
}
|
|
72
94
|
|
|
73
95
|
return Promise.reject(error);
|
|
@@ -1421,7 +1443,7 @@
|
|
|
1421
1443
|
// }
|
|
1422
1444
|
|
|
1423
1445
|
function VoucherifyServerSide(options) {
|
|
1424
|
-
var _options$apiUrl;
|
|
1446
|
+
var _options$apiUrl, _options$exposeErrorC;
|
|
1425
1447
|
|
|
1426
1448
|
assert(isObject(options), 'VoucherifyServerSide: the "options" argument must be an object');
|
|
1427
1449
|
assert(isString(options.applicationId), 'VoucherifyServerSide: "options.applicationId" is required');
|
|
@@ -1431,7 +1453,7 @@
|
|
|
1431
1453
|
let headers = {
|
|
1432
1454
|
'X-App-Id': options.applicationId,
|
|
1433
1455
|
'X-App-Token': options.secretKey,
|
|
1434
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.1.
|
|
1456
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.1.7"}`,
|
|
1435
1457
|
'Content-Type': 'application/json'
|
|
1436
1458
|
};
|
|
1437
1459
|
|
|
@@ -1456,7 +1478,8 @@
|
|
|
1456
1478
|
const client = new RequestController({
|
|
1457
1479
|
basePath: 'v1',
|
|
1458
1480
|
baseURL: (_options$apiUrl = options.apiUrl) != null ? _options$apiUrl : 'https://api.voucherify.io',
|
|
1459
|
-
headers
|
|
1481
|
+
headers,
|
|
1482
|
+
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false
|
|
1460
1483
|
});
|
|
1461
1484
|
const asyncActions = new AsyncActions(client);
|
|
1462
1485
|
const balance = new Balance(client);
|
|
@@ -1670,7 +1693,7 @@
|
|
|
1670
1693
|
}
|
|
1671
1694
|
|
|
1672
1695
|
function VoucherifyClientSide(options) {
|
|
1673
|
-
var _options$apiUrl;
|
|
1696
|
+
var _options$apiUrl, _options$exposeErrorC;
|
|
1674
1697
|
|
|
1675
1698
|
assert(isObject(options), 'VoucherifyCustomer: expected "options" argument to be an object');
|
|
1676
1699
|
assert(isString(options.clientApplicationId), 'VoucherifyCustomer: "options.clientApplicationId" is required');
|
|
@@ -1680,7 +1703,7 @@
|
|
|
1680
1703
|
let headers = {
|
|
1681
1704
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
1682
1705
|
'X-Client-Token': options.clientSecretKey,
|
|
1683
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.1.
|
|
1706
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.1.7"}`
|
|
1684
1707
|
};
|
|
1685
1708
|
|
|
1686
1709
|
if (environment().startsWith('Node')) {
|
|
@@ -1695,7 +1718,8 @@
|
|
|
1695
1718
|
const client = new RequestController({
|
|
1696
1719
|
basePath: 'client/v1',
|
|
1697
1720
|
baseURL: (_options$apiUrl = options.apiUrl) != null ? _options$apiUrl : 'https://api.voucherify.io',
|
|
1698
|
-
headers
|
|
1721
|
+
headers,
|
|
1722
|
+
exposeErrorCause: (_options$exposeErrorC = options.exposeErrorCause) != null ? _options$exposeErrorC : false
|
|
1699
1723
|
});
|
|
1700
1724
|
return new ClientSide(client, options.trackingId);
|
|
1701
1725
|
}
|