@basis-theory/basis-theory-reactor-formulas-sdk-js 1.0.1 → 1.1.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/package.json +1 -1
- package/src/errors/AuthenticationError.js +5 -1
- package/src/errors/BadRequestError.js +1 -1
- package/src/errors/BasisTheoryReactorError.js +3 -1
- package/src/errors/InvalidPaymentMethodError.js +9 -0
- package/src/errors/InvalidReactorConfigurationError.js +23 -0
- package/src/errors/InvalidReactorFormulaError.js +2 -2
- package/src/errors/RateLimitError.js +1 -1
- package/src/errors/ReactorRuntimeError.js +1 -1
- package/src/errors/index.js +4 -2
- package/src/errors/InvalidCardError.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory/basis-theory-reactor-formulas-sdk-js",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Javascript SDK for building Basis Theory reactor formulas",
|
|
5
5
|
"repository": "https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -2,7 +2,11 @@ const BasisTheoryReactorError = require('./BasisTheoryReactorError');
|
|
|
2
2
|
|
|
3
3
|
class AuthenticationError extends BasisTheoryReactorError {
|
|
4
4
|
constructor(data) {
|
|
5
|
-
super(
|
|
5
|
+
super({
|
|
6
|
+
message: 'Authentication Failed',
|
|
7
|
+
status: 401,
|
|
8
|
+
data,
|
|
9
|
+
});
|
|
6
10
|
}
|
|
7
11
|
}
|
|
8
12
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
class BasisTheoryReactorError extends Error {
|
|
2
|
-
constructor(message, status, data) {
|
|
2
|
+
constructor({ message, status, data, propertyValidationErrors }) {
|
|
3
3
|
super(message);
|
|
4
4
|
this.status = status;
|
|
5
5
|
this.data = data;
|
|
6
|
+
this.propertyValidationErrors = propertyValidationErrors;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
toRFC7807() {
|
|
9
10
|
return {
|
|
10
11
|
title: this.message,
|
|
11
12
|
status: this.status,
|
|
13
|
+
errors: this.propertyValidationErrors,
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const BasisTheoryReactorError = require('./BasisTheoryReactorError');
|
|
2
|
+
|
|
3
|
+
class InvalidPaymentMethodError extends BasisTheoryReactorError {
|
|
4
|
+
constructor(data) {
|
|
5
|
+
super({ message: 'Invalid Payment Method', status: 402, data });
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = InvalidPaymentMethodError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const BasisTheoryReactorError = require('./BasisTheoryReactorError');
|
|
2
|
+
|
|
3
|
+
class InvalidReactorConfigurationError extends BasisTheoryReactorError {
|
|
4
|
+
constructor(errors) {
|
|
5
|
+
const validationErrors = {};
|
|
6
|
+
if (typeof errors === 'object') {
|
|
7
|
+
for (const property in errors) {
|
|
8
|
+
validationErrors[property] = Array.isArray(errors[property])
|
|
9
|
+
? errors[property].map((e) => e.toString())
|
|
10
|
+
: [errors[property].toString()];
|
|
11
|
+
}
|
|
12
|
+
} else if (typeof errors === 'string') {
|
|
13
|
+
validationErrors[errors] = [`${errors} is invalid`];
|
|
14
|
+
}
|
|
15
|
+
super({
|
|
16
|
+
message: 'Invalid Reactor Configuration',
|
|
17
|
+
status: 400,
|
|
18
|
+
propertyValidationErrors: validationErrors,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = InvalidReactorConfigurationError;
|
|
@@ -2,7 +2,7 @@ const BasisTheoryReactorError = require('./BasisTheoryReactorError');
|
|
|
2
2
|
|
|
3
3
|
class ReactorRuntimeError extends BasisTheoryReactorError {
|
|
4
4
|
constructor(error) {
|
|
5
|
-
super('Reactor Runtime Error', 500, error);
|
|
5
|
+
super({ message: 'Reactor Runtime Error', status: 500, data: error });
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
package/src/errors/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const AuthenticationError = require('./AuthenticationError');
|
|
2
2
|
const BadRequestError = require('./BadRequestError');
|
|
3
|
-
const
|
|
3
|
+
const InvalidPaymentMethodError = require('./InvalidPaymentMethodError');
|
|
4
|
+
const InvalidReactorConfigurationError = require('./InvalidReactorConfigurationError');
|
|
4
5
|
const RateLimitError = require('./RateLimitError');
|
|
5
6
|
const ReactorRuntimeError = require('./ReactorRuntimeError');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
AuthenticationError,
|
|
9
10
|
BadRequestError,
|
|
10
|
-
|
|
11
|
+
InvalidPaymentMethodError,
|
|
12
|
+
InvalidReactorConfigurationError,
|
|
11
13
|
RateLimitError,
|
|
12
14
|
ReactorRuntimeError,
|
|
13
15
|
};
|