UNPKG

kotanipay-sdk

Version:

Official Kotani Pay SDK for Node.js and Browser

49 lines 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthenticationException = exports.ValidationException = exports.KotaniPayException = exports.HttpStatus = void 0; var HttpStatus; (function (HttpStatus) { HttpStatus[HttpStatus["OK"] = 200] = "OK"; HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED"; HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST"; HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED"; HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN"; HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND"; HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR"; })(HttpStatus || (exports.HttpStatus = HttpStatus = {})); class KotaniPayException extends Error { constructor(message, status = HttpStatus.INTERNAL_SERVER_ERROR, errorCode, details) { super(message); this.name = 'KotaniPayException'; this.status = status; this.errorCode = errorCode; this.details = details; this.timestamp = new Date().toISOString(); } toJSON() { return { name: this.name, message: this.message, status: this.status, errorCode: this.errorCode, details: this.details, timestamp: this.timestamp, }; } } exports.KotaniPayException = KotaniPayException; class ValidationException extends KotaniPayException { constructor(message, details) { super(message, HttpStatus.BAD_REQUEST, 'VALIDATION_ERROR', details); this.name = 'ValidationException'; } } exports.ValidationException = ValidationException; class AuthenticationException extends KotaniPayException { constructor(message = 'Authentication failed') { super(message, HttpStatus.UNAUTHORIZED, 'AUTHENTICATION_ERROR'); this.name = 'AuthenticationException'; } } exports.AuthenticationException = AuthenticationException; //# sourceMappingURL=kotani-pay.exception.js.map