@paddle/paddle-node-sdk 3.2.0 → 3.3.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/README.md +1 -1
- package/dist/cjs/entities/index.js +1 -0
- package/dist/cjs/entities/shared/payout-totals-adjustment.js +2 -0
- package/dist/cjs/entities/shared/total-adjustments.js +2 -0
- package/dist/cjs/entities/shared/transaction-payout-totals-adjusted.js +2 -0
- package/dist/cjs/entities/shared/transaction-totals-adjusted.js +2 -0
- package/dist/cjs/internal/api/client.js +10 -4
- package/dist/cjs/internal/base/base-resource.js +4 -1
- package/dist/cjs/internal/base/collection.js +4 -1
- package/dist/cjs/internal/errors/generic.js +3 -1
- package/dist/cjs/internal/types/response.js +2 -0
- package/dist/cjs/notifications/entities/shared/payout-totals-adjustment-notification.js +2 -0
- package/dist/cjs/notifications/entities/shared/total-adjustments-notification.js +2 -0
- package/dist/cjs/notifications/entities/shared/transaction-payout-totals-adjusted-notification.js +2 -0
- package/dist/cjs/notifications/entities/shared/transaction-totals-adjusted-notification.js +2 -0
- package/dist/cjs/resources/transactions/operations/index.js +1 -0
- package/dist/cjs/resources/transactions/operations/non-catalog-discount.js +2 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/entities/index.js +1 -0
- package/dist/esm/entities/shared/payout-totals-adjustment.js +2 -0
- package/dist/esm/entities/shared/total-adjustments.js +2 -0
- package/dist/esm/entities/shared/transaction-payout-totals-adjusted.js +2 -0
- package/dist/esm/entities/shared/transaction-totals-adjusted.js +2 -0
- package/dist/esm/internal/api/client.js +10 -4
- package/dist/esm/internal/base/base-resource.js +4 -1
- package/dist/esm/internal/base/collection.js +4 -1
- package/dist/esm/internal/errors/generic.js +3 -1
- package/dist/esm/internal/types/response.js +1 -1
- package/dist/esm/notifications/entities/shared/payout-totals-adjustment-notification.js +2 -0
- package/dist/esm/notifications/entities/shared/total-adjustments-notification.js +2 -0
- package/dist/esm/notifications/entities/shared/transaction-payout-totals-adjusted-notification.js +2 -0
- package/dist/esm/notifications/entities/shared/transaction-totals-adjusted-notification.js +2 -0
- package/dist/esm/resources/transactions/operations/index.js +1 -0
- package/dist/esm/resources/transactions/operations/non-catalog-discount.js +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/entities/index.d.ts +2 -1
- package/dist/types/entities/shared/payout-totals-adjustment.d.ts +1 -0
- package/dist/types/entities/shared/total-adjustments.d.ts +1 -0
- package/dist/types/entities/shared/transaction-payout-totals-adjusted.d.ts +1 -0
- package/dist/types/entities/shared/transaction-totals-adjusted.d.ts +1 -0
- package/dist/types/enums/payment-method/type.d.ts +1 -1
- package/dist/types/enums/shared/available-payment-methods.d.ts +1 -1
- package/dist/types/enums/shared/payment-type.d.ts +1 -1
- package/dist/types/internal/errors/generic.d.ts +2 -1
- package/dist/types/internal/types/response.d.ts +4 -0
- package/dist/types/notifications/entities/shared/payout-totals-adjustment-notification.d.ts +1 -0
- package/dist/types/notifications/entities/shared/total-adjustments-notification.d.ts +1 -0
- package/dist/types/notifications/entities/shared/transaction-payout-totals-adjusted-notification.d.ts +1 -0
- package/dist/types/notifications/entities/shared/transaction-totals-adjusted-notification.d.ts +1 -0
- package/dist/types/notifications/types/shared/payout-totals-adjustment-notification-response.d.ts +1 -0
- package/dist/types/notifications/types/shared/total-adjustments-notification-response.d.ts +1 -0
- package/dist/types/notifications/types/shared/transaction-payout-totals-adjusted-notification-response.d.ts +1 -0
- package/dist/types/notifications/types/shared/transaction-totals-adjusted-notification-response.d.ts +1 -0
- package/dist/types/resources/transactions/operations/create-transaction-request-body.d.ts +2 -0
- package/dist/types/resources/transactions/operations/index.d.ts +1 -0
- package/dist/types/resources/transactions/operations/non-catalog-discount.d.ts +11 -0
- package/dist/types/resources/transactions/operations/transaction-preview-request-body.d.ts +2 -0
- package/dist/types/resources/transactions/operations/update-transaction-request-body.d.ts +2 -0
- package/dist/types/types/shared/custom-data.d.ts +1 -1
- package/dist/types/types/shared/payout-totals-adjustment-response.d.ts +1 -0
- package/dist/types/types/shared/total-adjustments-response.d.ts +1 -0
- package/dist/types/types/shared/transaction-payout-totals-adjusted-response.d.ts +1 -0
- package/dist/types/types/shared/transaction-totals-adjusted-response.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2091,7 +2091,7 @@ console.log('Archived Business:', archivedBusiness)
|
|
|
2091
2091
|
|
|
2092
2092
|
### Error Handling
|
|
2093
2093
|
|
|
2094
|
-
If a request fails, Paddle returns an `error` object that contains the same information as [errors returned by the API](https://developer.paddle.com/api-reference/about/errors?utm_source=dx&utm_medium=paddle-node-sdk). You can use the `code` attribute to search an error in [the error reference](https://developer.paddle.com/errors/overview?utm_source=dx&utm_medium=paddle-node-sdk) and to handle the error in your app. Validation errors also return an array of `errors` that tell you which fields failed validation.
|
|
2094
|
+
If a request fails, Paddle returns an `error` object that contains the same information as [errors returned by the API](https://developer.paddle.com/api-reference/about/errors?utm_source=dx&utm_medium=paddle-node-sdk). You can use the `code` attribute to search an error in [the error reference](https://developer.paddle.com/errors/overview?utm_source=dx&utm_medium=paddle-node-sdk) and to handle the error in your app. Validation errors also return an array of `errors` that tell you which fields failed validation. The `retryAfter` property will be set for `too_many_requests` errors.
|
|
2095
2095
|
|
|
2096
2096
|
This example shows how to handle an error with the code `conflict`:
|
|
2097
2097
|
|
|
@@ -29,6 +29,7 @@ __exportStar(require("./discount-group/index.js"), exports);
|
|
|
29
29
|
__exportStar(require("./events/index.js"), exports);
|
|
30
30
|
__exportStar(require("./payment-method/index.js"), exports);
|
|
31
31
|
__exportStar(require("./payout/index.js"), exports);
|
|
32
|
+
__exportStar(require("./pricing-preview/index.js"), exports);
|
|
32
33
|
__exportStar(require("./event-types/index.js"), exports);
|
|
33
34
|
__exportStar(require("./notification-settings/index.js"), exports);
|
|
34
35
|
__exportStar(require("./notifications/index.js"), exports);
|
|
@@ -10,6 +10,7 @@ class PayoutTotalsAdjustment {
|
|
|
10
10
|
chargebackFee;
|
|
11
11
|
earnings;
|
|
12
12
|
currencyCode;
|
|
13
|
+
retainedFee;
|
|
13
14
|
constructor(payoutTotalsAdjustment) {
|
|
14
15
|
this.subtotal = payoutTotalsAdjustment.subtotal;
|
|
15
16
|
this.tax = payoutTotalsAdjustment.tax;
|
|
@@ -20,6 +21,7 @@ class PayoutTotalsAdjustment {
|
|
|
20
21
|
: null;
|
|
21
22
|
this.earnings = payoutTotalsAdjustment.earnings;
|
|
22
23
|
this.currencyCode = payoutTotalsAdjustment.currency_code;
|
|
24
|
+
this.retainedFee = payoutTotalsAdjustment.retained_fee;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
exports.PayoutTotalsAdjustment = PayoutTotalsAdjustment;
|
|
@@ -8,6 +8,7 @@ class TotalAdjustments {
|
|
|
8
8
|
fee;
|
|
9
9
|
earnings;
|
|
10
10
|
currencyCode;
|
|
11
|
+
retainedFee;
|
|
11
12
|
constructor(totalAdjustments) {
|
|
12
13
|
this.subtotal = totalAdjustments.subtotal;
|
|
13
14
|
this.tax = totalAdjustments.tax;
|
|
@@ -15,6 +16,7 @@ class TotalAdjustments {
|
|
|
15
16
|
this.fee = totalAdjustments.fee;
|
|
16
17
|
this.earnings = totalAdjustments.earnings;
|
|
17
18
|
this.currencyCode = totalAdjustments.currency_code;
|
|
19
|
+
this.retainedFee = totalAdjustments.retained_fee;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
exports.TotalAdjustments = TotalAdjustments;
|
|
@@ -11,6 +11,7 @@ class TransactionPayoutTotalsAdjusted {
|
|
|
11
11
|
earnings;
|
|
12
12
|
currencyCode;
|
|
13
13
|
exchangeRate;
|
|
14
|
+
retainedFee;
|
|
14
15
|
constructor(transactionPayoutTotalsAdjusted) {
|
|
15
16
|
this.subtotal = transactionPayoutTotalsAdjusted.subtotal;
|
|
16
17
|
this.tax = transactionPayoutTotalsAdjusted.tax;
|
|
@@ -22,6 +23,7 @@ class TransactionPayoutTotalsAdjusted {
|
|
|
22
23
|
this.earnings = transactionPayoutTotalsAdjusted.earnings;
|
|
23
24
|
this.currencyCode = transactionPayoutTotalsAdjusted.currency_code;
|
|
24
25
|
this.exchangeRate = transactionPayoutTotalsAdjusted.exchange_rate;
|
|
26
|
+
this.retainedFee = transactionPayoutTotalsAdjusted.retained_fee;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
exports.TransactionPayoutTotalsAdjusted = TransactionPayoutTotalsAdjusted;
|
|
@@ -9,6 +9,7 @@ class TransactionTotalsAdjusted {
|
|
|
9
9
|
fee;
|
|
10
10
|
earnings;
|
|
11
11
|
currencyCode;
|
|
12
|
+
retainedFee;
|
|
12
13
|
constructor(transactionTotalsAdjusted) {
|
|
13
14
|
this.subtotal = transactionTotalsAdjusted.subtotal;
|
|
14
15
|
this.tax = transactionTotalsAdjusted.tax;
|
|
@@ -17,6 +18,7 @@ class TransactionTotalsAdjusted {
|
|
|
17
18
|
this.fee = transactionTotalsAdjusted.fee ? transactionTotalsAdjusted.fee : null;
|
|
18
19
|
this.earnings = transactionTotalsAdjusted.earnings ? transactionTotalsAdjusted.earnings : null;
|
|
19
20
|
this.currencyCode = transactionTotalsAdjusted.currency_code;
|
|
21
|
+
this.retainedFee = transactionTotalsAdjusted.retained_fee;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.TransactionTotalsAdjusted = TransactionTotalsAdjusted;
|
|
@@ -8,6 +8,7 @@ const log_level_js_1 = require("./log-level.js");
|
|
|
8
8
|
const runtime_provider_js_1 = require("../providers/runtime-provider.js");
|
|
9
9
|
const version_js_1 = require("../../version.js");
|
|
10
10
|
const case_helpers_js_1 = require("./case-helpers.js");
|
|
11
|
+
const response_js_1 = require("../types/response.js");
|
|
11
12
|
class Client {
|
|
12
13
|
apiKey;
|
|
13
14
|
options;
|
|
@@ -51,7 +52,7 @@ class Client {
|
|
|
51
52
|
headers,
|
|
52
53
|
});
|
|
53
54
|
logger_js_1.Logger.logResponse('GET', logUrl, headers, rawResponse);
|
|
54
|
-
return rawResponse.json();
|
|
55
|
+
return { ...(await rawResponse.json()), [response_js_1.rawResponse]: rawResponse };
|
|
55
56
|
}
|
|
56
57
|
async post(url, requestBody) {
|
|
57
58
|
const logUrl = url.split('?')[0];
|
|
@@ -63,7 +64,7 @@ class Client {
|
|
|
63
64
|
headers,
|
|
64
65
|
});
|
|
65
66
|
logger_js_1.Logger.logResponse('POST', logUrl, headers, rawResponse);
|
|
66
|
-
return rawResponse.json();
|
|
67
|
+
return { ...(await rawResponse.json()), [response_js_1.rawResponse]: rawResponse };
|
|
67
68
|
}
|
|
68
69
|
async patch(url, requestBody) {
|
|
69
70
|
const logUrl = url.split('?')[0];
|
|
@@ -75,7 +76,7 @@ class Client {
|
|
|
75
76
|
headers,
|
|
76
77
|
});
|
|
77
78
|
logger_js_1.Logger.logResponse('PATCH', logUrl, headers, rawResponse);
|
|
78
|
-
return rawResponse.json();
|
|
79
|
+
return { ...(await rawResponse.json()), [response_js_1.rawResponse]: rawResponse };
|
|
79
80
|
}
|
|
80
81
|
async delete(url) {
|
|
81
82
|
const logUrl = url.split('?')[0];
|
|
@@ -86,7 +87,12 @@ class Client {
|
|
|
86
87
|
headers,
|
|
87
88
|
});
|
|
88
89
|
logger_js_1.Logger.logResponse('DELETE', logUrl, headers, rawResponse);
|
|
89
|
-
|
|
90
|
+
if (rawResponse.ok) {
|
|
91
|
+
return rawResponse;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return { ...(await rawResponse.json()), [response_js_1.rawResponse]: rawResponse };
|
|
95
|
+
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
98
|
exports.Client = Client;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseResource = void 0;
|
|
4
|
+
const response_js_1 = require("../types/response.js");
|
|
4
5
|
const generic_js_1 = require("../errors/generic.js");
|
|
5
6
|
class BaseResource {
|
|
6
7
|
client;
|
|
@@ -9,7 +10,9 @@ class BaseResource {
|
|
|
9
10
|
}
|
|
10
11
|
handleError(error) {
|
|
11
12
|
if (error.error) {
|
|
12
|
-
|
|
13
|
+
const retryAfterHeader = error[response_js_1.rawResponse]?.headers.get('Retry-After');
|
|
14
|
+
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : null;
|
|
15
|
+
throw new generic_js_1.ApiError(error.error, retryAfter);
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
handleResponse(response) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Collection = void 0;
|
|
4
|
+
const response_js_1 = require("../types/response.js");
|
|
4
5
|
const generic_js_1 = require("../errors/generic.js");
|
|
5
6
|
class Collection {
|
|
6
7
|
client;
|
|
@@ -25,7 +26,9 @@ class Collection {
|
|
|
25
26
|
const entityResponse = response;
|
|
26
27
|
const error = response;
|
|
27
28
|
if (error.error) {
|
|
28
|
-
|
|
29
|
+
const retryAfterHeader = error[response_js_1.rawResponse]?.headers.get('Retry-After');
|
|
30
|
+
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : null;
|
|
31
|
+
throw new generic_js_1.ApiError(error.error, retryAfter);
|
|
29
32
|
}
|
|
30
33
|
return entityResponse;
|
|
31
34
|
}
|
|
@@ -7,13 +7,15 @@ class ApiError extends Error {
|
|
|
7
7
|
detail;
|
|
8
8
|
documentationUrl;
|
|
9
9
|
errors;
|
|
10
|
-
|
|
10
|
+
retryAfter;
|
|
11
|
+
constructor(errorDetail, retryAfter) {
|
|
11
12
|
super(errorDetail.detail);
|
|
12
13
|
this.type = errorDetail.type;
|
|
13
14
|
this.code = errorDetail.code;
|
|
14
15
|
this.detail = errorDetail.detail;
|
|
15
16
|
this.documentationUrl = errorDetail.documentation_url;
|
|
16
17
|
this.errors = errorDetail.errors ? errorDetail.errors : null;
|
|
18
|
+
this.retryAfter = retryAfter;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
exports.ApiError = ApiError;
|
|
@@ -10,6 +10,7 @@ class PayoutTotalsAdjustmentNotification {
|
|
|
10
10
|
chargebackFee;
|
|
11
11
|
earnings;
|
|
12
12
|
currencyCode;
|
|
13
|
+
retainedFee;
|
|
13
14
|
constructor(payoutTotalsAdjustment) {
|
|
14
15
|
this.subtotal = payoutTotalsAdjustment.subtotal;
|
|
15
16
|
this.tax = payoutTotalsAdjustment.tax;
|
|
@@ -20,6 +21,7 @@ class PayoutTotalsAdjustmentNotification {
|
|
|
20
21
|
: null;
|
|
21
22
|
this.earnings = payoutTotalsAdjustment.earnings;
|
|
22
23
|
this.currencyCode = payoutTotalsAdjustment.currency_code;
|
|
24
|
+
this.retainedFee = payoutTotalsAdjustment.retained_fee;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
exports.PayoutTotalsAdjustmentNotification = PayoutTotalsAdjustmentNotification;
|
|
@@ -8,6 +8,7 @@ class TotalAdjustmentsNotification {
|
|
|
8
8
|
fee;
|
|
9
9
|
earnings;
|
|
10
10
|
currencyCode;
|
|
11
|
+
retainedFee;
|
|
11
12
|
constructor(totalAdjustments) {
|
|
12
13
|
this.subtotal = totalAdjustments.subtotal;
|
|
13
14
|
this.tax = totalAdjustments.tax;
|
|
@@ -15,6 +16,7 @@ class TotalAdjustmentsNotification {
|
|
|
15
16
|
this.fee = totalAdjustments.fee;
|
|
16
17
|
this.earnings = totalAdjustments.earnings;
|
|
17
18
|
this.currencyCode = totalAdjustments.currency_code;
|
|
19
|
+
this.retainedFee = totalAdjustments.retained_fee;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
exports.TotalAdjustmentsNotification = TotalAdjustmentsNotification;
|
package/dist/cjs/notifications/entities/shared/transaction-payout-totals-adjusted-notification.js
CHANGED
|
@@ -11,6 +11,7 @@ class TransactionPayoutTotalsAdjustedNotification {
|
|
|
11
11
|
earnings;
|
|
12
12
|
currencyCode;
|
|
13
13
|
exchangeRate;
|
|
14
|
+
retainedFee;
|
|
14
15
|
constructor(transactionPayoutTotalsAdjusted) {
|
|
15
16
|
this.subtotal = transactionPayoutTotalsAdjusted.subtotal;
|
|
16
17
|
this.tax = transactionPayoutTotalsAdjusted.tax;
|
|
@@ -22,6 +23,7 @@ class TransactionPayoutTotalsAdjustedNotification {
|
|
|
22
23
|
this.earnings = transactionPayoutTotalsAdjusted.earnings;
|
|
23
24
|
this.currencyCode = transactionPayoutTotalsAdjusted.currency_code;
|
|
24
25
|
this.exchangeRate = transactionPayoutTotalsAdjusted.exchange_rate;
|
|
26
|
+
this.retainedFee = transactionPayoutTotalsAdjusted.retained_fee;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
exports.TransactionPayoutTotalsAdjustedNotification = TransactionPayoutTotalsAdjustedNotification;
|
|
@@ -9,6 +9,7 @@ class TransactionTotalsAdjustedNotification {
|
|
|
9
9
|
fee;
|
|
10
10
|
earnings;
|
|
11
11
|
currencyCode;
|
|
12
|
+
retainedFee;
|
|
12
13
|
constructor(transactionTotalsAdjusted) {
|
|
13
14
|
this.subtotal = transactionTotalsAdjusted.subtotal;
|
|
14
15
|
this.tax = transactionTotalsAdjusted.tax;
|
|
@@ -17,6 +18,7 @@ class TransactionTotalsAdjustedNotification {
|
|
|
17
18
|
this.fee = transactionTotalsAdjusted.fee ? transactionTotalsAdjusted.fee : null;
|
|
18
19
|
this.earnings = transactionTotalsAdjusted.earnings ? transactionTotalsAdjusted.earnings : null;
|
|
19
20
|
this.currencyCode = transactionTotalsAdjusted.currency_code;
|
|
21
|
+
this.retainedFee = transactionTotalsAdjusted.retained_fee;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.TransactionTotalsAdjustedNotification = TransactionTotalsAdjustedNotification;
|
|
@@ -23,3 +23,4 @@ __exportStar(require("./update-transaction-request-body.js"), exports);
|
|
|
23
23
|
__exportStar(require("./transaction-preview-request-body.js"), exports);
|
|
24
24
|
__exportStar(require("./get-transaction-invoice-pdf-query-parameters.js"), exports);
|
|
25
25
|
__exportStar(require("./revise-transaction-request-body.js"), exports);
|
|
26
|
+
__exportStar(require("./non-catalog-discount.js"), exports);
|
package/dist/cjs/version.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from './discount-group/index.js';
|
|
|
13
13
|
export * from './events/index.js';
|
|
14
14
|
export * from './payment-method/index.js';
|
|
15
15
|
export * from './payout/index.js';
|
|
16
|
+
export * from './pricing-preview/index.js';
|
|
16
17
|
export * from './event-types/index.js';
|
|
17
18
|
export * from './notification-settings/index.js';
|
|
18
19
|
export * from './notifications/index.js';
|
|
@@ -7,6 +7,7 @@ export class PayoutTotalsAdjustment {
|
|
|
7
7
|
chargebackFee;
|
|
8
8
|
earnings;
|
|
9
9
|
currencyCode;
|
|
10
|
+
retainedFee;
|
|
10
11
|
constructor(payoutTotalsAdjustment) {
|
|
11
12
|
this.subtotal = payoutTotalsAdjustment.subtotal;
|
|
12
13
|
this.tax = payoutTotalsAdjustment.tax;
|
|
@@ -17,5 +18,6 @@ export class PayoutTotalsAdjustment {
|
|
|
17
18
|
: null;
|
|
18
19
|
this.earnings = payoutTotalsAdjustment.earnings;
|
|
19
20
|
this.currencyCode = payoutTotalsAdjustment.currency_code;
|
|
21
|
+
this.retainedFee = payoutTotalsAdjustment.retained_fee;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -5,6 +5,7 @@ export class TotalAdjustments {
|
|
|
5
5
|
fee;
|
|
6
6
|
earnings;
|
|
7
7
|
currencyCode;
|
|
8
|
+
retainedFee;
|
|
8
9
|
constructor(totalAdjustments) {
|
|
9
10
|
this.subtotal = totalAdjustments.subtotal;
|
|
10
11
|
this.tax = totalAdjustments.tax;
|
|
@@ -12,5 +13,6 @@ export class TotalAdjustments {
|
|
|
12
13
|
this.fee = totalAdjustments.fee;
|
|
13
14
|
this.earnings = totalAdjustments.earnings;
|
|
14
15
|
this.currencyCode = totalAdjustments.currency_code;
|
|
16
|
+
this.retainedFee = totalAdjustments.retained_fee;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -8,6 +8,7 @@ export class TransactionPayoutTotalsAdjusted {
|
|
|
8
8
|
earnings;
|
|
9
9
|
currencyCode;
|
|
10
10
|
exchangeRate;
|
|
11
|
+
retainedFee;
|
|
11
12
|
constructor(transactionPayoutTotalsAdjusted) {
|
|
12
13
|
this.subtotal = transactionPayoutTotalsAdjusted.subtotal;
|
|
13
14
|
this.tax = transactionPayoutTotalsAdjusted.tax;
|
|
@@ -19,5 +20,6 @@ export class TransactionPayoutTotalsAdjusted {
|
|
|
19
20
|
this.earnings = transactionPayoutTotalsAdjusted.earnings;
|
|
20
21
|
this.currencyCode = transactionPayoutTotalsAdjusted.currency_code;
|
|
21
22
|
this.exchangeRate = transactionPayoutTotalsAdjusted.exchange_rate;
|
|
23
|
+
this.retainedFee = transactionPayoutTotalsAdjusted.retained_fee;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -6,6 +6,7 @@ export class TransactionTotalsAdjusted {
|
|
|
6
6
|
fee;
|
|
7
7
|
earnings;
|
|
8
8
|
currencyCode;
|
|
9
|
+
retainedFee;
|
|
9
10
|
constructor(transactionTotalsAdjusted) {
|
|
10
11
|
this.subtotal = transactionTotalsAdjusted.subtotal;
|
|
11
12
|
this.tax = transactionTotalsAdjusted.tax;
|
|
@@ -14,5 +15,6 @@ export class TransactionTotalsAdjusted {
|
|
|
14
15
|
this.fee = transactionTotalsAdjusted.fee ? transactionTotalsAdjusted.fee : null;
|
|
15
16
|
this.earnings = transactionTotalsAdjusted.earnings ? transactionTotalsAdjusted.earnings : null;
|
|
16
17
|
this.currencyCode = transactionTotalsAdjusted.currency_code;
|
|
18
|
+
this.retainedFee = transactionTotalsAdjusted.retained_fee;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -5,6 +5,7 @@ import { LogLevel } from './log-level.js';
|
|
|
5
5
|
import { RuntimeProvider } from '../providers/runtime-provider.js';
|
|
6
6
|
import { SDK_VERSION } from '../../version.js';
|
|
7
7
|
import { convertToSnakeCase } from './case-helpers.js';
|
|
8
|
+
import { rawResponse as rawResponseSymbol } from '../types/response.js';
|
|
8
9
|
export class Client {
|
|
9
10
|
apiKey;
|
|
10
11
|
options;
|
|
@@ -48,7 +49,7 @@ export class Client {
|
|
|
48
49
|
headers,
|
|
49
50
|
});
|
|
50
51
|
Logger.logResponse('GET', logUrl, headers, rawResponse);
|
|
51
|
-
return rawResponse.json();
|
|
52
|
+
return { ...(await rawResponse.json()), [rawResponseSymbol]: rawResponse };
|
|
52
53
|
}
|
|
53
54
|
async post(url, requestBody) {
|
|
54
55
|
const logUrl = url.split('?')[0];
|
|
@@ -60,7 +61,7 @@ export class Client {
|
|
|
60
61
|
headers,
|
|
61
62
|
});
|
|
62
63
|
Logger.logResponse('POST', logUrl, headers, rawResponse);
|
|
63
|
-
return rawResponse.json();
|
|
64
|
+
return { ...(await rawResponse.json()), [rawResponseSymbol]: rawResponse };
|
|
64
65
|
}
|
|
65
66
|
async patch(url, requestBody) {
|
|
66
67
|
const logUrl = url.split('?')[0];
|
|
@@ -72,7 +73,7 @@ export class Client {
|
|
|
72
73
|
headers,
|
|
73
74
|
});
|
|
74
75
|
Logger.logResponse('PATCH', logUrl, headers, rawResponse);
|
|
75
|
-
return rawResponse.json();
|
|
76
|
+
return { ...(await rawResponse.json()), [rawResponseSymbol]: rawResponse };
|
|
76
77
|
}
|
|
77
78
|
async delete(url) {
|
|
78
79
|
const logUrl = url.split('?')[0];
|
|
@@ -83,6 +84,11 @@ export class Client {
|
|
|
83
84
|
headers,
|
|
84
85
|
});
|
|
85
86
|
Logger.logResponse('DELETE', logUrl, headers, rawResponse);
|
|
86
|
-
|
|
87
|
+
if (rawResponse.ok) {
|
|
88
|
+
return rawResponse;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return { ...(await rawResponse.json()), [rawResponseSymbol]: rawResponse };
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
94
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rawResponse } from '../types/response.js';
|
|
1
2
|
import { ApiError } from '../errors/generic.js';
|
|
2
3
|
export class BaseResource {
|
|
3
4
|
client;
|
|
@@ -6,7 +7,9 @@ export class BaseResource {
|
|
|
6
7
|
}
|
|
7
8
|
handleError(error) {
|
|
8
9
|
if (error.error) {
|
|
9
|
-
|
|
10
|
+
const retryAfterHeader = error[rawResponse]?.headers.get('Retry-After');
|
|
11
|
+
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : null;
|
|
12
|
+
throw new ApiError(error.error, retryAfter);
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
handleResponse(response) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rawResponse } from '../types/response.js';
|
|
1
2
|
import { ApiError } from '../errors/generic.js';
|
|
2
3
|
export class Collection {
|
|
3
4
|
client;
|
|
@@ -22,7 +23,9 @@ export class Collection {
|
|
|
22
23
|
const entityResponse = response;
|
|
23
24
|
const error = response;
|
|
24
25
|
if (error.error) {
|
|
25
|
-
|
|
26
|
+
const retryAfterHeader = error[rawResponse]?.headers.get('Retry-After');
|
|
27
|
+
const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : null;
|
|
28
|
+
throw new ApiError(error.error, retryAfter);
|
|
26
29
|
}
|
|
27
30
|
return entityResponse;
|
|
28
31
|
}
|
|
@@ -4,12 +4,14 @@ export class ApiError extends Error {
|
|
|
4
4
|
detail;
|
|
5
5
|
documentationUrl;
|
|
6
6
|
errors;
|
|
7
|
-
|
|
7
|
+
retryAfter;
|
|
8
|
+
constructor(errorDetail, retryAfter) {
|
|
8
9
|
super(errorDetail.detail);
|
|
9
10
|
this.type = errorDetail.type;
|
|
10
11
|
this.code = errorDetail.code;
|
|
11
12
|
this.detail = errorDetail.detail;
|
|
12
13
|
this.documentationUrl = errorDetail.documentation_url;
|
|
13
14
|
this.errors = errorDetail.errors ? errorDetail.errors : null;
|
|
15
|
+
this.retryAfter = retryAfter;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const rawResponse = Symbol('raw response');
|
|
@@ -7,6 +7,7 @@ export class PayoutTotalsAdjustmentNotification {
|
|
|
7
7
|
chargebackFee;
|
|
8
8
|
earnings;
|
|
9
9
|
currencyCode;
|
|
10
|
+
retainedFee;
|
|
10
11
|
constructor(payoutTotalsAdjustment) {
|
|
11
12
|
this.subtotal = payoutTotalsAdjustment.subtotal;
|
|
12
13
|
this.tax = payoutTotalsAdjustment.tax;
|
|
@@ -17,5 +18,6 @@ export class PayoutTotalsAdjustmentNotification {
|
|
|
17
18
|
: null;
|
|
18
19
|
this.earnings = payoutTotalsAdjustment.earnings;
|
|
19
20
|
this.currencyCode = payoutTotalsAdjustment.currency_code;
|
|
21
|
+
this.retainedFee = payoutTotalsAdjustment.retained_fee;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -5,6 +5,7 @@ export class TotalAdjustmentsNotification {
|
|
|
5
5
|
fee;
|
|
6
6
|
earnings;
|
|
7
7
|
currencyCode;
|
|
8
|
+
retainedFee;
|
|
8
9
|
constructor(totalAdjustments) {
|
|
9
10
|
this.subtotal = totalAdjustments.subtotal;
|
|
10
11
|
this.tax = totalAdjustments.tax;
|
|
@@ -12,5 +13,6 @@ export class TotalAdjustmentsNotification {
|
|
|
12
13
|
this.fee = totalAdjustments.fee;
|
|
13
14
|
this.earnings = totalAdjustments.earnings;
|
|
14
15
|
this.currencyCode = totalAdjustments.currency_code;
|
|
16
|
+
this.retainedFee = totalAdjustments.retained_fee;
|
|
15
17
|
}
|
|
16
18
|
}
|
package/dist/esm/notifications/entities/shared/transaction-payout-totals-adjusted-notification.js
CHANGED
|
@@ -8,6 +8,7 @@ export class TransactionPayoutTotalsAdjustedNotification {
|
|
|
8
8
|
earnings;
|
|
9
9
|
currencyCode;
|
|
10
10
|
exchangeRate;
|
|
11
|
+
retainedFee;
|
|
11
12
|
constructor(transactionPayoutTotalsAdjusted) {
|
|
12
13
|
this.subtotal = transactionPayoutTotalsAdjusted.subtotal;
|
|
13
14
|
this.tax = transactionPayoutTotalsAdjusted.tax;
|
|
@@ -19,5 +20,6 @@ export class TransactionPayoutTotalsAdjustedNotification {
|
|
|
19
20
|
this.earnings = transactionPayoutTotalsAdjusted.earnings;
|
|
20
21
|
this.currencyCode = transactionPayoutTotalsAdjusted.currency_code;
|
|
21
22
|
this.exchangeRate = transactionPayoutTotalsAdjusted.exchange_rate;
|
|
23
|
+
this.retainedFee = transactionPayoutTotalsAdjusted.retained_fee;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -6,6 +6,7 @@ export class TransactionTotalsAdjustedNotification {
|
|
|
6
6
|
fee;
|
|
7
7
|
earnings;
|
|
8
8
|
currencyCode;
|
|
9
|
+
retainedFee;
|
|
9
10
|
constructor(transactionTotalsAdjusted) {
|
|
10
11
|
this.subtotal = transactionTotalsAdjusted.subtotal;
|
|
11
12
|
this.tax = transactionTotalsAdjusted.tax;
|
|
@@ -14,5 +15,6 @@ export class TransactionTotalsAdjustedNotification {
|
|
|
14
15
|
this.fee = transactionTotalsAdjusted.fee ? transactionTotalsAdjusted.fee : null;
|
|
15
16
|
this.earnings = transactionTotalsAdjusted.earnings ? transactionTotalsAdjusted.earnings : null;
|
|
16
17
|
this.currencyCode = transactionTotalsAdjusted.currency_code;
|
|
18
|
+
this.retainedFee = transactionTotalsAdjusted.retained_fee;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -7,3 +7,4 @@ export * from './update-transaction-request-body.js';
|
|
|
7
7
|
export * from './transaction-preview-request-body.js';
|
|
8
8
|
export * from './get-transaction-invoice-pdf-query-parameters.js';
|
|
9
9
|
export * from './revise-transaction-request-body.js';
|
|
10
|
+
export * from './non-catalog-discount.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '3.
|
|
1
|
+
export const SDK_VERSION = '3.3.0';
|