Class: Fuser::Response
- Inherits:
-
Object
- Object
- Fuser::Response
- Defined in:
- lib/fuser/response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
- #error_message ⇒ Object
-
#initialize(response, action:) ⇒ Response
constructor
A new instance of Response.
- #raw_body ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response, action:) ⇒ Response
Returns a new instance of Response.
7 8 9 10 |
# File 'lib/fuser/response.rb', line 7 def initialize(response, action:) @response = response @action = action end |
Instance Method Details
#body ⇒ Object
12 13 14 15 16 |
# File 'lib/fuser/response.rb', line 12 def body @body ||= JSON.parse(response.body, quirks_mode: true).tap do |parsed_response| (parsed_response) end end |
#code ⇒ Object
26 27 28 |
# File 'lib/fuser/response.rb', line 26 def code response.code end |
#error_message ⇒ Object
30 31 32 |
# File 'lib/fuser/response.rb', line 30 def body.dig('error', 'message') end |
#raw_body ⇒ Object
18 19 20 |
# File 'lib/fuser/response.rb', line 18 def raw_body response.body end |
#success? ⇒ Boolean
22 23 24 |
# File 'lib/fuser/response.rb', line 22 def success? code == '200' end |