Class: GetResponse::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



3
4
5
# File 'lib/get_response/response.rb', line 3

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject



7
8
9
10
11
# File 'lib/get_response/response.rb', line 7

def body
  JSON.parse(@response.body)
rescue JSON::ParserError => e
  {}
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/get_response/response.rb', line 13

def success?
  [200, 201, 202].include? @response.status
end