mws-orders 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +3 -3
  4. data/lib/mws/orders/address.rb +38 -0
  5. data/lib/mws/orders/buyer_customized_info.rb +14 -0
  6. data/lib/mws/orders/buyer_tax_info.rb +23 -0
  7. data/lib/mws/orders/collection.rb +1 -0
  8. data/lib/mws/orders/document.rb +6 -4
  9. data/lib/mws/orders/entity.rb +26 -15
  10. data/lib/mws/orders/invoice_data.rb +5 -4
  11. data/lib/mws/orders/message.rb +3 -2
  12. data/lib/mws/orders/order.rb +82 -33
  13. data/lib/mws/orders/order_item.rb +67 -30
  14. data/lib/mws/orders/order_items.rb +1 -0
  15. data/lib/mws/orders/orders.rb +1 -0
  16. data/lib/mws/orders/parser.rb +6 -14
  17. data/lib/mws/orders/payment_execution_detail_item.rb +3 -2
  18. data/lib/mws/orders/points_granted.rb +18 -0
  19. data/lib/mws/orders/product_info.rb +14 -0
  20. data/lib/mws/orders/service_status.rb +4 -3
  21. data/lib/mws/orders/tax_classification.rb +18 -0
  22. data/lib/mws/orders/tax_collection.rb +18 -0
  23. data/lib/mws/orders/tokenable.rb +2 -2
  24. data/lib/mws/orders/version.rb +1 -1
  25. metadata +11 -38
  26. data/lib/mws/orders/payment_execution_detail.rb +0 -16
  27. data/lib/mws/orders/shipping_address.rb +0 -37
  28. data/test/fixtures/order_items.xml +0 -83
  29. data/test/fixtures/orders.xml +0 -112
  30. data/test/fixtures/service_status.xml +0 -19
  31. data/test/mws/orders/test_entity.rb +0 -96
  32. data/test/mws/orders/test_message.rb +0 -18
  33. data/test/mws/orders/test_order.rb +0 -99
  34. data/test/mws/orders/test_order_item.rb +0 -74
  35. data/test/mws/orders/test_order_items.rb +0 -21
  36. data/test/mws/orders/test_orders.rb +0 -21
  37. data/test/mws/orders/test_parser.rb +0 -9
  38. data/test/mws/orders/test_payment_execution_detail.rb +0 -19
  39. data/test/mws/orders/test_payment_execution_detail_item.rb +0 -19
  40. data/test/mws/orders/test_service_status.rb +0 -28
  41. data/test/mws/orders/test_shipping_address.rb +0 -37
  42. data/test/mws/orders/test_tokenable.rb +0 -33
  43. data/test/test_helper.rb +0 -19
@@ -1,109 +1,146 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'mws/orders/entity'
4
+ require 'mws/orders/buyer_customized_info'
4
5
  require 'mws/orders/invoice_data'
6
+ require 'mws/orders/points_granted'
7
+ require 'mws/orders/product_info'
8
+ require 'mws/orders/tax_collection'
5
9
 
6
10
  module MWS
7
11
  module Orders
12
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#OrderItem
8
13
  class OrderItem < Entity
9
14
  attribute(:asin) do
10
- text_at_xpath('ASIN')
15
+ string('ASIN')
16
+ end
17
+
18
+ attribute(:order_item_id) do
19
+ string('OrderItemId')
11
20
  end
12
21
 
13
22
  attribute(:seller_sku) do
14
- text_at_xpath('SellerSKU')
23
+ string('SellerSKU')
15
24
  end
16
25
 
17
- attribute(:order_item_id) do
18
- text_at_xpath('OrderItemId')
26
+ attribute(:buyer_customized_info) do
27
+ entity('BuyerCustomizedInfo', BuyerCustomizedInfo)
19
28
  end
20
29
 
21
30
  attribute(:title) do
22
- text_at_xpath('Title')
31
+ string('Title')
23
32
  end
24
33
 
25
34
  attribute(:quantity_ordered) do
26
- integer_at_xpath('QuantityOrdered')
35
+ integer('QuantityOrdered')
27
36
  end
28
37
 
29
38
  attribute(:quantity_shipped) do
30
- integer_at_xpath('QuantityShipped')
39
+ integer('QuantityShipped')
31
40
  end
32
41
 
33
- attribute(:gift_message_text) do
34
- text_at_xpath('GiftMessageText')
42
+ attribute(:points_granted) do
43
+ entity('PointsGranted', PointsGranted)
35
44
  end
36
45
 
37
- attribute(:gift_wrap_level) do
38
- text_at_xpath('GiftWrapLevel')
46
+ attribute(:product_info) do
47
+ entity('ProductInfo', ProductInfo)
39
48
  end
40
49
 
41
50
  attribute(:item_price) do
42
- money_at_xpath('ItemPrice')
51
+ money('ItemPrice')
43
52
  end
44
53
 
45
54
  attribute(:shipping_price) do
46
- money_at_xpath('ShippingPrice')
55
+ money('ShippingPrice')
47
56
  end
48
57
 
49
58
  attribute(:gift_wrap_price) do
50
- money_at_xpath('GiftWrapPrice')
59
+ money('GiftWrapPrice')
60
+ end
61
+
62
+ attribute(:tax_collection) do
63
+ entity('TaxCollection', TaxCollection)
51
64
  end
52
65
 
53
66
  attribute(:item_tax) do
54
- money_at_xpath('ItemTax')
67
+ money('ItemTax')
55
68
  end
56
69
 
57
70
  attribute(:shipping_tax) do
58
- money_at_xpath('ShippingTax')
71
+ money('ShippingTax')
59
72
  end
60
73
 
61
74
  attribute(:gift_wrap_tax) do
62
- money_at_xpath('GiftWrapPrice')
75
+ money('GiftWrapPrice')
63
76
  end
64
77
 
65
78
  attribute(:shipping_discount) do
66
- money_at_xpath('ShippingDiscount')
79
+ money('ShippingDiscount')
67
80
  end
68
81
 
69
82
  attribute(:promotion_discount) do
70
- money_at_xpath('PromotionDiscount')
83
+ money('PromotionDiscount')
71
84
  end
72
85
 
73
86
  attribute(:promotion_ids) do
74
- xpath('PromotionId').map(&:text)
87
+ xpath('PromotionIds').map(&:text)
75
88
  end
76
89
 
77
90
  attribute(:cod_fee) do
78
- money_at_xpath('CODFee')
91
+ money('CODFee')
79
92
  end
80
93
 
81
94
  attribute(:cod_fee_discount) do
82
- money_at_xpath('CODFeeDiscount')
95
+ money('CODFeeDiscount')
96
+ end
97
+
98
+ attribute(:gift?) do
99
+ boolean('IsGift')
100
+ end
101
+
102
+ attribute(:gift_message_text) do
103
+ string('GiftMessageText')
104
+ end
105
+
106
+ attribute(:gift_wrap_level) do
107
+ string('GiftWrapLevel')
83
108
  end
84
109
 
85
110
  attribute(:invoice_data) do
86
- xpath('InvoiceData').map { |node| InvoiceData.new(node) }
111
+ entity('InvoiceData', InvoiceData)
112
+ end
113
+
114
+ attribute(:condition_note) do
115
+ string('ConditionNote')
87
116
  end
88
117
 
89
118
  attribute(:condition_id) do
90
- text_at_xpath('ConditionId')
119
+ string('ConditionId')
91
120
  end
92
121
 
93
122
  attribute(:condition_subtype_id) do
94
- text_at_xpath('ConditionSubtypeId')
123
+ string('ConditionSubtypeId')
95
124
  end
96
125
 
97
- attribute(:condition_note) do
98
- text_at_xpath('ConditionNote')
126
+ attribute(:scheduled_delivery_starts_at) do
127
+ time('ScheduledDeliveryStartDate')
99
128
  end
100
129
 
101
130
  attribute(:scheduled_delivery_ends_at) do
102
- time_at_xpath('ScheduledDeliveryEndDate')
131
+ time('ScheduledDeliveryEndDate')
103
132
  end
104
133
 
105
- attribute(:scheduled_delivery_starts_at) do
106
- time_at_xpath('ScheduledDeliveryStartDate')
134
+ attribute(:price_designation) do
135
+ string('PriceDesignation')
136
+ end
137
+
138
+ attribute(:transparency?) do
139
+ boolean('IsTransparency')
140
+ end
141
+
142
+ attribute(:serial_number_required?) do
143
+ boolean('SerialNumberRequired')
107
144
  end
108
145
 
109
146
  def to_s
@@ -6,6 +6,7 @@ require 'mws/orders/tokenable'
6
6
 
7
7
  module MWS
8
8
  module Orders
9
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_ListOrderItems.html
9
10
  class OrderItems < Collection
10
11
  include Tokenable
11
12
 
@@ -6,6 +6,7 @@ require 'mws/orders/tokenable'
6
6
 
7
7
  module MWS
8
8
  module Orders
9
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_ListOrders.html
9
10
  class Orders < Collection
10
11
  include Tokenable
11
12
 
@@ -7,10 +7,15 @@ require 'mws/orders/service_status'
7
7
  require 'peddler'
8
8
 
9
9
  module MWS
10
+ # With the MWS Orders API, you can list orders created or updated during a
11
+ # time frame you specify or retrieve information about specific orders.
10
12
  module Orders
13
+ # Overrides the default parser in Peddler
11
14
  class Parser
12
15
  include ::Peddler::Headers
13
16
 
17
+ attr_reader :response
18
+
14
19
  def initialize(response, _encoding)
15
20
  @response = response
16
21
  end
@@ -25,18 +30,6 @@ module MWS
25
30
  end
26
31
  end
27
32
 
28
- def headers
29
- @response.headers
30
- end
31
-
32
- def status_code
33
- @response.status
34
- end
35
-
36
- def body
37
- @response.body
38
- end
39
-
40
33
  private
41
34
 
42
35
  def order
@@ -60,14 +53,13 @@ module MWS
60
53
  end
61
54
 
62
55
  def find_result_node
63
- xml = Nokogiri(body)
56
+ xml = Nokogiri(response.body)
64
57
  root = xml.children.first
65
58
 
66
59
  root.children.find { |node| node.name.include?('Result') }
67
60
  end
68
61
  end
69
62
 
70
- # Override Peddler's default Parser.
71
63
  Client.parser = Parser
72
64
  end
73
65
  end
@@ -4,13 +4,14 @@ require 'mws/orders/entity'
4
4
 
5
5
  module MWS
6
6
  module Orders
7
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#PaymentExecutionDetailItem
7
8
  class PaymentExecutionDetailItem < Entity
8
9
  attribute(:payment) do
9
- money_at_xpath('Payment')
10
+ money('Payment')
10
11
  end
11
12
 
12
13
  attribute(:payment_method) do
13
- text_at_xpath('PaymentMethod')
14
+ string('PaymentMethod')
14
15
  end
15
16
  end
16
17
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mws/orders/entity'
4
+
5
+ module MWS
6
+ module Orders
7
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#PointsGranted
8
+ class PointsGranted < Entity
9
+ attribute(:number) do
10
+ integer('PointsNumber')
11
+ end
12
+
13
+ attribute(:monetary_value) do
14
+ money('PointsMonetaryValue')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mws/orders/entity'
4
+
5
+ module MWS
6
+ module Orders
7
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#ProductInfo
8
+ class ProductInfo < Entity
9
+ attribute(:number_of_items) do
10
+ integer('NumberOfItems')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -5,17 +5,18 @@ require 'mws/orders/message'
5
5
 
6
6
  module MWS
7
7
  module Orders
8
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/MWS_GetServiceStatus.html
8
9
  class ServiceStatus < Entity
9
10
  attribute(:status) do
10
- text_at_xpath('Status')
11
+ string('Status')
11
12
  end
12
13
 
13
14
  attribute(:timestamp) do
14
- time_at_xpath('Timestamp')
15
+ time('Timestamp')
15
16
  end
16
17
 
17
18
  attribute(:message_id) do
18
- text_at_xpath('MessageId')
19
+ string('MessageId')
19
20
  end
20
21
 
21
22
  attribute(:messages) do
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mws/orders/entity'
4
+
5
+ module MWS
6
+ module Orders
7
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#TaxClassification
8
+ class TaxClassification < Entity
9
+ attribute :name do
10
+ string('Name')
11
+ end
12
+
13
+ attribute(:value) do
14
+ string('Value')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mws/orders/entity'
4
+
5
+ module MWS
6
+ module Orders
7
+ # https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#TaxCollection
8
+ class TaxCollection < Entity
9
+ attribute :model do
10
+ string('Model')
11
+ end
12
+
13
+ attribute(:responsible_party) do
14
+ string('ResponsibleParty')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,10 +2,10 @@
2
2
 
3
3
  module MWS
4
4
  module Orders
5
+ # https://docs.developer.amazonservices.com/en_US/dev_guide/DG_NextToken.html
5
6
  module Tokenable
6
7
  def next_token
7
- node = xpath('NextToken').first
8
- node&.text
8
+ at_xpath('NextToken')&.text
9
9
  end
10
10
  end
11
11
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MWS
4
4
  module Orders
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-28 00:00:00.000000000 Z
11
+ date: 2019-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -117,6 +117,9 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - LICENSE
119
119
  - README.md
120
+ - lib/mws/orders/address.rb
121
+ - lib/mws/orders/buyer_customized_info.rb
122
+ - lib/mws/orders/buyer_tax_info.rb
120
123
  - lib/mws/orders/collection.rb
121
124
  - lib/mws/orders/document.rb
122
125
  - lib/mws/orders/entity.rb
@@ -127,28 +130,14 @@ files:
127
130
  - lib/mws/orders/order_items.rb
128
131
  - lib/mws/orders/orders.rb
129
132
  - lib/mws/orders/parser.rb
130
- - lib/mws/orders/payment_execution_detail.rb
131
133
  - lib/mws/orders/payment_execution_detail_item.rb
134
+ - lib/mws/orders/points_granted.rb
135
+ - lib/mws/orders/product_info.rb
132
136
  - lib/mws/orders/service_status.rb
133
- - lib/mws/orders/shipping_address.rb
137
+ - lib/mws/orders/tax_classification.rb
138
+ - lib/mws/orders/tax_collection.rb
134
139
  - lib/mws/orders/tokenable.rb
135
140
  - lib/mws/orders/version.rb
136
- - test/fixtures/order_items.xml
137
- - test/fixtures/orders.xml
138
- - test/fixtures/service_status.xml
139
- - test/mws/orders/test_entity.rb
140
- - test/mws/orders/test_message.rb
141
- - test/mws/orders/test_order.rb
142
- - test/mws/orders/test_order_item.rb
143
- - test/mws/orders/test_order_items.rb
144
- - test/mws/orders/test_orders.rb
145
- - test/mws/orders/test_parser.rb
146
- - test/mws/orders/test_payment_execution_detail.rb
147
- - test/mws/orders/test_payment_execution_detail_item.rb
148
- - test/mws/orders/test_service_status.rb
149
- - test/mws/orders/test_shipping_address.rb
150
- - test/mws/orders/test_tokenable.rb
151
- - test/test_helper.rb
152
141
  homepage: https://github.com/hakanensari/mws-orders
153
142
  licenses:
154
143
  - MIT
@@ -171,21 +160,5 @@ requirements: []
171
160
  rubygems_version: 3.0.3
172
161
  signing_key:
173
162
  specification_version: 4
174
- summary: A Ruby wrapper for the Amazon MWS Orders API
175
- test_files:
176
- - test/mws/orders/test_orders.rb
177
- - test/mws/orders/test_order.rb
178
- - test/mws/orders/test_service_status.rb
179
- - test/mws/orders/test_shipping_address.rb
180
- - test/mws/orders/test_tokenable.rb
181
- - test/mws/orders/test_message.rb
182
- - test/mws/orders/test_payment_execution_detail_item.rb
183
- - test/mws/orders/test_order_items.rb
184
- - test/mws/orders/test_entity.rb
185
- - test/mws/orders/test_payment_execution_detail.rb
186
- - test/mws/orders/test_parser.rb
187
- - test/mws/orders/test_order_item.rb
188
- - test/fixtures/order_items.xml
189
- - test/fixtures/service_status.xml
190
- - test/fixtures/orders.xml
191
- - test/test_helper.rb
163
+ summary: A Ruby interface to the Amazon MWS Orders API, built on Peddler
164
+ test_files: []