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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +3 -3
- data/lib/mws/orders/address.rb +38 -0
- data/lib/mws/orders/buyer_customized_info.rb +14 -0
- data/lib/mws/orders/buyer_tax_info.rb +23 -0
- data/lib/mws/orders/collection.rb +1 -0
- data/lib/mws/orders/document.rb +6 -4
- data/lib/mws/orders/entity.rb +26 -15
- data/lib/mws/orders/invoice_data.rb +5 -4
- data/lib/mws/orders/message.rb +3 -2
- data/lib/mws/orders/order.rb +82 -33
- data/lib/mws/orders/order_item.rb +67 -30
- data/lib/mws/orders/order_items.rb +1 -0
- data/lib/mws/orders/orders.rb +1 -0
- data/lib/mws/orders/parser.rb +6 -14
- data/lib/mws/orders/payment_execution_detail_item.rb +3 -2
- data/lib/mws/orders/points_granted.rb +18 -0
- data/lib/mws/orders/product_info.rb +14 -0
- data/lib/mws/orders/service_status.rb +4 -3
- data/lib/mws/orders/tax_classification.rb +18 -0
- data/lib/mws/orders/tax_collection.rb +18 -0
- data/lib/mws/orders/tokenable.rb +2 -2
- data/lib/mws/orders/version.rb +1 -1
- metadata +11 -38
- data/lib/mws/orders/payment_execution_detail.rb +0 -16
- data/lib/mws/orders/shipping_address.rb +0 -37
- data/test/fixtures/order_items.xml +0 -83
- data/test/fixtures/orders.xml +0 -112
- data/test/fixtures/service_status.xml +0 -19
- data/test/mws/orders/test_entity.rb +0 -96
- data/test/mws/orders/test_message.rb +0 -18
- data/test/mws/orders/test_order.rb +0 -99
- data/test/mws/orders/test_order_item.rb +0 -74
- data/test/mws/orders/test_order_items.rb +0 -21
- data/test/mws/orders/test_orders.rb +0 -21
- data/test/mws/orders/test_parser.rb +0 -9
- data/test/mws/orders/test_payment_execution_detail.rb +0 -19
- data/test/mws/orders/test_payment_execution_detail_item.rb +0 -19
- data/test/mws/orders/test_service_status.rb +0 -28
- data/test/mws/orders/test_shipping_address.rb +0 -37
- data/test/mws/orders/test_tokenable.rb +0 -33
- data/test/test_helper.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b05f9a8f9c6d1b3eda7df105bd088572fbe93324682f9902f81a16aa7060b55f
|
4
|
+
data.tar.gz: 812d86fb8d5e6e4bdf8f5ad1b928394290f26a282b5f2eed67c8054da1d1cef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bcd1463e7bcdf91b937926079202a9ebc93ec783da4a459fcef869c65381b8ad935d654462a3397c7ed5145f55c306f6dff4cc7345096e77f96b6c438bc19d5
|
7
|
+
data.tar.gz: a8df5632bc2d3132680cdc9e9c45cb91d355400fae60a6479f8b248332ce9afc80623eb51f0262fec54075ffcc77694e43415770fc58b568654beeaa6607e2ea
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MWS Orders
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![CircleCI](https://circleci.com/gh/hakanensari/mws-orders.svg?style=svg)](https://circleci.com/gh/hakanensari/mws-orders)
|
4
4
|
|
5
5
|
**MWS Orders** is a full-featured Ruby interface to the [Amazon Marketplace Web Service (MWS) Orders API](http://docs.developer.amazonservices.com/en_UK/orders/index.html). With the MWS Orders API, you can list orders created or updated during a time frame you specify or retrieve information about specific orders.
|
6
6
|
|
@@ -26,7 +26,7 @@ List orders created or updated during a time frame you specify:
|
|
26
26
|
response = client.list_orders(created_after: 1.month.ago)
|
27
27
|
orders = response.parse
|
28
28
|
puts orders.count # => 100
|
29
|
-
|
29
|
+
orders.first.inspect # => #<MWS::Orders::Order 902-3159896-1390916>
|
30
30
|
)
|
31
31
|
```
|
32
32
|
|
@@ -41,7 +41,7 @@ Get one or more orders based on their order numbers:
|
|
41
41
|
```ruby
|
42
42
|
response = client.get_order('123-1234567-1234567')
|
43
43
|
order = response.parse
|
44
|
-
|
44
|
+
order.inspect # => #<MWS::Orders::Order 902-3159896-1390916>
|
45
45
|
```
|
46
46
|
|
47
47
|
### Order Items
|
@@ -0,0 +1,38 @@
|
|
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#Address
|
8
|
+
class Address < Entity
|
9
|
+
attribute(:name) do
|
10
|
+
string('Name')
|
11
|
+
end
|
12
|
+
|
13
|
+
attribute(:lines) do
|
14
|
+
1.upto(3).map { |i| string("AddressLine#{i}") }.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
attribute(:city) do
|
18
|
+
string('City')
|
19
|
+
end
|
20
|
+
|
21
|
+
attribute(:state_or_region) do
|
22
|
+
string('StateOrRegion')
|
23
|
+
end
|
24
|
+
|
25
|
+
attribute(:postal_code) do
|
26
|
+
string('PostalCode')
|
27
|
+
end
|
28
|
+
|
29
|
+
attribute(:country_code) do
|
30
|
+
string('CountryCode')
|
31
|
+
end
|
32
|
+
|
33
|
+
attribute(:phone) do
|
34
|
+
string('Phone')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
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#BuyerCustomizedInfo
|
8
|
+
class BuyerCustomizedInfo < Entity
|
9
|
+
attribute :customized_url do
|
10
|
+
string('CustomizedURL')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/orders/entity'
|
4
|
+
require 'mws/orders/tax_classification'
|
5
|
+
|
6
|
+
module MWS
|
7
|
+
module Orders
|
8
|
+
# https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#BuyerTaxInfo
|
9
|
+
class BuyerTaxInfo < Entity
|
10
|
+
attribute :company_legal_name do
|
11
|
+
string('CompanyLegalName')
|
12
|
+
end
|
13
|
+
|
14
|
+
attribute(:taxing_region) do
|
15
|
+
string('TaxingRegion')
|
16
|
+
end
|
17
|
+
|
18
|
+
attribute(:tax_classifications) do
|
19
|
+
entities('TaxClassifications/TaxClassification', TaxClassification)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/mws/orders/document.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
5
|
+
# Wraps a Nokogiri node
|
5
6
|
class Document
|
6
7
|
attr_reader :node
|
7
8
|
|
@@ -13,13 +14,14 @@ module MWS
|
|
13
14
|
node.xpath(add_namespace(path))
|
14
15
|
end
|
15
16
|
|
17
|
+
def at_xpath(path)
|
18
|
+
node.at_xpath(add_namespace(path))
|
19
|
+
end
|
20
|
+
|
16
21
|
private
|
17
22
|
|
18
23
|
def add_namespace(path)
|
19
|
-
path
|
20
|
-
.split('/')
|
21
|
-
.map { |attr| "xmlns:#{attr}" }
|
22
|
-
.join('/')
|
24
|
+
path.split('/').map { |attr| "xmlns:#{attr}" }.join('/')
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/mws/orders/entity.rb
CHANGED
@@ -8,37 +8,48 @@ require 'mws/orders/document'
|
|
8
8
|
|
9
9
|
module MWS
|
10
10
|
module Orders
|
11
|
+
# A parsed object
|
11
12
|
class Entity < Document
|
12
13
|
include Structure
|
13
14
|
|
14
|
-
def
|
15
|
-
|
16
|
-
text&.to_f
|
15
|
+
def boolean(path)
|
16
|
+
string(path) == 'true'
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
text&.to_i
|
19
|
+
def entities(path, klass)
|
20
|
+
xpath(path).map { |node| klass.new(node) }
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
23
|
+
def entity(path, klass)
|
24
|
+
node = at_xpath(path)
|
25
|
+
klass.new(node) if node
|
26
|
+
end
|
27
|
+
|
28
|
+
def float(path)
|
29
|
+
string(path)&.to_f
|
30
|
+
end
|
31
|
+
|
32
|
+
def integer(path)
|
33
|
+
string(path)&.to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
def money(path)
|
37
|
+
amount = float("#{path}/Amount")
|
26
38
|
return unless amount
|
27
39
|
|
28
|
-
currency_code =
|
40
|
+
currency_code = string("#{path}/CurrencyCode")
|
29
41
|
amount *= 100 unless currency_code == 'JPY'
|
30
42
|
|
31
43
|
Money.new(amount, currency_code)
|
32
44
|
end
|
33
45
|
|
34
|
-
def
|
35
|
-
|
36
|
-
Time.parse(CGI.unescape(text)) if text
|
46
|
+
def string(path)
|
47
|
+
at_xpath(path)&.text&.strip
|
37
48
|
end
|
38
49
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
50
|
+
def time(path)
|
51
|
+
text = string(path)
|
52
|
+
Time.parse(CGI.unescape(text)) if text
|
42
53
|
end
|
43
54
|
end
|
44
55
|
end
|
@@ -4,21 +4,22 @@ 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#InvoiceData
|
7
8
|
class InvoiceData < Entity
|
8
9
|
attribute(:invoice_requirement) do
|
9
|
-
|
10
|
+
string('InvoiceRequirement')
|
10
11
|
end
|
11
12
|
|
12
13
|
attribute(:buyer_selected_invoice_category) do
|
13
|
-
|
14
|
+
string('BuyerSelectedInvoiceCategory')
|
14
15
|
end
|
15
16
|
|
16
17
|
attribute(:invoice_title) do
|
17
|
-
|
18
|
+
string('InvoiceTitle')
|
18
19
|
end
|
19
20
|
|
20
21
|
attribute(:invoice_information) do
|
21
|
-
|
22
|
+
string('InvoiceInformation')
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/lib/mws/orders/message.rb
CHANGED
@@ -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/MWS_GetServiceStatus.html
|
7
8
|
class Message < Entity
|
8
9
|
attribute(:locale) do
|
9
|
-
|
10
|
+
string('Locale')
|
10
11
|
end
|
11
12
|
|
12
13
|
attribute(:text) do
|
13
|
-
|
14
|
+
string('Text')
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
data/lib/mws/orders/order.rb
CHANGED
@@ -1,116 +1,165 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'mws/orders/entity'
|
4
|
-
require 'mws/orders/
|
5
|
-
require 'mws/orders/
|
4
|
+
require 'mws/orders/address'
|
5
|
+
require 'mws/orders/buyer_tax_info'
|
6
|
+
require 'mws/orders/payment_execution_detail_item'
|
6
7
|
|
7
8
|
module MWS
|
8
9
|
module Orders
|
10
|
+
# https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#Order
|
9
11
|
class Order < Entity
|
10
12
|
attribute(:amazon_order_id) do
|
11
|
-
|
13
|
+
string('AmazonOrderId')
|
12
14
|
end
|
13
15
|
|
14
16
|
attribute(:seller_order_id) do
|
15
|
-
|
17
|
+
string('SellerOrderId')
|
16
18
|
end
|
17
19
|
|
18
20
|
attribute(:purchased_at) do
|
19
|
-
|
21
|
+
time('PurchaseDate')
|
20
22
|
end
|
21
23
|
|
22
24
|
attribute(:last_updated_at) do
|
23
|
-
|
25
|
+
time('LastUpdateDate')
|
24
26
|
end
|
25
27
|
|
26
28
|
attribute(:status) do
|
27
|
-
|
29
|
+
string('OrderStatus')
|
28
30
|
end
|
29
31
|
|
30
32
|
attribute(:fulfillment_channel) do
|
31
|
-
|
33
|
+
string('FulfillmentChannel')
|
32
34
|
end
|
33
35
|
|
34
36
|
attribute(:sales_channel) do
|
35
|
-
|
37
|
+
string('SalesChannel')
|
36
38
|
end
|
37
39
|
|
38
40
|
attribute(:order_channel) do
|
39
|
-
|
41
|
+
string('OrderChannel')
|
40
42
|
end
|
41
43
|
|
42
44
|
attribute(:ship_service_level) do
|
43
|
-
|
45
|
+
string('ShipServiceLevel')
|
44
46
|
end
|
45
47
|
|
46
48
|
attribute(:shipping_address) do
|
47
|
-
|
48
|
-
ShippingAddress.new(node) if node
|
49
|
+
entity('ShippingAddress', Address)
|
49
50
|
end
|
50
51
|
|
51
52
|
attribute(:total) do
|
52
|
-
|
53
|
+
money('OrderTotal')
|
53
54
|
end
|
54
55
|
|
55
56
|
attribute(:number_of_items_shipped) do
|
56
|
-
|
57
|
+
integer('NumberOfItemsShipped')
|
57
58
|
end
|
58
59
|
|
59
60
|
attribute(:number_of_items_unshipped) do
|
60
|
-
|
61
|
+
integer('NumberOfItemsUnshipped')
|
61
62
|
end
|
62
63
|
|
63
64
|
attribute(:payment_execution_detail) do
|
64
|
-
|
65
|
-
|
65
|
+
xpath('PaymentExecutionDetail/PaymentExecutionDetailItem')
|
66
|
+
.map { |node| PaymentExecutionDetailItem.new(node) }
|
66
67
|
end
|
67
68
|
|
68
69
|
attribute(:payment_method) do
|
69
|
-
|
70
|
+
string('PaymentMethod')
|
71
|
+
end
|
72
|
+
|
73
|
+
attribute(:payment_method_details) do
|
74
|
+
xpath('PaymentMethodDetails/PaymentMethodDetail').map(&:text)
|
75
|
+
end
|
76
|
+
|
77
|
+
attribute(:replacement_order?) do
|
78
|
+
boolean('IsReplacementOrder')
|
79
|
+
end
|
80
|
+
|
81
|
+
attribute(:replaced_order_id) do
|
82
|
+
string('ReplacedOrderId')
|
70
83
|
end
|
71
84
|
|
72
85
|
attribute(:marketplace_id) do
|
73
|
-
|
86
|
+
string('MarketplaceId')
|
87
|
+
end
|
88
|
+
|
89
|
+
attribute(:buyer_email) do
|
90
|
+
string('BuyerEmail')
|
74
91
|
end
|
75
92
|
|
76
93
|
attribute(:buyer_name) do
|
77
|
-
|
94
|
+
string('BuyerName')
|
78
95
|
end
|
79
96
|
|
80
|
-
attribute(:
|
81
|
-
|
97
|
+
attribute(:buyer_county) do
|
98
|
+
string('BuyerCounty')
|
82
99
|
end
|
83
100
|
|
84
|
-
attribute(:
|
85
|
-
|
101
|
+
attribute(:buyer_tax_info) do
|
102
|
+
entity('BuyerTaxInfo', BuyerTaxInfo)
|
86
103
|
end
|
87
104
|
|
88
|
-
attribute(:
|
89
|
-
|
105
|
+
attribute(:shipment_service_level_category) do
|
106
|
+
string('ShipmentServiceLevelCategory')
|
90
107
|
end
|
91
108
|
|
92
109
|
attribute(:shipped_by_amazon_tfm) do
|
93
|
-
|
110
|
+
string('ShippedByAmazonTFM')
|
94
111
|
end
|
95
112
|
|
96
113
|
attribute(:tfm_shipment_status) do
|
97
|
-
|
114
|
+
string('TFMShipmentStatus')
|
115
|
+
end
|
116
|
+
|
117
|
+
attribute(:easy_ship_shipment_status) do
|
118
|
+
string('EasyShipShipmentStatus')
|
98
119
|
end
|
99
120
|
|
100
121
|
attribute(:type) do
|
101
|
-
|
122
|
+
string('OrderType')
|
102
123
|
end
|
103
124
|
|
104
125
|
attribute(:earliest_shipped_at) do
|
105
|
-
|
126
|
+
time('EarliestShipDate')
|
106
127
|
end
|
107
128
|
|
108
129
|
attribute(:latest_shipped_at) do
|
109
|
-
|
130
|
+
time('LatestShipDate')
|
131
|
+
end
|
132
|
+
|
133
|
+
attribute(:earliest_delivered_at) do
|
134
|
+
time('LatestDeliveryDate')
|
110
135
|
end
|
111
136
|
|
112
137
|
attribute(:latest_delivered_at) do
|
113
|
-
|
138
|
+
time('LatestDeliveryDate')
|
139
|
+
end
|
140
|
+
|
141
|
+
attribute(:business_order?) do
|
142
|
+
boolean('IsBusinessOrder')
|
143
|
+
end
|
144
|
+
|
145
|
+
attribute(:purchase_order_number) do
|
146
|
+
string('PurchaseOrderNumber')
|
147
|
+
end
|
148
|
+
|
149
|
+
attribute(:prime?) do
|
150
|
+
boolean('IsPrime')
|
151
|
+
end
|
152
|
+
|
153
|
+
attribute(:premium?) do
|
154
|
+
boolean('IsPremiumOrder')
|
155
|
+
end
|
156
|
+
|
157
|
+
attribute(:promise_response_due_at) do
|
158
|
+
time('PromiseResponseDueDate')
|
159
|
+
end
|
160
|
+
|
161
|
+
attribute(:estimated_ship_date_set?) do
|
162
|
+
boolean('IsEstimatedShipDateSet')
|
114
163
|
end
|
115
164
|
|
116
165
|
def to_s
|