peddler 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +237 -8
- data/lib/mws/feeds.rb +1 -0
- data/lib/mws/feeds/client.rb +97 -0
- data/lib/mws/feeds/parsers/feed.rb +14 -0
- data/lib/mws/feeds/parsers/feed_submission.rb +25 -0
- data/lib/mws/feeds/parsers/feed_submission_count.rb +13 -0
- data/lib/mws/feeds/parsers/feed_submission_list.rb +20 -0
- data/lib/mws/feeds/parsers/feed_submission_result.rb +10 -0
- data/lib/mws/feeds/parsers/feed_submissions.rb +18 -0
- data/lib/mws/feeds/requests/feed.rb +38 -0
- data/lib/mws/feeds/requests/feed_submission_count.rb +20 -0
- data/lib/mws/feeds/requests/feed_submission_list.rb +28 -0
- data/lib/mws/feeds/requests/feed_submission_result.rb +18 -0
- data/lib/mws/feeds/requests/feed_submissions.rb +20 -0
- data/lib/mws/fulfillment_inbound_shipment/client.rb +7 -0
- data/lib/mws/fulfillment_inventory/client.rb +7 -0
- data/lib/mws/fulfillment_outbound_shipment/client.rb +7 -0
- data/lib/mws/off_amazon_payments/client.rb +7 -0
- data/lib/mws/orders.rb +1 -0
- data/lib/mws/orders/client.rb +88 -0
- data/lib/mws/orders/parsers/invoice_data.rb +25 -0
- data/lib/mws/orders/parsers/order.rb +113 -0
- data/lib/mws/orders/parsers/order_item.rb +110 -0
- data/lib/mws/orders/parsers/order_items.rb +20 -0
- data/lib/mws/orders/parsers/orders.rb +20 -0
- data/lib/mws/orders/parsers/payment_execution_detail.rb +20 -0
- data/lib/mws/orders/parsers/payment_execution_detail_item.rb +17 -0
- data/lib/mws/orders/parsers/service_status.rb +36 -0
- data/lib/mws/orders/parsers/service_status_message.rb +17 -0
- data/lib/mws/orders/parsers/shipping_address.rb +37 -0
- data/lib/mws/orders/requests/order_items.rb +26 -0
- data/lib/mws/orders/requests/orders.rb +39 -0
- data/lib/mws/orders/requests/service_status.rb +15 -0
- data/lib/mws/products/client.rb +7 -0
- data/lib/mws/recommendations/client.rb +7 -0
- data/lib/mws/reports/client.rb +6 -0
- data/lib/mws/sellers/client.rb +7 -0
- data/lib/mws/subscriptions/client.rb +7 -0
- data/lib/peddler.rb +11 -1
- data/lib/peddler/client.rb +62 -0
- data/lib/peddler/parsers/base.rb +15 -0
- data/lib/peddler/parsers/collection.rb +23 -0
- data/lib/peddler/parsers/model.rb +43 -0
- data/lib/peddler/parsers/text.rb +13 -0
- data/lib/peddler/parsers/xml.rb +25 -0
- data/lib/peddler/request.rb +50 -0
- data/lib/peddler/request/parameters.rb +56 -0
- data/lib/peddler/request/structured_list.rb +43 -0
- data/lib/peddler/response_wrapper.rb +32 -0
- data/lib/peddler/version.rb +1 -1
- data/test/fixtures/feeds/feed_submission.xml +14 -0
- data/test/fixtures/feeds/feed_submission_count.xml +9 -0
- data/test/fixtures/feeds/feed_submission_list.xml +17 -0
- data/test/fixtures/feeds/feed_submissions.xml +15 -0
- data/test/fixtures/mws.yml +8 -0
- data/test/fixtures/mws.yml.example +4 -0
- data/test/fixtures/orders/order_items.xml +83 -0
- data/test/fixtures/orders/orders.xml +109 -0
- data/test/fixtures/orders/service_status.xml +19 -0
- data/test/helper.rb +5 -0
- data/test/integration/feeds/test_feed_submission_count.rb +13 -0
- data/test/integration/feeds/test_feed_submission_list.rb +15 -0
- data/test/integration/feeds/test_feed_submission_result.rb +15 -0
- data/test/integration/orders/test_order_items.rb +19 -0
- data/test/integration/orders/test_orders.rb +20 -0
- data/test/integration/orders/test_service_status.rb +12 -0
- data/test/integration_helper.rb +16 -0
- data/test/mws/feeds/parsers/test_feed.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submission.rb +25 -0
- data/test/mws/feeds/parsers/test_feed_submission_count.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submission_list.rb +14 -0
- data/test/mws/feeds/parsers/test_feed_submission_result.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submissions.rb +17 -0
- data/test/mws/feeds/requests/test_feed.rb +63 -0
- data/test/mws/feeds/requests/test_feed_submission_count.rb +23 -0
- data/test/mws/feeds/requests/test_feed_submission_list.rb +40 -0
- data/test/mws/feeds/requests/test_feed_submissions.rb +29 -0
- data/test/mws/orders/parsers/test_order.rb +86 -0
- data/test/mws/orders/parsers/test_order_item.rb +69 -0
- data/test/mws/orders/parsers/test_order_items.rb +14 -0
- data/test/mws/orders/parsers/test_orders.rb +14 -0
- data/test/mws/orders/parsers/test_payment_execution_detail.rb +14 -0
- data/test/mws/orders/parsers/test_payment_execution_detail_item.rb +17 -0
- data/test/mws/orders/parsers/test_service_status.rb +39 -0
- data/test/mws/orders/parsers/test_service_status_message.rb +17 -0
- data/test/mws/orders/parsers/test_shipping_address.rb +36 -0
- data/test/mws/orders/requests/test_order_items.rb +39 -0
- data/test/mws/orders/requests/test_orders.rb +49 -0
- data/test/mws/orders/requests/test_service_status.rb +25 -0
- data/test/parser_helper.rb +11 -0
- data/test/peddler/parsers/test_collection.rb +8 -0
- data/test/peddler/parsers/test_model.rb +34 -0
- data/test/peddler/request/test_parameters.rb +35 -0
- data/test/peddler/request/test_structured_list.rb +18 -0
- data/test/peddler/test_client.rb +42 -0
- data/test/request_helper.rb +20 -0
- metadata +213 -10
- data/lib/peddler/apis.rb +0 -45
- data/lib/peddler/service.rb +0 -83
- data/test/service_test.rb +0 -42
- data/test/test_helper.rb +0 -3
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/order_item'
|
3
|
+
|
4
|
+
class OrderItemParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/order_items').xpath('//xmlns:OrderItem').first
|
7
|
+
@order_item = MWS::Orders::Parsers::OrderItem.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_asin
|
11
|
+
assert_kind_of String, @order_item.asin
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_order_item_id
|
15
|
+
assert_kind_of String, @order_item.order_item_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_seller_sku
|
19
|
+
assert_kind_of String, @order_item.seller_sku
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_title
|
23
|
+
assert_kind_of String, @order_item.title
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_quantity_ordered
|
27
|
+
assert_kind_of Integer, @order_item.quantity_ordered
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_quantity_shipped
|
31
|
+
assert_kind_of Integer, @order_item.quantity_shipped
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_item_price
|
35
|
+
assert_kind_of Money, @order_item.item_price
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_shipping_price
|
39
|
+
assert_kind_of Money, @order_item.shipping_price
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_scheduled_delivery_ends_at
|
43
|
+
assert_kind_of Time, @order_item.scheduled_delivery_ends_at
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_scheduled_delivery_starts_at
|
47
|
+
assert_kind_of Time, @order_item.scheduled_delivery_starts_at
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_cod_fee
|
51
|
+
assert_kind_of Money, @order_item.cod_fee
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_cod_fee_discount
|
55
|
+
assert_kind_of Money, @order_item.cod_fee_discount
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_gift_message_text
|
59
|
+
assert_kind_of String, @order_item.gift_message_text
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_gift_wrap_price
|
63
|
+
assert_kind_of Money, @order_item.gift_wrap_price
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_gift_wrap_level
|
67
|
+
assert_kind_of String, @order_item.gift_wrap_level
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/order_items'
|
3
|
+
|
4
|
+
class OrderItemsParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/order_items').xpath('//xmlns:ListOrderItemsResult')
|
7
|
+
@order_items = MWS::Orders::Parsers::OrderItems.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_order_items
|
11
|
+
refute_empty @order_items.to_a
|
12
|
+
@order_items.each { |order_item| assert_kind_of MWS::Orders::Parsers::OrderItem, order_item }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/orders'
|
3
|
+
|
4
|
+
class OrdersParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/orders').xpath('//xmlns:ListOrdersResult')
|
7
|
+
@orders = MWS::Orders::Parsers::Orders.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_orders
|
11
|
+
refute_empty @orders.to_a
|
12
|
+
@orders.each { |order| assert_kind_of MWS::Orders::Parsers::Order, order }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/payment_execution_detail'
|
3
|
+
|
4
|
+
class PaymentExecutionDetailParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/orders').xpath('//xmlns:PaymentExecutionDetail').first
|
7
|
+
@ped = MWS::Orders::Parsers::PaymentExecutionDetail.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_payment_execution_detail_items
|
11
|
+
refute_empty @ped.to_a
|
12
|
+
@ped.each { |pedi| assert_kind_of MWS::Orders::Parsers::PaymentExecutionDetailItem, pedi }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/payment_execution_detail_item'
|
3
|
+
|
4
|
+
class PaymentExecutionDetailItemParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/orders').xpath('//xmlns:PaymentExecutionDetailItem').first
|
7
|
+
@pedi = MWS::Orders::Parsers::PaymentExecutionDetailItem.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_payment
|
11
|
+
assert_kind_of Money, @pedi.payment
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_payment_method
|
15
|
+
assert_kind_of String, @pedi.payment_method
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/service_status'
|
3
|
+
|
4
|
+
class ServiceStatusParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/service_status').xpath('//xmlns:GetServiceStatusResult').first
|
7
|
+
@service_status = MWS::Orders::Parsers::ServiceStatus.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_status
|
11
|
+
assert_kind_of String, @service_status.status
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_timestamp
|
15
|
+
assert_kind_of Time, @service_status.timestamp
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_message_id
|
19
|
+
assert_kind_of String, @service_status.message_id
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_messages
|
23
|
+
assert_kind_of Array, @service_status.messages
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_ok?
|
27
|
+
@service_status.stub(:status, 'GREEN') do
|
28
|
+
assert @service_status.ok?
|
29
|
+
end
|
30
|
+
|
31
|
+
@service_status.stub(:status, 'RED') do
|
32
|
+
refute @service_status.ok?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_inspect
|
37
|
+
assert_equal @service_status.status, @service_status.to_s
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/service_status_message'
|
3
|
+
|
4
|
+
class ServiceStatusMessageParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/service_status').xpath('//xmlns:Message').first
|
7
|
+
@message = MWS::Orders::Parsers::ServiceStatusMessage.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_locale
|
11
|
+
assert_kind_of String, @message.locale
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_text
|
15
|
+
assert_kind_of String, @message.text
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'parser_helper'
|
2
|
+
require 'mws/orders/parsers/shipping_address'
|
3
|
+
|
4
|
+
class ShippingAddressParserTest < ParserTest
|
5
|
+
def setup
|
6
|
+
node = fixture('orders/orders').xpath('//xmlns:ShippingAddress').first
|
7
|
+
@address = MWS::Orders::Parsers::ShippingAddress.new(node)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_name
|
11
|
+
assert_kind_of String, @address.name
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_address_lines
|
15
|
+
assert_kind_of Array, @address.address_lines
|
16
|
+
@address.address_lines.each do |line|
|
17
|
+
assert_kind_of String, line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_city
|
22
|
+
assert_kind_of String, @address.city
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_state_or_region
|
26
|
+
assert_kind_of String, @address.state_or_region
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_postal_code
|
30
|
+
assert_kind_of String, @address.postal_code
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_country_code
|
34
|
+
assert_kind_of String, @address.country_code
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'request_helper'
|
2
|
+
require 'mws/orders/requests/order_items'
|
3
|
+
|
4
|
+
class MWSOrdersOrderItemsRequestTest < RequestTest
|
5
|
+
def mock_response_body
|
6
|
+
<<-EOF
|
7
|
+
<Response xmlns="ns">
|
8
|
+
<Result>
|
9
|
+
<NextToken>123</NextToken>
|
10
|
+
<OrderItems>
|
11
|
+
<OrderItem>
|
12
|
+
<Id>123</Id>
|
13
|
+
</OrderItem>
|
14
|
+
</OrderItems>
|
15
|
+
</Result>
|
16
|
+
</Response>
|
17
|
+
EOF
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@order_items = MWS::Orders::Requests::OrderItems.new(mock_client)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_lists_order_items
|
25
|
+
res = @order_items.list('123-1234567-1234567')
|
26
|
+
assert_kind_of MWS::Orders::Parsers::OrderItems, res
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_returns_next_token
|
30
|
+
@order_items.last_response = mock_response
|
31
|
+
assert_equal '123', @order_items.next_token
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_lists_order_items_by_next_token
|
35
|
+
@order_items.last_response = mock_response
|
36
|
+
res = @order_items.list_by_next_token
|
37
|
+
assert_kind_of MWS::Orders::Parsers::OrderItems, res
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'request_helper'
|
2
|
+
require 'mws/orders/requests/orders'
|
3
|
+
|
4
|
+
class MWSOrdersOrdersRequestTest < RequestTest
|
5
|
+
def mock_response_body
|
6
|
+
<<-EOF
|
7
|
+
<Response xmlns="ns">
|
8
|
+
<Result>
|
9
|
+
<NextToken>123</NextToken>
|
10
|
+
<Orders>
|
11
|
+
<Order>
|
12
|
+
<Id>123</Id>
|
13
|
+
</Order>
|
14
|
+
</Orders>
|
15
|
+
</Result>
|
16
|
+
</Response>
|
17
|
+
EOF
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@orders = MWS::Orders::Requests::Orders.new(mock_client)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_lists_orders
|
25
|
+
res = @orders.list(created_after: 0)
|
26
|
+
assert_kind_of MWS::Orders::Parsers::Orders, res
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_returns_next_token
|
30
|
+
@orders.last_response = mock_response
|
31
|
+
assert_equal '123', @orders.next_token
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_lists_orders_by_next_token
|
35
|
+
@orders.last_response = mock_response
|
36
|
+
res = @orders.list_by_next_token
|
37
|
+
assert_kind_of MWS::Orders::Parsers::Orders, res
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_gets_order
|
41
|
+
res = @orders.get('123')
|
42
|
+
assert_kind_of MWS::Orders::Parsers::Orders, res
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_gets_multiple_orders
|
46
|
+
res = @orders.get('123', '321')
|
47
|
+
assert_kind_of MWS::Orders::Parsers::Orders, res
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'request_helper'
|
2
|
+
require 'mws/orders/requests/service_status'
|
3
|
+
|
4
|
+
class MWSOrdersServiceStatusRequestTest < RequestTest
|
5
|
+
def mock_response_body
|
6
|
+
<<-EOF
|
7
|
+
<Response xmlns="ns">
|
8
|
+
<Result>
|
9
|
+
<GetServiceStatusResult>
|
10
|
+
<Status>GREEN</Status>
|
11
|
+
</GetServiceStatusResult>
|
12
|
+
</Result>
|
13
|
+
</Response>
|
14
|
+
EOF
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@status = MWS::Orders::Requests::ServiceStatus.new(mock_client)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_gets_status
|
22
|
+
res = @status.get
|
23
|
+
assert_kind_of MWS::Orders::Parsers::ServiceStatus, res
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'peddler/parsers/model'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
class PeddlerModelParserTest < MiniTest::Test
|
6
|
+
def build(xml)
|
7
|
+
document = Nokogiri(xml)
|
8
|
+
Peddler::Parsers::Model.new(document)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_parses_money
|
12
|
+
xml = <<-EOF
|
13
|
+
<Price xmlns="example">
|
14
|
+
<CurrencyCode>USD</CurrencyCode>
|
15
|
+
<Amount>10.00</Amount>
|
16
|
+
</Price>
|
17
|
+
EOF
|
18
|
+
model = build(xml)
|
19
|
+
money = model.money_at_xpath('Price')
|
20
|
+
assert_equal '$10.00', money.format
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_parses_japanese_yen
|
24
|
+
xml = <<-EOF
|
25
|
+
<Price xmlns="example">
|
26
|
+
<CurrencyCode>JPY</CurrencyCode>
|
27
|
+
<Amount>1000.00</Amount>
|
28
|
+
</Price>
|
29
|
+
EOF
|
30
|
+
model = build(xml)
|
31
|
+
money = model.money_at_xpath('Price')
|
32
|
+
assert_equal '¥1,000', money.format
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'peddler/request/parameters'
|
3
|
+
|
4
|
+
class PeddlerRequestParametersTest < MiniTest::Test
|
5
|
+
def setup
|
6
|
+
@parameters = Peddler::Request::Parameters.new(:do_it)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_has_an_action_key
|
10
|
+
assert_equal 'DoIt', @parameters.fetch('Action')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_formats_timestamps
|
14
|
+
ts = Minitest::Mock.new
|
15
|
+
ts.expect(:iso8601, 'formatted')
|
16
|
+
@parameters.store('a timestamp', ts)
|
17
|
+
assert_equal 'formatted', @parameters.timestamp!.fetch('a timestamp')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_formats_structured_lists
|
21
|
+
@parameters.store(:order_status, 'foo')
|
22
|
+
assert_equal 'foo', @parameters.format_structured_lists!.fetch('OrderStatus.Status.1')
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_camelizes_keys
|
26
|
+
@parameters.store(:underscored_key, 'baz')
|
27
|
+
refute @parameters.camelize_keys!.has_key?(:underscored_key)
|
28
|
+
assert @parameters.has_key?('UnderscoredKey')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_updates_delegated_hash
|
32
|
+
assert_kind_of Peddler::Request::Parameters, @parameters.update(key: 'value')
|
33
|
+
assert_equal 'value', @parameters.fetch(:key)
|
34
|
+
end
|
35
|
+
end
|