Class: Multicard::Response
- Inherits:
-
Object
- Object
- Multicard::Response
- Defined in:
- lib/multicard/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #data ⇒ Object
- #error_code ⇒ Object
- #error_details ⇒ Object
-
#initialize(http_status:, body:, headers: {}) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(http_status:, body:, headers: {}) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 |
# File 'lib/multicard/response.rb', line 7 def initialize(http_status:, body:, headers: {}) @http_status = http_status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/multicard/response.rb', line 5 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/multicard/response.rb', line 5 def headers @headers end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
5 6 7 |
# File 'lib/multicard/response.rb', line 5 def http_status @http_status end |
Instance Method Details
#[](key) ⇒ Object
29 30 31 |
# File 'lib/multicard/response.rb', line 29 def [](key) data&.[](key) end |
#data ⇒ Object
17 18 19 |
# File 'lib/multicard/response.rb', line 17 def data body[:data] end |
#error_code ⇒ Object
21 22 23 |
# File 'lib/multicard/response.rb', line 21 def error_code body.dig(:error, :code) end |
#error_details ⇒ Object
25 26 27 |
# File 'lib/multicard/response.rb', line 25 def error_details body.dig(:error, :details) end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/multicard/response.rb', line 13 def success? body[:success] == true end |