Class: Cardgate::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
14
15
# File 'lib/cardgate/response.rb', line 7

def initialize(response)
  if response.body.nil?
    raise Cardgate::Exception, 'Got an empty response from API'
  elsif !response.status.between?(200, 299)
    raise Cardgate::Exception, "#{response.body["error"]["code"]}: #{response.body["error"]["message"]}"
  else
    @body = response.body
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/cardgate/response.rb', line 5

def body
  @body
end