Class: Smartpay::Responses::Base
- Inherits:
-
Object
- Object
- Smartpay::Responses::Base
- Defined in:
- lib/smartpay/responses/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #as_hash ⇒ Object
- #as_json ⇒ Object
- #http_code ⇒ Object
-
#initialize(raw_response) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(raw_response) ⇒ Base
8 9 10 11 12 13 14 15 |
# File 'lib/smartpay/responses/base.rb', line 8 def initialize(raw_response) @raw_response = raw_response @response = begin JSON.parse(@raw_response.body, symbolize_names: true) rescue JSON::ParserError { body: @raw_response.body } end if @raw_response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/smartpay/responses/base.rb', line 6 def response @response end |
Instance Method Details
#as_hash ⇒ Object
17 18 19 |
# File 'lib/smartpay/responses/base.rb', line 17 def as_hash @response end |
#as_json ⇒ Object
21 22 23 |
# File 'lib/smartpay/responses/base.rb', line 21 def as_json @response.to_json end |
#http_code ⇒ Object
25 26 27 |
# File 'lib/smartpay/responses/base.rb', line 25 def http_code @raw_response.code end |