Class: Payrix::Http::Response
- Inherits:
-
Object
- Object
- Payrix::Http::Response
- Defined in:
- lib/payrix/http/response.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #details ⇒ Object
- #errors ⇒ Object
- #has_errors? ⇒ Boolean
- #has_more? ⇒ Boolean
-
#initialize(response = {}, status = '', cls) ⇒ Response
constructor
A new instance of Response.
-
#response ⇒ Object
Return the response as an array.
- #totals ⇒ Object
Constructor Details
#initialize(response = {}, status = '', cls) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/payrix/http/response.rb', line 6 def initialize(response = {}, status = '', cls) @response = response @status = status @cls = cls end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/payrix/http/response.rb', line 4 def status @status end |
Instance Method Details
#details ⇒ Object
26 27 28 |
# File 'lib/payrix/http/response.rb', line 26 def details (@response['response'] && @response['response']['details']) || {} end |
#errors ⇒ Object
18 19 20 |
# File 'lib/payrix/http/response.rb', line 18 def errors @response['errors'] || (@response['response'] && @response['response']['errors']) || [] end |
#has_errors? ⇒ Boolean
22 23 24 |
# File 'lib/payrix/http/response.rb', line 22 def has_errors? !errors.empty? end |
#has_more? ⇒ Boolean
34 35 36 37 38 39 40 41 |
# File 'lib/payrix/http/response.rb', line 34 def has_more? page = @response['response'] && @response['response']['details'] && @response['response']['details']['page'] !page.nil? && !page['current'].nil? && !page['last'].nil? && page['current'] < page['last'] end |
#response ⇒ Object
Return the response as an array
13 14 15 16 |
# File 'lib/payrix/http/response.rb', line 13 def response data = (@response['response'] && @response['response']['data']) || [] data.map { |v| @cls.new(v) } end |
#totals ⇒ Object
30 31 32 |
# File 'lib/payrix/http/response.rb', line 30 def totals (@response['response'] && @response['response']['details'] && @response['response']['details']['totals']) || {} end |