Class: Fuser::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/fuser/response.rb

Instance Method Summary collapse

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

#bodyObject



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|
    expand_error(parsed_response)
  end
end

#codeObject



26
27
28
# File 'lib/fuser/response.rb', line 26

def code
  response.code
end

#error_messageObject



30
31
32
# File 'lib/fuser/response.rb', line 30

def error_message
  body.dig('error', 'message')
end

#raw_bodyObject



18
19
20
# File 'lib/fuser/response.rb', line 18

def raw_body
  response.body
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/fuser/response.rb', line 22

def success?
  code == '200'
end