Class: Moip2::Response
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Moip2::Response
- Defined in:
- lib/moip2/response.rb
Instance Method Summary collapse
- #client_error? ⇒ Boolean
-
#initialize(resp, json) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(resp, json) ⇒ Response
Returns a new instance of Response.
3 4 5 6 7 8 9 10 |
# File 'lib/moip2/response.rb', line 3 def initialize(resp, json) if json.is_a? Hash super(RecursiveOpenStruct.new(json, recurse_over_arrays: true)) else super(resp) end @resp = resp end |
Instance Method Details
#client_error? ⇒ Boolean
16 17 18 |
# File 'lib/moip2/response.rb', line 16 def client_error? (400..499).cover? @resp.code.to_i end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/moip2/response.rb', line 12 def success? (200..299).cover? @resp.code.to_i end |