Class: BraspagRest::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag-rest/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway_response) ⇒ Response

Returns a new instance of Response.



5
6
7
# File 'lib/braspag-rest/response.rb', line 5

def initialize(gateway_response)
  @gateway_response = gateway_response
end

Instance Attribute Details

#gateway_responseObject (readonly)

Returns the value of attribute gateway_response.



3
4
5
# File 'lib/braspag-rest/response.rb', line 3

def gateway_response
  @gateway_response
end

Instance Method Details

#parsed_bodyObject



13
14
15
# File 'lib/braspag-rest/response.rb', line 13

def parsed_body
  JSON.parse(@gateway_response.body) rescue {}
end

#success?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/braspag-rest/response.rb', line 9

def success?
  (200..207).include?(@gateway_response.code) rescue false
end