Class: AmazonSellerCentral::PaymentsPage

Inherits:
Page
  • Object
show all
Defined in:
lib/amazon_seller_central/payments_page.rb

Constant Summary collapse

PAYMENT_FEED_V1 =
"_GET_FLAT_FILE_PAYMENT_SETTLEMENT_DATA__"
PAYMENT_FEED_V2 =
"_GET_V2_SETTLEMENT_REPORT_DATA__"

Instance Attribute Summary collapse

Attributes inherited from Page

#body

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Page

#initialize, #last_page?

Constructor Details

This class inherits a constructor from AmazonSellerCentral::Page

Instance Attribute Details

#pageObject

Returns the value of attribute page.



3
4
5
# File 'lib/amazon_seller_central/payments_page.rb', line 3

def page
  @page
end

Class Method Details

.available_report_idsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/amazon_seller_central/payments_page.rb', line 20

def self.available_report_ids
  id_array = []
  mech = AmazonSellerCentral.mechanizer
  mech.
  mech.follow_link_with(:text => "Payments")
  payments_page = mech.follow_link_with(:text => "All Statements")
  @page = PaymentsPage.new(:page => payments_page, :agent => mech)
  id_array << @page.page.links_with(:text => "Download Flat File").map{|link| link.href.match(/(#{PAYMENT_FEED_V1}|#{PAYMENT_FEED_V2})(\d+)\.txt/)[2]}
  while(@page.has_next?)
    @page = @page.next_page
    id_array << @page.page.links_with(:text => "Download Flat File").map{|link| link.href.match(/(#{PAYMENT_FEED_V1}|#{PAYMENT_FEED_V2})(\d+)\.txt/)[2]}
  end
  id_array.flatten
end

Instance Method Details

#has_next?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/amazon_seller_central/payments_page.rb', line 8

def has_next?
  @has_next ||= @page.search('a').map(&:text).grep(/Next/).any?
end

#next_pageObject



12
13
14
15
16
17
18
# File 'lib/amazon_seller_central/payments_page.rb', line 12

def next_page
  @next_page ||= begin
                   raise NoNextPageAvailableError unless has_next?
                   @page = @agent.follow_link_with(:text => 'Next')
                   PaymentsPage.new(:page => page, :agent => @agent)
                 end
end