Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/recharge/response.rb
Defined Under Namespace
Classes: BadRequest, NotAuthorized, NotFound
Instance Method Summary collapse
- #assertValidResponse ⇒ Object
- #body ⇒ Object
- #code ⇒ Object
-
#initialize(code, body) ⇒ Response
constructor
A new instance of Response.
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
#assertValidResponse ⇒ Object
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 |
#body ⇒ Object
9 10 11 |
# File 'lib/recharge/response.rb', line 9 def body @body end |
#code ⇒ Object
6 7 8 |
# File 'lib/recharge/response.rb', line 6 def code @code end |