Class: PayLane::Response
- Inherits:
-
Hash
- Object
- Hash
- PayLane::Response
- Defined in:
- lib/paylane/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #attributes ⇒ Object
- #error_description ⇒ Object
- #has_data? ⇒ Boolean
- #has_error? ⇒ Boolean
- #has_ok? ⇒ Boolean
-
#initialize(body) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(body) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/paylane/response.rb', line 5 def initialize(body) @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/paylane/response.rb', line 3 def body @body end |
Instance Method Details
#attributes ⇒ Object
25 26 27 28 |
# File 'lib/paylane/response.rb', line 25 def attributes hash = (@body[:ok] || @body[:error]) has_data? ? hash.merge(@body[:data]) : hash end |
#error_description ⇒ Object
21 22 23 |
# File 'lib/paylane/response.rb', line 21 def error_description @body[:error][:error_description] if has_error? end |
#has_data? ⇒ Boolean
17 18 19 |
# File 'lib/paylane/response.rb', line 17 def has_data? @body.include?(:data) end |
#has_error? ⇒ Boolean
13 14 15 |
# File 'lib/paylane/response.rb', line 13 def has_error? !has_ok? end |
#has_ok? ⇒ Boolean
9 10 11 |
# File 'lib/paylane/response.rb', line 9 def has_ok? @body.include?(:ok) end |