amazon_seller_central 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/amazon_seller_central.gemspec +8 -2
- data/lib/amazon_seller_central/payment.rb +5 -0
- data/lib/amazon_seller_central/payments_page.rb +34 -0
- data/lib/amazon_seller_central.rb +2 -0
- data/spec/lib/inventory_page_spec.rb +16 -16
- data/spec/lib/listing_set_spec.rb +6 -6
- data/spec/lib/orders_page_spec.rb +1 -1
- data/spec/lib/payments_page_spec.rb +12 -0
- data/spec/support/sample_pages/Payments Page.html +908 -0
- data/spec/support/sample_pages/Seller Central Homepage.html +2178 -2175
- data/spec/support/sample_pages/Settlement Payment Reports 1.html +668 -0
- data/spec/support/sample_pages/Settlement Payment Reports 2.html +665 -0
- data/spec/support/sample_pages/listings_page_1.html +21596 -7144
- data/spec/support/sample_pages/update_inventory_result_from_page_1.html +21603 -7140
- data/spec/support/sample_pages.rb +5 -0
- metadata +37 -31
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "amazon_seller_central"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["optoro"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-05-16"
|
13
13
|
s.description = "This gem is intended to wrap Amazon's SellerCentral pages with a Ruby API. Currently this gem supports accessing buyer feedback only."
|
14
14
|
s.email = "dev@optoro.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,6 +41,8 @@ Gem::Specification.new do |s|
|
|
41
41
|
"lib/amazon_seller_central/order.rb",
|
42
42
|
"lib/amazon_seller_central/orders_page.rb",
|
43
43
|
"lib/amazon_seller_central/page.rb",
|
44
|
+
"lib/amazon_seller_central/payment.rb",
|
45
|
+
"lib/amazon_seller_central/payments_page.rb",
|
44
46
|
"spec/amazon_seller_central_spec.rb",
|
45
47
|
"spec/lib/feedback_page_spec.rb",
|
46
48
|
"spec/lib/feedback_spec.rb",
|
@@ -50,6 +52,7 @@ Gem::Specification.new do |s|
|
|
50
52
|
"spec/lib/listing_spec.rb",
|
51
53
|
"spec/lib/mechanizer_spec.rb",
|
52
54
|
"spec/lib/orders_page_spec.rb",
|
55
|
+
"spec/lib/payments_page_spec.rb",
|
53
56
|
"spec/spec_helper.rb",
|
54
57
|
"spec/support/page_body_regexen.rb",
|
55
58
|
"spec/support/page_examples.rb",
|
@@ -59,9 +62,12 @@ Gem::Specification.new do |s|
|
|
59
62
|
"spec/support/sample_pages/Feedback Page 2.html",
|
60
63
|
"spec/support/sample_pages/Feedback Page Last.html",
|
61
64
|
"spec/support/sample_pages/Manage Orders.html",
|
65
|
+
"spec/support/sample_pages/Payments Page.html",
|
62
66
|
"spec/support/sample_pages/Seller Central Homepage.html",
|
63
67
|
"spec/support/sample_pages/Seller Central Redirect.html",
|
64
68
|
"spec/support/sample_pages/Seller Central.html",
|
69
|
+
"spec/support/sample_pages/Settlement Payment Reports 1.html",
|
70
|
+
"spec/support/sample_pages/Settlement Payment Reports 2.html",
|
65
71
|
"spec/support/sample_pages/another_listings_page.html",
|
66
72
|
"spec/support/sample_pages/listings_last_page.html",
|
67
73
|
"spec/support/sample_pages/listings_page_1.html",
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module AmazonSellerCentral
|
2
|
+
class PaymentsPage < Page
|
3
|
+
attr_accessor :page
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def has_next?
|
8
|
+
@has_next ||= @page.search('a').map(&:text).grep(/Next/).any?
|
9
|
+
end
|
10
|
+
|
11
|
+
def next_page
|
12
|
+
@next_page ||= begin
|
13
|
+
raise NoNextPageAvailableError unless has_next?
|
14
|
+
@page = @agent.follow_link_with(:text => 'Next')
|
15
|
+
PaymentsPage.new(:page => page, :agent => @agent)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.available_report_ids
|
20
|
+
id_array = []
|
21
|
+
mech = AmazonSellerCentral.mechanizer
|
22
|
+
mech.login_to_seller_central
|
23
|
+
mech.follow_link_with(:text => "Payments")
|
24
|
+
payments_page = mech.follow_link_with(:text => "Past Settlements")
|
25
|
+
@page = PaymentsPage.new(:page => payments_page, :agent => mech)
|
26
|
+
id_array << @page.page.links_with(:text => "Download Flat File").map{|link| link.href.match(/_GET_FLAT_FILE_PAYMENT_SETTLEMENT_DATA__(\d+)\.txt/)[1]}
|
27
|
+
while(@page.has_next?)
|
28
|
+
@page = @page.next_page
|
29
|
+
id_array << @page.page.links_with(:text => "Download Flat File").map{|link| link.href.match(/_GET_FLAT_FILE_PAYMENT_SETTLEMENT_DATA__(\d+)\.txt/)[1]}
|
30
|
+
end
|
31
|
+
id_array.flatten
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -9,6 +9,8 @@ require 'amazon_seller_central/inventory'
|
|
9
9
|
require 'amazon_seller_central/inventory_page'
|
10
10
|
require 'amazon_seller_central/order'
|
11
11
|
require 'amazon_seller_central/orders_page'
|
12
|
+
require 'amazon_seller_central/payment'
|
13
|
+
require 'amazon_seller_central/payments_page'
|
12
14
|
|
13
15
|
module AmazonSellerCentral
|
14
16
|
def self.configuration
|
@@ -23,26 +23,26 @@ describe "InventoryPage" do
|
|
23
23
|
|
24
24
|
it "transforms itself into a set of Listing objects" do
|
25
25
|
listings = @first_page.listings
|
26
|
-
listings.size.should ==
|
27
|
-
|
28
|
-
listings[3].sku.should == "
|
29
|
-
listings[3].asin.should == "
|
30
|
-
listings[3].product_name.should == "
|
31
|
-
listings[3].created_at.should == Time.parse("
|
32
|
-
listings[3].quantity.should ==
|
33
|
-
listings[3].condition.should == "
|
34
|
-
listings[3].price_cents.should ==
|
26
|
+
listings.size.should == 500
|
27
|
+
|
28
|
+
listings[3].sku.should == "PR24386-11"
|
29
|
+
listings[3].asin.should == "B000MFORRA"
|
30
|
+
listings[3].product_name.should == "Asa 5505 Sec. Plus License"
|
31
|
+
listings[3].created_at.should == Time.parse("2012-05-16 12:03:14")
|
32
|
+
listings[3].quantity.should == 2
|
33
|
+
listings[3].condition.should == "New"
|
34
|
+
listings[3].price_cents.should == 31399
|
35
35
|
listings[3].low_price.should == nil
|
36
36
|
listings[3].low_price_cents.should == nil
|
37
|
-
listings[3].status.should == "
|
37
|
+
listings[3].status.should == "Active"
|
38
38
|
|
39
|
-
listings[6].sku.should == "
|
40
|
-
listings[6].asin.should == "
|
41
|
-
listings[6].product_name.should == "
|
42
|
-
listings[6].created_at.should == Time.parse("
|
39
|
+
listings[6].sku.should == "PR23923-11"
|
40
|
+
listings[6].asin.should == "B002QEBM96"
|
41
|
+
listings[6].product_name.should == "Nokia E72 Unlocked Phone Featuring GPS with Voice Navigation - U.S. Version with Full Warranty (Zodium Black)"
|
42
|
+
listings[6].created_at.should == Time.parse("2012-05-16 11:28:07")
|
43
43
|
listings[6].quantity.should == 1
|
44
44
|
listings[6].condition.should == "New"
|
45
|
-
listings[6].price_cents.should ==
|
45
|
+
listings[6].price_cents.should == 24999
|
46
46
|
listings[6].status.should == "Active"
|
47
47
|
end
|
48
48
|
|
@@ -86,7 +86,7 @@ describe "InventoryPage" do
|
|
86
86
|
|
87
87
|
it "raises an unsupported modification error when trying to set the price on an incomplete listing" do
|
88
88
|
listings = @first_page.listings
|
89
|
-
l = listings[
|
89
|
+
l = listings[5]
|
90
90
|
l.price = 24.26
|
91
91
|
lambda {
|
92
92
|
@first_page.apply_listings([l])
|
@@ -10,16 +10,16 @@ describe "ListingSet" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "allows find by sku" do
|
13
|
-
listing = @listing_set.find("
|
14
|
-
listing.sku.should == "
|
15
|
-
listing.asin.should == "
|
13
|
+
listing = @listing_set.find("PR24386-11")
|
14
|
+
listing.sku.should == "PR24386-11"
|
15
|
+
listing.asin.should == "B000MFORRA"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "allows find by asin" do
|
19
|
-
listings = @listing_set.find("
|
19
|
+
listings = @listing_set.find("B002QEBM96")
|
20
20
|
listings.should be_kind_of(Enumerable)
|
21
|
-
listings.first.sku.should == "
|
22
|
-
listings.first.asin.should == "
|
21
|
+
listings.first.sku.should == "PR23923-11"
|
22
|
+
listings.first.asin.should == "B002QEBM96"
|
23
23
|
end
|
24
24
|
|
25
25
|
# it "allows where by quantity" do
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe "OrdersPage" do
|
4
4
|
describe "pending_orders" do
|
5
5
|
it "should return an array of pending orders" do
|
6
|
-
orders = AmazonSellerCentral::OrdersPage.pending_orders
|
6
|
+
orders = AmazonSellerCentral::OrdersPage.pending_orders
|
7
7
|
orders.class.should == Array
|
8
8
|
orders.count.should == 38
|
9
9
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "PaymentsPage" do
|
4
|
+
describe "available_report_ids" do
|
5
|
+
it "should return an array of report ids that are available for you to download from seeler central" do
|
6
|
+
report_ids = AmazonSellerCentral::PaymentsPage.available_report_ids
|
7
|
+
report_ids.class.should == Array
|
8
|
+
report_ids.count.should == 10
|
9
|
+
report_ids[4].should == "55555555"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|