Class: Response

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

Defined Under Namespace

Classes: BadRequest, NotAuthorized, NotFound

Instance Method Summary collapse

Constructor Details

#initialize(code, body) ⇒ Response

Returns a new instance of Response.



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

def initialize(code, body)
  @code = code
  @body = body
end

Instance Method Details

#assertValidResponseObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/recharge/response.rb', line 22

def assertValidResponse
  case @code.to_i
  when 200
      return
  when 400
      raise BadRequest, Recharge::Base.returnErrorXML(@body)
  when 401
      raise NotAuthorized, Recharge::Base.returnErrorXML(@body)
  when 404
      raise NotFound, Recharge::Base.returnErrorXML(@body)
  end
end

#bodyObject



9
10
11
# File 'lib/recharge/response.rb', line 9

def body
  @body
end

#codeObject



6
7
8
# File 'lib/recharge/response.rb', line 6

def code
  @code
end