amazon_seller_central 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p290"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+
14
+ #
15
+ # First we attempt to load the desired environment directly from the environment
16
+ # file. This is very fast and efficient compared to running through the entire
17
+ # CLI and selector. If you want feedback on which environment was used then
18
+ # insert the word 'use' after --create as this triggers verbose mode.
19
+ #
20
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
21
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
22
+ then
23
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
24
+
25
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
26
+ then
27
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
28
+ fi
29
+ else
30
+ # If the environment file has not yet been created, use the RVM CLI to select.
31
+ if ! rvm --create "$environment_id"
32
+ then
33
+ echo "Failed to create RVM environment '${environment_id}'."
34
+ return 1
35
+ fi
36
+ fi
37
+
38
+ #
39
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
40
+ # it be automatically loaded. Uncomment the following and adjust the filename if
41
+ # necessary.
42
+ #
43
+ # filename=".gems"
44
+ # if [[ -s "$filename" ]]
45
+ # then
46
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
47
+ # fi
48
+
49
+ # If you use bundler, this might be useful to you:
50
+ # if command -v bundle && [[ -s Gemfile ]]
51
+ # then
52
+ # bundle install
53
+ # fi
54
+
55
+
data/Gemfile CHANGED
@@ -20,5 +20,5 @@ group :development do
20
20
  gem 'ffi'
21
21
  gem 'faker'
22
22
  gem 'fakeweb'
23
- gem 'ruby-debug'
23
+ gem 'ruby-debug19'
24
24
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- columnize (0.3.2)
4
+ archive-tar-minitar (0.5.2)
5
+ columnize (0.3.5)
5
6
  diff-lcs (1.1.2)
6
7
  faker (0.9.5)
7
8
  i18n (~> 0.4)
@@ -18,7 +19,8 @@ GEM
18
19
  git (>= 1.2.5)
19
20
  rake
20
21
  libnotify (0.5.6)
21
- linecache (0.43)
22
+ linecache19 (0.5.12)
23
+ ruby_core_source (>= 0.1.4)
22
24
  mechanize (1.0.0)
23
25
  nokogiri (>= 1.2.1)
24
26
  nokogiri (1.4.4)
@@ -34,11 +36,16 @@ GEM
34
36
  rspec-expectations (2.3.0)
35
37
  diff-lcs (~> 1.1.2)
36
38
  rspec-mocks (2.3.0)
37
- ruby-debug (0.10.4)
38
- columnize (>= 0.1)
39
- ruby-debug-base (~> 0.10.4.0)
40
- ruby-debug-base (0.10.4)
41
- linecache (>= 0.3)
39
+ ruby-debug-base19 (0.11.25)
40
+ columnize (>= 0.3.1)
41
+ linecache19 (>= 0.5.11)
42
+ ruby_core_source (>= 0.1.4)
43
+ ruby-debug19 (0.11.6)
44
+ columnize (>= 0.3.1)
45
+ linecache19 (>= 0.5.11)
46
+ ruby-debug-base19 (>= 0.11.19)
47
+ ruby_core_source (0.1.5)
48
+ archive-tar-minitar (>= 0.5.2)
42
49
  thor (0.14.6)
43
50
  yard (0.7.2)
44
51
 
@@ -58,5 +65,5 @@ DEPENDENCIES
58
65
  rb-inotify (>= 0.8.5)
59
66
  rcov
60
67
  rspec (~> 2.3.0)
61
- ruby-debug
68
+ ruby-debug19
62
69
  yard
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{amazon_seller_central}
8
- s.version = "0.2.2"
7
+ s.name = "amazon_seller_central"
8
+ s.version = "0.2.3"
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 = %q{2011-10-25}
13
- s.description = %q{This gem is intended to wrap Amazon's SellerCentral pages with a Ruby API. Currently this gem supports accessing buyer feedback only.}
14
- s.email = %q{dev@optoro.com}
12
+ s.date = "2011-12-01"
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
+ s.email = "dev@optoro.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.md"
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
+ ".rvmrc",
22
23
  "CHANGELOG.md",
23
24
  "Gemfile",
24
25
  "Gemfile.lock",
@@ -65,11 +66,11 @@ Gem::Specification.new do |s|
65
66
  "spec/support/sample_pages/update_inventory_result_from_page_1.html",
66
67
  "spec/support/sample_pages/update_inventory_result_from_page_2.html"
67
68
  ]
68
- s.homepage = %q{http://github.com/optoro/amazon_seller_central}
69
+ s.homepage = "http://github.com/optoro/amazon_seller_central"
69
70
  s.licenses = ["MIT"]
70
71
  s.require_paths = ["lib"]
71
- s.rubygems_version = %q{1.5.0}
72
- s.summary = %q{Ruby API to access Amazon's SellerCentral}
72
+ s.rubygems_version = "1.8.10"
73
+ s.summary = "Ruby API to access Amazon's SellerCentral"
73
74
 
74
75
  if s.respond_to? :specification_version then
75
76
  s.specification_version = 3
@@ -88,7 +89,7 @@ Gem::Specification.new do |s|
88
89
  s.add_development_dependency(%q<ffi>, [">= 0"])
89
90
  s.add_development_dependency(%q<faker>, [">= 0"])
90
91
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
91
- s.add_development_dependency(%q<ruby-debug>, [">= 0"])
92
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
92
93
  else
93
94
  s.add_dependency(%q<mechanize>, [">= 1.0.0"])
94
95
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
@@ -103,7 +104,7 @@ Gem::Specification.new do |s|
103
104
  s.add_dependency(%q<ffi>, [">= 0"])
104
105
  s.add_dependency(%q<faker>, [">= 0"])
105
106
  s.add_dependency(%q<fakeweb>, [">= 0"])
106
- s.add_dependency(%q<ruby-debug>, [">= 0"])
107
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
107
108
  end
108
109
  else
109
110
  s.add_dependency(%q<mechanize>, [">= 1.0.0"])
@@ -119,7 +120,7 @@ Gem::Specification.new do |s|
119
120
  s.add_dependency(%q<ffi>, [">= 0"])
120
121
  s.add_dependency(%q<faker>, [">= 0"])
121
122
  s.add_dependency(%q<fakeweb>, [">= 0"])
122
- s.add_dependency(%q<ruby-debug>, [">= 0"])
123
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
123
124
  end
124
125
  end
125
126
 
@@ -50,7 +50,7 @@ module AmazonSellerCentral
50
50
  def feedback_row_to_object(row)
51
51
  data = row.search('.//td').map(&:text)
52
52
  {
53
- :date => Time.parse(data[0]),
53
+ :date => parse_amazon_date(data[0]),
54
54
  :rating => data[1].to_i,
55
55
  :comments => data[2].gsub(/\n\nRespond$/,''),
56
56
  :arrived_on_time => yes_no_nil(data[3]),
@@ -65,15 +65,15 @@ module AmazonSellerCentral
65
65
  # 0 - hidden input of sku
66
66
  # 1 - checkbox itemOffer
67
67
  # 2 - actions
68
- # 3 - sku
69
- # 4 - asin
70
- # 5 - product name
71
- # 6 - date created
72
- # 7 - qty
73
- # 8 - condition
74
- # 9 - your price
75
- # 10 - low price
76
- # 11 - status
68
+ # 3 - status
69
+ # 4 - sku
70
+ # 5 - asin
71
+ # 6 - product name
72
+ # 7 - date created
73
+ # 8 - qty
74
+ # 9 - condition
75
+ # 10 - your price
76
+ # 11 - low price
77
77
  def listing_row_to_object(row)
78
78
  l = Listing.new
79
79
  row.css('td').each_with_index do |td, i|
@@ -81,23 +81,23 @@ module AmazonSellerCentral
81
81
  txt = td.text.strip # yes, slightly slower to do this here, but I type less.
82
82
 
83
83
  case i
84
- when 3
85
- l.sku = txt
86
84
  when 4
87
- l.asin = txt
85
+ l.sku = txt
88
86
  when 5
89
- l.product_name = txt
87
+ l.asin = txt
90
88
  when 6
91
- l.created_at = Time.parse(txt)
89
+ l.product_name = txt
92
90
  when 7
93
- l.quantity = (inputs = td.css('input')).any? ? inputs.first['value'].to_i : txt.to_i
91
+ l.created_at = parse_amazon_time(txt)
94
92
  when 8
95
- l.condition = txt
93
+ l.quantity = (inputs = td.css('input')).any? ? inputs.first['value'].to_i : txt.to_i
96
94
  when 9
97
- l.price = get_price(td)
95
+ l.condition = txt
98
96
  when 10
99
- l.low_price = get_low_price(td)
97
+ l.price = get_price(td)
100
98
  when 11
99
+ l.low_price = get_low_price(td)
100
+ when 3
101
101
  l.status = txt
102
102
  end
103
103
  end
@@ -23,5 +23,15 @@ module AmazonSellerCentral
23
23
  class NoNextPageAvailableError < StandardError
24
24
  end
25
25
 
26
+ protected
27
+ AZN_DATE_FMT = "%m/%d/%Y"
28
+ def parse_amazon_time(string)
29
+ Time.strptime(string, "#{AZN_DATE_FMT} %H:%M:%S")
30
+ end
31
+
32
+ def parse_amazon_date(string)
33
+ Time.strptime(string, AZN_DATE_FMT)
34
+ end
35
+
26
36
  end
27
37
  end
@@ -25,35 +25,25 @@ describe "InventoryPage" do
25
25
  listings = @first_page.listings
26
26
  listings.size.should == 250
27
27
 
28
- listings[46].sku.should == "PR53377-2"
29
- listings[46].asin.should == "B004ARVJSG"
30
- listings[46].product_name.should == "The Bathroom Trivia Digest"
31
- listings[46].created_at.should == Time.parse("2011-10-24 11:38:33")
32
- listings[46].quantity.should == 0
33
- listings[46].condition.should == "Used - Very Good"
34
- listings[46].price_cents.should == nil
35
- listings[46].low_price.should == nil
36
- listings[46].low_price_cents.should == nil
37
- listings[46].status.should == "Incomplete"
38
-
39
- listings[3].sku.should == "PR52534-3"
40
- listings[3].asin.should == "B002ONCCFW"
41
- listings[3].product_name.should == "Compaq CQ5210F Black Desktop PC (Windows 7 Home Premium)"
42
- listings[3].created_at.should == Time.parse("2011-10-24 16:38:28")
43
- listings[3].quantity.should == 1
44
- listings[3].condition.should == "Used - Good"
45
- listings[3].price_cents.should == 18749
46
- listings[3].status.should == "Active"
47
-
48
- listings[10].sku.should == "PR53292-2"
49
- listings[10].asin.should == "B003SX0JRK"
50
- listings[10].product_name.should == "Checkolite B1010-02 LED Flex Light, Green"
51
- listings[10].created_at.should == Time.parse("2011-10-24 15:36:17")
52
- listings[10].quantity.should == 5
53
- listings[10].condition.should == "Used - Very Good"
54
- listings[10].price_cents.should == 639
55
- #listings[10].low_price_cents.should == 10250
56
- listings[10].status.should == "Active"
28
+ listings[3].sku.should == "PR60079-2"
29
+ listings[3].asin.should == "B002746WPE"
30
+ listings[3].product_name.should == "Dell Latitude D810, D820, D830 Series 15.4inch WXGA LCD Screen [Electronics]"
31
+ listings[3].created_at.should == Time.parse("2011-12-01 10:18:35")
32
+ listings[3].quantity.should == 0
33
+ listings[3].condition.should == "Used - Very Good"
34
+ listings[3].price_cents.should == nil
35
+ listings[3].low_price.should == nil
36
+ listings[3].low_price_cents.should == nil
37
+ listings[3].status.should == "Incomplete"
38
+
39
+ listings[6].sku.should == "PR55562-11"
40
+ listings[6].asin.should == "B000WMHHL6"
41
+ listings[6].product_name.should == "Kodak K7600-C Li-Ion Universal Battery Charger [CD] [Camera]"
42
+ listings[6].created_at.should == Time.parse("2011-12-01 10:09:47")
43
+ listings[6].quantity.should == 1
44
+ listings[6].condition.should == "New"
45
+ listings[6].price_cents.should == 1899
46
+ listings[6].status.should == "Active"
57
47
  end
58
48
 
59
49
  # it "loads listings appropriately for another sample page" do
@@ -75,7 +65,7 @@ describe "InventoryPage" do
75
65
 
76
66
  it "accepts a set of Listing objects to apply updates to the page" do
77
67
  listings = @first_page.listings
78
- l = listings[3]
68
+ l = listings[6]
79
69
  # l.quantity = 0
80
70
  # l.price = 225.59
81
71
  l.quantity = 2
@@ -88,7 +78,7 @@ describe "InventoryPage" do
88
78
  (@first_page.instance_variable_get('@agent').last_page.parser.css('div#msg_saveSuccess')[0]['style'] !~ /display: none/).should be_true
89
79
 
90
80
  FakeWeb.register_uri(:get, 'https://sellercentral.amazon.com/gp/ezdpc-gui/inventory-status/status.html/ref=ag_invmgr_mmap_home', :response => mock_pages[:update_inventory_result_from_page_1])
91
- listing = AmazonSellerCentral::Inventory.load_first_page.listings[3]
81
+ listing = AmazonSellerCentral::Inventory.load_first_page.listings[6]
92
82
  listing.sku.should == l.sku
93
83
  listing.quantity.should == l.quantity
94
84
  listing.price.should == l.price
@@ -105,7 +95,7 @@ describe "InventoryPage" do
105
95
 
106
96
  it "raises an unsupported modification error when trying to apply listings twice" do
107
97
  listings = @first_page.listings
108
- l = listings[3]
98
+ l = listings[6]
109
99
  l.price = 24.26
110
100
  @first_page.apply_listings([l])
111
101
 
@@ -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("PR51341-2")
14
- listing.sku.should == "PR51341-2"
15
- listing.asin.should == "B003NE5JJW"
13
+ listing = @listing_set.find("PR37307-11")
14
+ listing.sku.should == "PR37307-11"
15
+ listing.asin.should == "B000YA1XU2"
16
16
  end
17
17
 
18
18
  it "allows find by asin" do
19
- listings = @listing_set.find("B0045JLPMY")
19
+ listings = @listing_set.find("B000RH3W9M")
20
20
  listings.should be_kind_of(Enumerable)
21
- listings.first.sku.should == "PR52729-3"
22
- listings.first.asin.should == "B0045JLPMY"
21
+ listings.first.sku.should == "PR48352-2"
22
+ listings.first.asin.should == "B000RH3W9M"
23
23
  end
24
24
 
25
25
  # it "allows where by quantity" do