mws-orders 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a19c5ef1c9834c6008a1618a7e2b9740dbc264d6
4
- data.tar.gz: d7a3b54bdeb81dd00380076535e869747e46b71f
3
+ metadata.gz: ae7156d5c979b3ae713f0f09741403ddd77a5fd6
4
+ data.tar.gz: 29d588ed4d4bb2742e19c5b29c0fcd2e53ad0b6a
5
5
  SHA512:
6
- metadata.gz: 36ea87627bac392e57c5e6abd92ecc2e6beee64d3b38458a9a8e6ddb4b5f278de30d160569099c6fc3ee50a51d81d20d61d6e2ea44c89a9d77e001984384cf04
7
- data.tar.gz: ab91b32c50a02f8f964c1f4bb94753a26801b1d6ed8a0b648a63fae4b4bb731efefbdcf347cb4deddfc7a957670917e034604a810033ae4f0c777db0774b0abb
6
+ metadata.gz: eb08511c0f4cdb639cb4f98e750e6cd8cbfd9c487c0f07a3101b9f1c67f345b9e7686b62eeeef9372d312e00b0b45f671e2e5bb255be99ac4b3073c09c81e612
7
+ data.tar.gz: 3dee6e2ca99790d8a4c6f6b243defee158a09f22696e7ae8aceb8deaf0b43f0379bc339c152a0348c994b33853647350dac09f5090cb1b593f590486c685ffbd
@@ -1,10 +1,6 @@
1
- require "structure"
2
-
3
1
  module MWS
4
2
  module Orders
5
3
  class Document
6
- include Structure
7
-
8
4
  attr_reader :node
9
5
 
10
6
  def initialize(node)
@@ -1,11 +1,14 @@
1
1
  require "cgi"
2
2
  require "time"
3
3
  require "money"
4
+ require "structure"
4
5
  require "mws/orders/document"
5
6
 
6
7
  module MWS
7
8
  module Orders
8
9
  class Entity < Document
10
+ include Structure
11
+
9
12
  def float_at_xpath(path)
10
13
  text = text_at_xpath(path)
11
14
  text.to_f if text
@@ -2,7 +2,7 @@ module MWS
2
2
  module Orders
3
3
  module Tokenable
4
4
  def next_token
5
- node = xpath('NextToken')
5
+ node = xpath('NextToken').first
6
6
  node.text if node
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  module MWS
2
2
  module Orders
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,8 +1,8 @@
1
1
  require "test_helper"
2
2
 
3
- class TestIntegration < MiniTest::Test
3
+ class TestMWSOrders < MiniTest::Test
4
4
  def setup
5
- skip if ENV['CI']
5
+ skip unless ENV['AWS_ACCESS_KEY_ID']
6
6
  @client = MWS.orders
7
7
  end
8
8
 
@@ -10,17 +10,18 @@ class TestIntegration < MiniTest::Test
10
10
  assert_kind_of ServiceStatus, @client.get_service_status
11
11
  end
12
12
 
13
- def test_lists_orders_and_order_items
14
- orders = @client.list_orders(created_after: Date.today - 30)
13
+ def test_lists_orders_and_their_items
14
+ orders = @client.list_orders(created_after: one_year_ago)
15
15
  refute_empty orders
16
-
17
- next_orders = @client.list_orders_by_next_token(orders.next_token)
18
- refute_empty orders
19
-
20
- amazon_order_id = next_orders.to_a.sample.amazon_order_id
16
+ amazon_order_id = orders.to_a.sample.amazon_order_id
21
17
  assert_kind_of MWS::Orders::Order, @client.get_order(amazon_order_id)
22
-
23
18
  order_items = @client.list_order_items(amazon_order_id)
24
19
  refute_empty order_items
25
20
  end
21
+
22
+ private
23
+
24
+ def one_year_ago
25
+ Date.today - 365
26
+ end
26
27
  end
@@ -5,7 +5,7 @@ class TestEntity < MiniTest::Test
5
5
  xml = <<-EOF
6
6
  <Float xmlns="example">10.0</Float>
7
7
  EOF
8
- entity = Entity.new(Nokogiri(xml))
8
+ entity= build_entity(xml)
9
9
  float = entity.float_at_xpath("Float")
10
10
  assert_equal 10.0, float
11
11
  end
@@ -14,7 +14,7 @@ class TestEntity < MiniTest::Test
14
14
  xml = <<-EOF
15
15
  <Integer xmlns="example">10</Integer>
16
16
  EOF
17
- entity = Entity.new(Nokogiri(xml))
17
+ entity= build_entity(xml)
18
18
  integer = entity.integer_at_xpath("Integer")
19
19
  assert_equal 10, integer
20
20
  end
@@ -26,7 +26,7 @@ class TestEntity < MiniTest::Test
26
26
  <Amount>10.00</Amount>
27
27
  </Price>
28
28
  EOF
29
- entity = Entity.new(Nokogiri(xml))
29
+ entity= build_entity(xml)
30
30
  money = entity.money_at_xpath("Price")
31
31
  assert_equal "$10.00", money.format
32
32
  end
@@ -38,7 +38,7 @@ class TestEntity < MiniTest::Test
38
38
  <Amount>1000.00</Amount>
39
39
  </Price>
40
40
  EOF
41
- entity = Entity.new(Nokogiri(xml))
41
+ entity= build_entity(xml)
42
42
  money = entity.money_at_xpath("Price")
43
43
  assert_equal "¥1,000", money.format
44
44
  end
@@ -47,7 +47,7 @@ class TestEntity < MiniTest::Test
47
47
  xml = <<-EOF
48
48
  <Text xmlns="example">Foo</Text>
49
49
  EOF
50
- entity = Entity.new(Nokogiri(xml))
50
+ entity= build_entity(xml)
51
51
  text = entity.text_at_xpath("Text")
52
52
  assert_equal "Foo", text
53
53
  end
@@ -58,7 +58,7 @@ class TestEntity < MiniTest::Test
58
58
 
59
59
  </Text>
60
60
  EOF
61
- entity = Entity.new(Nokogiri(xml))
61
+ entity= build_entity(xml)
62
62
  text = entity.text_at_xpath("Text")
63
63
  assert_equal "Foo", text
64
64
  end
@@ -67,7 +67,7 @@ class TestEntity < MiniTest::Test
67
67
  xml = <<-EOF
68
68
  <Time xmlns="example">2013-01-01T01:30:00.000-06:00</Time>
69
69
  EOF
70
- entity = Entity.new(Nokogiri(xml))
70
+ entity= build_entity(xml)
71
71
  time = entity.time_at_xpath("Time")
72
72
  assert_kind_of Time, time
73
73
  end
@@ -77,7 +77,7 @@ class TestEntity < MiniTest::Test
77
77
  <Foo xmlns="example">
78
78
  </Foo>
79
79
  EOF
80
- entity = Entity.new(Nokogiri(xml))
80
+ entity= build_entity(xml)
81
81
 
82
82
  assert_nil entity.float_at_xpath("Bar")
83
83
  assert_nil entity.integer_at_xpath("Bar")
@@ -85,4 +85,10 @@ class TestEntity < MiniTest::Test
85
85
  assert_nil entity.time_at_xpath("Bar")
86
86
  assert_nil entity.text_at_xpath("Bar")
87
87
  end
88
+
89
+ private
90
+
91
+ def build_entity(xml)
92
+ Entity.new(Nokogiri(xml))
93
+ end
88
94
  end
@@ -0,0 +1,31 @@
1
+ require "test_helper"
2
+
3
+ class TestTokenable < MiniTest::Test
4
+ def test_parses_next_token
5
+ xml = <<-EOF
6
+ <NextToken xmlns="example">123</NextToken>
7
+ EOF
8
+ tokenable = build_tokenable(xml)
9
+
10
+ assert_equal "123", tokenable.next_token
11
+ end
12
+
13
+ def test_returns_nil_if_next_token_is_not_present
14
+ xml = <<-EOF
15
+ <Foo xmlns="example"/>
16
+ EOF
17
+ tokenable = build_tokenable(xml)
18
+
19
+ refute tokenable.next_token
20
+ end
21
+
22
+ private
23
+
24
+ def build_tokenable(xml)
25
+ klass = Class.new(Collection) do
26
+ include Tokenable
27
+ end
28
+
29
+ klass.new(Nokogiri(xml))
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mws-orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2015-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: peddler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.9.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.2
55
55
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.29.0
69
- description: A Ruby interface to the Amazon MWS Orders API
69
+ description: A rich Ruby interface to the Amazon MWS Orders API
70
70
  email:
71
71
  - me@hakanensari.com
72
72
  executables: []
@@ -92,11 +92,10 @@ files:
92
92
  - lib/mws/orders/shipping_address.rb
93
93
  - lib/mws/orders/tokenable.rb
94
94
  - lib/mws/orders/version.rb
95
- - test/fixtures/mws.yml.example
96
95
  - test/fixtures/order_items.xml
97
96
  - test/fixtures/orders.xml
98
97
  - test/fixtures/service_status.xml
99
- - test/integration/test_integration.rb
98
+ - test/integration/test_mws_orders.rb
100
99
  - test/mws/orders/test_entity.rb
101
100
  - test/mws/orders/test_order.rb
102
101
  - test/mws/orders/test_order_item.rb
@@ -108,6 +107,7 @@ files:
108
107
  - test/mws/orders/test_service_status.rb
109
108
  - test/mws/orders/test_service_status_message.rb
110
109
  - test/mws/orders/test_shipping_address.rb
110
+ - test/mws/orders/test_tokenable.rb
111
111
  - test/test_helper.rb
112
112
  homepage: http://github.com/hakanensari/mws-orders
113
113
  licenses:
@@ -129,16 +129,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.3.0
132
+ rubygems_version: 2.4.5
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Wraps the Amazon MWS Orders API
136
136
  test_files:
137
- - test/fixtures/mws.yml.example
138
137
  - test/fixtures/order_items.xml
139
138
  - test/fixtures/orders.xml
140
139
  - test/fixtures/service_status.xml
141
- - test/integration/test_integration.rb
140
+ - test/integration/test_mws_orders.rb
142
141
  - test/mws/orders/test_entity.rb
143
142
  - test/mws/orders/test_order.rb
144
143
  - test/mws/orders/test_order_item.rb
@@ -150,5 +149,6 @@ test_files:
150
149
  - test/mws/orders/test_service_status.rb
151
150
  - test/mws/orders/test_service_status_message.rb
152
151
  - test/mws/orders/test_shipping_address.rb
152
+ - test/mws/orders/test_tokenable.rb
153
153
  - test/test_helper.rb
154
154
  has_rdoc:
@@ -1,4 +0,0 @@
1
- - country: GB
2
- aws_access_key_id: foo
3
- aws_secret_access_key: bar
4
- seller_id: baz