Class: PagSeguro::SubscriptionSearchPaymentOrders
- Inherits:
-
Object
- Object
- PagSeguro::SubscriptionSearchPaymentOrders
- Defined in:
- lib/pagseguro/subscription_search_payment_orders.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#created_at ⇒ Object
The report’s creation date.
-
#initialize(code, status, options = {}) ⇒ SubscriptionSearchPaymentOrders
constructor
A new instance of SubscriptionSearchPaymentOrders.
-
#next_page! ⇒ Object
Move the page pointer to the next page.
-
#next_page? ⇒ Boolean
Detect if the report has a next page.
-
#payment_orders ⇒ Object
Return the list of subscription payment orders.
-
#previous_page! ⇒ Object
Move the page pointer to the previous page.
-
#previous_page? ⇒ Boolean
Detect if the report has a previous page.
-
#results ⇒ Object
How many results the report returned on the given page.
-
#total_pages ⇒ Object
How many pages the report returned.
-
#valid? ⇒ Boolean
Detect if the report request returned errors.
Constructor Details
#initialize(code, status, options = {}) ⇒ SubscriptionSearchPaymentOrders
Returns a new instance of SubscriptionSearchPaymentOrders.
9 10 11 12 13 14 15 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 9 def initialize(code, status, ={}) @code = code @status = status @options = @page = .delete(:page) || 0 @errors = Errors.new end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 3 def code @code end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 6 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 4 def @options end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
7 8 9 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 7 def page @page end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 5 def status @status end |
Instance Method Details
#created_at ⇒ Object
The report’s creation date.
28 29 30 31 32 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 28 def created_at xml do |xml| @created_at ||= Time.parse xml.css("paymentOrdersResult > date").text end end |
#next_page! ⇒ Object
Move the page pointer to the next page.
59 60 61 62 63 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 59 def next_page! return unless next_page? @page += 1 clear! end |
#next_page? ⇒ Boolean
Detect if the report has a next page.
49 50 51 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 49 def next_page? page.zero? || page < total_pages end |
#payment_orders ⇒ Object
Return the list of subscription payment orders. Each item will be wrapped in a PagSeguro::SubscriptionPaymentOrder instance.
19 20 21 22 23 24 25 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 19 def payment_orders xml do |xml| xml.css("paymentOrdersResult > paymentOrders > paymentOrder").map do |node| SubscriptionPaymentOrder.load_from_xml(node) end end end |
#previous_page! ⇒ Object
Move the page pointer to the previous page.
66 67 68 69 70 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 66 def previous_page! return unless previous_page? @page -= 1 clear! end |
#previous_page? ⇒ Boolean
Detect if the report has a previous page.
54 55 56 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 54 def previous_page? page > 1 end |
#results ⇒ Object
How many results the report returned on the given page.
35 36 37 38 39 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 35 def results xml do |xml| @results = xml.css("paymentOrdersResult > resultsInThisPage").text.to_i end end |
#total_pages ⇒ Object
How many pages the report returned.
42 43 44 45 46 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 42 def total_pages xml do |xml| @total_pages ||= xml.css("paymentOrdersResult > totalPages").text.to_i end end |
#valid? ⇒ Boolean
Detect if the report request returned errors.
73 74 75 |
# File 'lib/pagseguro/subscription_search_payment_orders.rb', line 73 def valid? fetch { errors.empty? } end |