mws-orders 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mws-orders.rb +2 -2
- data/lib/mws/orders/collection.rb +8 -10
- data/lib/mws/orders/document.rb +2 -2
- data/lib/mws/orders/entity.rb +8 -7
- data/lib/mws/orders/invoice_data.rb +5 -5
- data/lib/mws/orders/order.rb +31 -33
- data/lib/mws/orders/order_item.rb +27 -27
- data/lib/mws/orders/order_items.rb +5 -5
- data/lib/mws/orders/orders.rb +5 -5
- data/lib/mws/orders/parser.rb +5 -5
- data/lib/mws/orders/payment_execution_detail.rb +4 -4
- data/lib/mws/orders/payment_execution_detail_item.rb +3 -3
- data/lib/mws/orders/service_status.rb +6 -6
- data/lib/mws/orders/service_status_message.rb +3 -3
- data/lib/mws/orders/shipping_address.rb +7 -7
- data/lib/mws/orders/version.rb +1 -1
- data/test/integration/test_mws_orders.rb +1 -1
- data/test/mws/orders/test_entity.rb +25 -25
- data/test/mws/orders/test_order.rb +4 -4
- data/test/mws/orders/test_order_item.rb +2 -2
- data/test/mws/orders/test_order_items.rb +2 -2
- data/test/mws/orders/test_orders.rb +2 -2
- data/test/mws/orders/test_parser.rb +1 -1
- data/test/mws/orders/test_payment_execution_detail.rb +2 -2
- data/test/mws/orders/test_payment_execution_detail_item.rb +2 -2
- data/test/mws/orders/test_service_status.rb +2 -2
- data/test/mws/orders/test_service_status_message.rb +2 -2
- data/test/mws/orders/test_shipping_address.rb +2 -2
- data/test/mws/orders/test_tokenable.rb +2 -2
- data/test/test_helper.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec20ee7a6a68c18970939fe3d7ceb04ce88136f
|
4
|
+
data.tar.gz: e9ecd3b7c72d0374df6a0f4fef03434c6ef9dea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbc9aabc78da68b32f23d60d56e796dfc5649f77873c8f79b16521d0a66da36be7f6d5a39a7c17786f635d6e9aaa1c490120a4dba701a2cee3cb1165d6c0d23
|
7
|
+
data.tar.gz: b7502ca5ac44132c8168c91c83bbfb0938ed7bb1326a349ec88d3d6f3cee1e1eebea477ee11c87eb7823a0c32c97b459f1d49e7568f9164c31cce93c583a9286
|
data/lib/mws-orders.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'peddler'
|
2
|
+
require 'mws/orders/parser'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'mws/orders/document'
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
@@ -10,20 +10,18 @@ module MWS
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def empty?
|
13
|
-
count
|
13
|
+
count.zero?
|
14
14
|
end
|
15
15
|
|
16
16
|
def inspect
|
17
|
-
"#<#{self.class} #{
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
}>"
|
17
|
+
"#<#{self.class} #{if count > 3
|
18
|
+
"[#{take(3).map(&:inspect).join(', ')}...]"
|
19
|
+
else
|
20
|
+
"[#{map(&:inspect).join(', ')}]"
|
21
|
+
end}>"
|
24
22
|
end
|
25
23
|
|
26
|
-
|
24
|
+
alias to_s inspect
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/mws/orders/document.rb
CHANGED
data/lib/mws/orders/entity.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'cgi'
|
2
|
+
require 'time'
|
3
|
+
require 'money'
|
4
|
+
require 'structure'
|
5
|
+
require 'mws/orders/document'
|
6
6
|
|
7
7
|
module MWS
|
8
8
|
module Orders
|
@@ -20,10 +20,11 @@ module MWS
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def money_at_xpath(path)
|
23
|
-
|
23
|
+
amount = float_at_xpath("#{path}/Amount")
|
24
|
+
return unless amount
|
24
25
|
|
25
26
|
currency_code = text_at_xpath("#{path}/CurrencyCode")
|
26
|
-
amount
|
27
|
+
amount *= 100 unless currency_code == 'JPY'
|
27
28
|
|
28
29
|
Money.new(amount, currency_code)
|
29
30
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
5
5
|
class InvoiceData < Entity
|
6
6
|
attribute(:invoice_requirement) do
|
7
|
-
text_at_xpath(
|
7
|
+
text_at_xpath('InvoiceRequirement')
|
8
8
|
end
|
9
9
|
|
10
10
|
attribute(:buyer_selected_invoice_category) do
|
11
|
-
text_at_xpath(
|
11
|
+
text_at_xpath('BuyerSelectedInvoiceCategory')
|
12
12
|
end
|
13
13
|
|
14
14
|
attribute(:invoice_title) do
|
15
|
-
text_at_xpath(
|
15
|
+
text_at_xpath('InvoiceTitle')
|
16
16
|
end
|
17
17
|
|
18
18
|
attribute(:invoice_information) do
|
19
|
-
text_at_xpath(
|
19
|
+
text_at_xpath('InvoiceInformation')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/mws/orders/order.rb
CHANGED
@@ -1,115 +1,113 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
|
+
require 'mws/orders/shipping_address'
|
3
|
+
require 'mws/orders/payment_execution_detail'
|
4
4
|
|
5
5
|
module MWS
|
6
6
|
module Orders
|
7
7
|
class Order < Entity
|
8
8
|
attribute(:amazon_order_id) do
|
9
|
-
text_at_xpath(
|
9
|
+
text_at_xpath('AmazonOrderId')
|
10
10
|
end
|
11
11
|
|
12
12
|
attribute(:seller_order_id) do
|
13
|
-
text_at_xpath(
|
13
|
+
text_at_xpath('SellerOrderId')
|
14
14
|
end
|
15
15
|
|
16
16
|
attribute(:purchased_at) do
|
17
|
-
time_at_xpath(
|
17
|
+
time_at_xpath('PurchaseDate')
|
18
18
|
end
|
19
19
|
|
20
20
|
attribute(:last_updated_at) do
|
21
|
-
time_at_xpath(
|
21
|
+
time_at_xpath('LastUpdateDate')
|
22
22
|
end
|
23
23
|
|
24
24
|
attribute(:status) do
|
25
|
-
text_at_xpath(
|
25
|
+
text_at_xpath('OrderStatus')
|
26
26
|
end
|
27
27
|
|
28
28
|
attribute(:fulfillment_channel) do
|
29
|
-
text_at_xpath(
|
29
|
+
text_at_xpath('FulfillmentChannel')
|
30
30
|
end
|
31
31
|
|
32
32
|
attribute(:sales_channel) do
|
33
|
-
text_at_xpath(
|
33
|
+
text_at_xpath('SalesChannel')
|
34
34
|
end
|
35
35
|
|
36
36
|
attribute(:order_channel) do
|
37
|
-
text_at_xpath(
|
37
|
+
text_at_xpath('OrderChannel')
|
38
38
|
end
|
39
39
|
|
40
40
|
attribute(:ship_service_level) do
|
41
|
-
text_at_xpath(
|
41
|
+
text_at_xpath('ShipServiceLevel')
|
42
42
|
end
|
43
43
|
|
44
44
|
attribute(:shipping_address) do
|
45
|
-
|
46
|
-
|
47
|
-
end
|
45
|
+
node = xpath('ShippingAddress').first
|
46
|
+
ShippingAddress.new(node) if node
|
48
47
|
end
|
49
48
|
|
50
49
|
attribute(:total) do
|
51
|
-
money_at_xpath(
|
50
|
+
money_at_xpath('OrderTotal')
|
52
51
|
end
|
53
52
|
|
54
53
|
attribute(:number_of_items_shipped) do
|
55
|
-
integer_at_xpath(
|
54
|
+
integer_at_xpath('NumberOfItemsShipped')
|
56
55
|
end
|
57
56
|
|
58
57
|
attribute(:number_of_items_unshipped) do
|
59
|
-
integer_at_xpath(
|
58
|
+
integer_at_xpath('NumberOfItemsUnshipped')
|
60
59
|
end
|
61
60
|
|
62
61
|
attribute(:payment_execution_detail) do
|
63
|
-
|
64
|
-
|
65
|
-
end
|
62
|
+
node = xpath('PaymentExecutionDetail').first
|
63
|
+
PaymentExecutionDetail.new(node) if node
|
66
64
|
end
|
67
65
|
|
68
66
|
attribute(:payment_method) do
|
69
|
-
text_at_xpath(
|
67
|
+
text_at_xpath('PaymentMethod')
|
70
68
|
end
|
71
69
|
|
72
70
|
attribute(:marketplace_id) do
|
73
|
-
text_at_xpath(
|
71
|
+
text_at_xpath('MarketplaceId')
|
74
72
|
end
|
75
73
|
|
76
74
|
attribute(:buyer_name) do
|
77
|
-
text_at_xpath(
|
75
|
+
text_at_xpath('BuyerName')
|
78
76
|
end
|
79
77
|
|
80
78
|
attribute(:buyer_email) do
|
81
|
-
text_at_xpath(
|
79
|
+
text_at_xpath('BuyerEmail')
|
82
80
|
end
|
83
81
|
|
84
82
|
attribute(:shipment_service_level_category) do
|
85
|
-
text_at_xpath(
|
83
|
+
text_at_xpath('ShipmentServiceLevelCategory')
|
86
84
|
end
|
87
85
|
|
88
86
|
attribute(:cba_displayable_shipping_label) do
|
89
|
-
text_at_xpath(
|
87
|
+
text_at_xpath('CbaDisplayableShippingLabel')
|
90
88
|
end
|
91
89
|
|
92
90
|
attribute(:shipped_by_amazon_tfm) do
|
93
|
-
text_at_xpath(
|
91
|
+
text_at_xpath('ShippedByAmazonTFM')
|
94
92
|
end
|
95
93
|
|
96
94
|
attribute(:tfm_shipment_status) do
|
97
|
-
text_at_xpath(
|
95
|
+
text_at_xpath('TFMShipmentStatus')
|
98
96
|
end
|
99
97
|
|
100
98
|
attribute(:type) do
|
101
|
-
text_at_xpath(
|
99
|
+
text_at_xpath('OrderType')
|
102
100
|
end
|
103
101
|
|
104
102
|
attribute(:earliest_shipped_at) do
|
105
|
-
time_at_xpath(
|
103
|
+
time_at_xpath('EarliestShipDate')
|
106
104
|
end
|
107
105
|
|
108
106
|
attribute(:latest_shipped_at) do
|
109
|
-
time_at_xpath(
|
107
|
+
time_at_xpath('LatestShipDate')
|
110
108
|
end
|
111
109
|
|
112
|
-
attribute(:
|
110
|
+
attribute(:latest_delivered_at) do
|
113
111
|
time_at_xpath('LatestDeliveryDate')
|
114
112
|
end
|
115
113
|
end
|
@@ -1,107 +1,107 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
|
+
require 'mws/orders/invoice_data'
|
3
3
|
|
4
4
|
module MWS
|
5
5
|
module Orders
|
6
6
|
class OrderItem < Entity
|
7
7
|
attribute(:asin) do
|
8
|
-
text_at_xpath(
|
8
|
+
text_at_xpath('ASIN')
|
9
9
|
end
|
10
10
|
|
11
11
|
attribute(:seller_sku) do
|
12
|
-
text_at_xpath(
|
12
|
+
text_at_xpath('SellerSKU')
|
13
13
|
end
|
14
14
|
|
15
15
|
attribute(:order_item_id) do
|
16
|
-
text_at_xpath(
|
16
|
+
text_at_xpath('OrderItemId')
|
17
17
|
end
|
18
18
|
|
19
19
|
attribute(:title) do
|
20
|
-
text_at_xpath(
|
20
|
+
text_at_xpath('Title')
|
21
21
|
end
|
22
22
|
|
23
23
|
attribute(:quantity_ordered) do
|
24
|
-
integer_at_xpath(
|
24
|
+
integer_at_xpath('QuantityOrdered')
|
25
25
|
end
|
26
26
|
|
27
27
|
attribute(:quantity_shipped) do
|
28
|
-
integer_at_xpath(
|
28
|
+
integer_at_xpath('QuantityShipped')
|
29
29
|
end
|
30
30
|
|
31
31
|
attribute(:gift_message_text) do
|
32
|
-
text_at_xpath(
|
32
|
+
text_at_xpath('GiftMessageText')
|
33
33
|
end
|
34
34
|
|
35
35
|
attribute(:gift_wrap_level) do
|
36
|
-
text_at_xpath(
|
36
|
+
text_at_xpath('GiftWrapLevel')
|
37
37
|
end
|
38
38
|
|
39
39
|
attribute(:item_price) do
|
40
|
-
money_at_xpath(
|
40
|
+
money_at_xpath('ItemPrice')
|
41
41
|
end
|
42
42
|
|
43
43
|
attribute(:shipping_price) do
|
44
|
-
money_at_xpath(
|
44
|
+
money_at_xpath('ShippingPrice')
|
45
45
|
end
|
46
46
|
|
47
47
|
attribute(:gift_wrap_price) do
|
48
|
-
money_at_xpath(
|
48
|
+
money_at_xpath('GiftWrapPrice')
|
49
49
|
end
|
50
50
|
|
51
51
|
attribute(:item_tax) do
|
52
|
-
money_at_xpath(
|
52
|
+
money_at_xpath('ItemTax')
|
53
53
|
end
|
54
54
|
|
55
55
|
attribute(:shipping_tax) do
|
56
|
-
money_at_xpath(
|
56
|
+
money_at_xpath('ShippingTax')
|
57
57
|
end
|
58
58
|
|
59
59
|
attribute(:gift_wrap_tax) do
|
60
|
-
money_at_xpath(
|
60
|
+
money_at_xpath('GiftWrapPrice')
|
61
61
|
end
|
62
62
|
|
63
63
|
attribute(:shipping_discount) do
|
64
|
-
money_at_xpath(
|
64
|
+
money_at_xpath('ShippingDiscount')
|
65
65
|
end
|
66
66
|
|
67
67
|
attribute(:promotion_discount) do
|
68
|
-
money_at_xpath(
|
68
|
+
money_at_xpath('PromotionDiscount')
|
69
69
|
end
|
70
70
|
|
71
71
|
attribute(:promotion_ids) do
|
72
|
-
xpath(
|
72
|
+
xpath('PromotionId').map(&:text)
|
73
73
|
end
|
74
74
|
|
75
75
|
attribute(:cod_fee) do
|
76
|
-
money_at_xpath(
|
76
|
+
money_at_xpath('CODFee')
|
77
77
|
end
|
78
78
|
|
79
79
|
attribute(:cod_fee_discount) do
|
80
|
-
money_at_xpath(
|
80
|
+
money_at_xpath('CODFeeDiscount')
|
81
81
|
end
|
82
82
|
|
83
83
|
attribute(:invoice_data) do
|
84
|
-
xpath(
|
84
|
+
xpath('InvoiceData').map { |node| InvoiceData.new(node) }
|
85
85
|
end
|
86
86
|
|
87
87
|
attribute(:condition_id) do
|
88
|
-
text_at_xpath(
|
88
|
+
text_at_xpath('ConditionId')
|
89
89
|
end
|
90
90
|
|
91
91
|
attribute(:condition_subtype_id) do
|
92
|
-
text_at_xpath(
|
92
|
+
text_at_xpath('ConditionSubtypeId')
|
93
93
|
end
|
94
94
|
|
95
95
|
attribute(:condition_note) do
|
96
|
-
text_at_xpath(
|
96
|
+
text_at_xpath('ConditionNote')
|
97
97
|
end
|
98
98
|
|
99
99
|
attribute(:scheduled_delivery_ends_at) do
|
100
|
-
time_at_xpath(
|
100
|
+
time_at_xpath('ScheduledDeliveryEndDate')
|
101
101
|
end
|
102
102
|
|
103
103
|
attribute(:scheduled_delivery_starts_at) do
|
104
|
-
time_at_xpath(
|
104
|
+
time_at_xpath('ScheduledDeliveryStartDate')
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'mws/orders/collection'
|
2
|
+
require 'mws/orders/order_item'
|
3
|
+
require 'mws/orders/tokenable'
|
4
4
|
|
5
5
|
module MWS
|
6
6
|
module Orders
|
7
7
|
class OrderItems < Collection
|
8
8
|
include Tokenable
|
9
9
|
|
10
|
-
def each
|
11
|
-
xpath(
|
10
|
+
def each
|
11
|
+
xpath('OrderItems/OrderItem').each { |node| yield OrderItem.new(node) }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/mws/orders/orders.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'mws/orders/collection'
|
2
|
+
require 'mws/orders/order'
|
3
|
+
require 'mws/orders/tokenable'
|
4
4
|
|
5
5
|
module MWS
|
6
6
|
module Orders
|
7
7
|
class Orders < Collection
|
8
8
|
include Tokenable
|
9
9
|
|
10
|
-
def each
|
11
|
-
xpath(
|
10
|
+
def each
|
11
|
+
xpath('Orders/Order').map { |node| yield Order.new(node) }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/mws/orders/parser.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'mws/orders/orders'
|
3
|
+
require 'mws/orders/order_items'
|
4
|
+
require 'mws/orders/service_status'
|
5
5
|
|
6
6
|
module MWS
|
7
7
|
module Orders
|
@@ -38,7 +38,7 @@ module MWS
|
|
38
38
|
xml = Nokogiri(@response.body)
|
39
39
|
root = xml.children.first
|
40
40
|
|
41
|
-
root.children.find { |node| node.name.include?(
|
41
|
+
root.children.find { |node| node.name.include?('Result') }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'mws/orders/collection'
|
2
|
+
require 'mws/orders/payment_execution_detail_item'
|
3
3
|
|
4
4
|
module MWS
|
5
5
|
module Orders
|
6
6
|
class PaymentExecutionDetail < Collection
|
7
|
-
def each
|
8
|
-
xpath(
|
7
|
+
def each
|
8
|
+
xpath('PaymentExecutionDetailItem').each { |node| yield PaymentExecutionDetailItem.new(node) }
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
5
5
|
class PaymentExecutionDetailItem < Entity
|
6
6
|
attribute(:payment) do
|
7
|
-
money_at_xpath(
|
7
|
+
money_at_xpath('Payment')
|
8
8
|
end
|
9
9
|
|
10
10
|
attribute(:payment_method) do
|
11
|
-
text_at_xpath(
|
11
|
+
text_at_xpath('PaymentMethod')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
|
+
require 'mws/orders/service_status_message'
|
3
3
|
|
4
4
|
module MWS
|
5
5
|
module Orders
|
6
6
|
class ServiceStatus < Entity
|
7
7
|
attribute(:status) do
|
8
|
-
text_at_xpath(
|
8
|
+
text_at_xpath('Status')
|
9
9
|
end
|
10
10
|
|
11
11
|
attribute(:timestamp) do
|
12
|
-
time_at_xpath(
|
12
|
+
time_at_xpath('Timestamp')
|
13
13
|
end
|
14
14
|
|
15
15
|
attribute(:message_id) do
|
16
|
-
text_at_xpath(
|
16
|
+
text_at_xpath('MessageId')
|
17
17
|
end
|
18
18
|
|
19
19
|
attribute(:messages) do
|
20
|
-
xpath(
|
20
|
+
xpath('Messages/Message').map { |node| ServiceStatusMessage.new(node) }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
5
5
|
class ServiceStatusMessage < Entity
|
6
6
|
attribute(:locale) do
|
7
|
-
text_at_xpath(
|
7
|
+
text_at_xpath('Locale')
|
8
8
|
end
|
9
9
|
|
10
10
|
attribute(:text) do
|
11
|
-
text_at_xpath(
|
11
|
+
text_at_xpath('Text')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'mws/orders/entity'
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Orders
|
5
5
|
class ShippingAddress < Entity
|
6
6
|
attribute(:name) do
|
7
|
-
text_at_xpath(
|
7
|
+
text_at_xpath('Name')
|
8
8
|
end
|
9
9
|
|
10
10
|
attribute(:address_lines) do
|
@@ -12,23 +12,23 @@ module MWS
|
|
12
12
|
end
|
13
13
|
|
14
14
|
attribute(:city) do
|
15
|
-
text_at_xpath(
|
15
|
+
text_at_xpath('City')
|
16
16
|
end
|
17
17
|
|
18
18
|
attribute(:state_or_region) do
|
19
|
-
text_at_xpath(
|
19
|
+
text_at_xpath('StateOrRegion')
|
20
20
|
end
|
21
21
|
|
22
22
|
attribute(:postal_code) do
|
23
|
-
text_at_xpath(
|
23
|
+
text_at_xpath('PostalCode')
|
24
24
|
end
|
25
25
|
|
26
26
|
attribute(:country_code) do
|
27
|
-
text_at_xpath(
|
27
|
+
text_at_xpath('CountryCode')
|
28
28
|
end
|
29
29
|
|
30
30
|
attribute(:phone) do
|
31
|
-
text_at_xpath(
|
31
|
+
text_at_xpath('Phone')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/mws/orders/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- encoding : utf-8
|
2
|
-
require
|
2
|
+
require 'test_helper'
|
3
3
|
|
4
4
|
class TestEntity < MiniTest::Test
|
5
5
|
def test_parses_floats
|
6
6
|
xml = <<-EOF
|
7
7
|
<Float xmlns="example">10.0</Float>
|
8
8
|
EOF
|
9
|
-
entity= build_entity(xml)
|
10
|
-
float = entity.float_at_xpath(
|
9
|
+
entity = build_entity(xml)
|
10
|
+
float = entity.float_at_xpath('Float')
|
11
11
|
assert_equal 10.0, float
|
12
12
|
end
|
13
13
|
|
@@ -15,8 +15,8 @@ class TestEntity < MiniTest::Test
|
|
15
15
|
xml = <<-EOF
|
16
16
|
<Integer xmlns="example">10</Integer>
|
17
17
|
EOF
|
18
|
-
entity= build_entity(xml)
|
19
|
-
integer = entity.integer_at_xpath(
|
18
|
+
entity = build_entity(xml)
|
19
|
+
integer = entity.integer_at_xpath('Integer')
|
20
20
|
assert_equal 10, integer
|
21
21
|
end
|
22
22
|
|
@@ -27,9 +27,9 @@ class TestEntity < MiniTest::Test
|
|
27
27
|
<Amount>10.00</Amount>
|
28
28
|
</Price>
|
29
29
|
EOF
|
30
|
-
entity= build_entity(xml)
|
31
|
-
money = entity.money_at_xpath(
|
32
|
-
assert_equal
|
30
|
+
entity = build_entity(xml)
|
31
|
+
money = entity.money_at_xpath('Price')
|
32
|
+
assert_equal '$10.00', money.format
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_parses_japanese_yen
|
@@ -39,19 +39,19 @@ class TestEntity < MiniTest::Test
|
|
39
39
|
<Amount>1000.00</Amount>
|
40
40
|
</Price>
|
41
41
|
EOF
|
42
|
-
entity= build_entity(xml)
|
43
|
-
money = entity.money_at_xpath(
|
42
|
+
entity = build_entity(xml)
|
43
|
+
money = entity.money_at_xpath('Price')
|
44
44
|
|
45
|
-
assert_equal
|
45
|
+
assert_equal '¥1,000', money.format
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_parses_text
|
49
49
|
xml = <<-EOF
|
50
50
|
<Text xmlns="example">Foo</Text>
|
51
51
|
EOF
|
52
|
-
entity= build_entity(xml)
|
53
|
-
text = entity.text_at_xpath(
|
54
|
-
assert_equal
|
52
|
+
entity = build_entity(xml)
|
53
|
+
text = entity.text_at_xpath('Text')
|
54
|
+
assert_equal 'Foo', text
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_strips_text
|
@@ -60,17 +60,17 @@ class TestEntity < MiniTest::Test
|
|
60
60
|
|
61
61
|
</Text>
|
62
62
|
EOF
|
63
|
-
entity= build_entity(xml)
|
64
|
-
text = entity.text_at_xpath(
|
65
|
-
assert_equal
|
63
|
+
entity = build_entity(xml)
|
64
|
+
text = entity.text_at_xpath('Text')
|
65
|
+
assert_equal 'Foo', text
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_parses_time
|
69
69
|
xml = <<-EOF
|
70
70
|
<Time xmlns="example">2013-01-01T01:30:00.000-06:00</Time>
|
71
71
|
EOF
|
72
|
-
entity= build_entity(xml)
|
73
|
-
time = entity.time_at_xpath(
|
72
|
+
entity = build_entity(xml)
|
73
|
+
time = entity.time_at_xpath('Time')
|
74
74
|
assert_kind_of Time, time
|
75
75
|
end
|
76
76
|
|
@@ -79,13 +79,13 @@ class TestEntity < MiniTest::Test
|
|
79
79
|
<Foo xmlns="example">
|
80
80
|
</Foo>
|
81
81
|
EOF
|
82
|
-
entity= build_entity(xml)
|
82
|
+
entity = build_entity(xml)
|
83
83
|
|
84
|
-
assert_nil entity.float_at_xpath(
|
85
|
-
assert_nil entity.integer_at_xpath(
|
86
|
-
assert_nil entity.money_at_xpath(
|
87
|
-
assert_nil entity.time_at_xpath(
|
88
|
-
assert_nil entity.text_at_xpath(
|
84
|
+
assert_nil entity.float_at_xpath('Bar')
|
85
|
+
assert_nil entity.integer_at_xpath('Bar')
|
86
|
+
assert_nil entity.money_at_xpath('Bar')
|
87
|
+
assert_nil entity.time_at_xpath('Bar')
|
88
|
+
assert_nil entity.text_at_xpath('Bar')
|
89
89
|
end
|
90
90
|
|
91
91
|
private
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestOrder < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('orders').at_xpath('//xmlns:Order')
|
6
6
|
@order = Order.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -87,7 +87,7 @@ class TestOrder < MiniTest::Test
|
|
87
87
|
assert_kind_of Time, @order.latest_shipped_at
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
91
|
-
assert_kind_of Time, @order.
|
90
|
+
def test_latest_delivered_at
|
91
|
+
assert_kind_of Time, @order.latest_delivered_at
|
92
92
|
end
|
93
93
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestOrderItemTest < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('order_items').at_xpath('//xmlns:OrderItem')
|
6
6
|
@order_item = OrderItem.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestOrderItems < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('order_items').xpath('//xmlns:ListOrderItemsResult')
|
6
6
|
@order_items = OrderItems.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestOrders < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('orders').xpath('//xmlns:ListOrdersResult')
|
6
6
|
@orders = Orders.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestPaymentExecutionDetail < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('orders').xpath('//xmlns:PaymentExecutionDetail').first
|
6
6
|
@ped = PaymentExecutionDetail.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestPaymentExecutionDetailItem < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('orders').xpath('//xmlns:PaymentExecutionDetailItem').first
|
6
6
|
@pedi = PaymentExecutionDetailItem.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestServiceStatus < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('service_status').xpath('//xmlns:GetServiceStatusResult').first
|
6
6
|
@status = ServiceStatus.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestServiceStatusMessage < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('service_status').xpath('//xmlns:Message').first
|
6
6
|
@message = ServiceStatusMessage.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestShippingAddress < MiniTest::Test
|
4
4
|
def setup
|
5
|
-
node = load_xml_fixture(
|
5
|
+
node = load_xml_fixture('orders').xpath('//xmlns:ShippingAddress').first
|
6
6
|
@address = ShippingAddress.new(node)
|
7
7
|
end
|
8
8
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
class TestTokenable < MiniTest::Test
|
4
4
|
def test_parses_next_token
|
@@ -7,7 +7,7 @@ class TestTokenable < MiniTest::Test
|
|
7
7
|
EOF
|
8
8
|
tokenable = build_tokenable(xml)
|
9
9
|
|
10
|
-
assert_equal
|
10
|
+
assert_equal '123', tokenable.next_token
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_returns_nil_if_next_token_is_not_present
|
data/test/test_helper.rb
CHANGED