Exception: QuickPay::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- QuickPay::API::Error
- Defined in:
- lib/quickpay/api/error.rb
Direct Known Subclasses
BadGateway, BadRequest, Conflict, Forbidden, GatewayTimeout, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, PaymentRequired, ServiceUnavailable, TooManyRequest, Unauthorized
Defined Under Namespace
Classes: BadGateway, BadRequest, Conflict, Forbidden, GatewayTimeout, InternalServerError, MethodNotAllowed, NotAcceptable, NotFound, PaymentRequired, ServiceUnavailable, TooManyRequest, Unauthorized
Constant Summary collapse
- CLASS_MAP =
{ 400 => "BadRequest", 401 => "Unauthorized", 402 => "PaymentRequired", 403 => "Forbidden", 404 => "NotFound", 405 => "MethodNotAllowed", 406 => "NotAcceptable", 409 => "Conflict", 429 => "TooManyRequest", 500 => "InternalServerError", 502 => "BadGateway", 503 => "ServiceUnavailable", 504 => "GatewayTimeout" }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, body, headers) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(status, body, headers) ⇒ Error
Returns a new instance of Error.
36 37 38 39 40 |
# File 'lib/quickpay/api/error.rb', line 36 def initialize(status, body, headers) @status = status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
34 35 36 |
# File 'lib/quickpay/api/error.rb', line 34 def status @status end |
Class Method Details
.by_status_code(status, body, headers) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/quickpay/api/error.rb', line 42 def self.by_status_code(status, body, headers) if CLASS_MAP[status] klass = QuickPay::API::Error.const_get(CLASS_MAP[status]) fail klass.new(status, body, headers) else fail QuickPay::API::Error.new(status, body, headers) end end |