Class: Direct::API::V5::Response
- Inherits:
-
Object
- Object
- Direct::API::V5::Response
- Defined in:
- lib/direct/api/v5/response.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #error ⇒ Object
- #error? ⇒ Boolean
-
#initialize(body, headers) ⇒ Response
constructor
A new instance of Response.
- #request_id ⇒ Object
- #result ⇒ Object
- #units ⇒ Object
Constructor Details
#initialize(body, headers) ⇒ Response
Returns a new instance of Response.
6 7 8 9 |
# File 'lib/direct/api/v5/response.rb', line 6 def initialize(body, headers) @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/direct/api/v5/response.rb', line 3 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
4 5 6 |
# File 'lib/direct/api/v5/response.rb', line 4 def headers @headers end |
Instance Method Details
#error ⇒ Object
27 28 29 30 |
# File 'lib/direct/api/v5/response.rb', line 27 def error return unless error? @error ||= Error.new(body[:error]) end |
#error? ⇒ Boolean
23 24 25 |
# File 'lib/direct/api/v5/response.rb', line 23 def error? body.key?(:error) end |
#request_id ⇒ Object
15 16 17 |
# File 'lib/direct/api/v5/response.rb', line 15 def request_id @request_id ||= headers[:RequestId] end |
#result ⇒ Object
11 12 13 |
# File 'lib/direct/api/v5/response.rb', line 11 def result body[:result] end |
#units ⇒ Object
19 20 21 |
# File 'lib/direct/api/v5/response.rb', line 19 def units @units ||= Units.new(headers[:Units]) end |