mws-orders 0.0.2 → 0.1.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 +16 -25
- data/lib/mws-orders.rb +2 -29
- data/lib/mws/orders/collection.rb +29 -0
- data/lib/mws/orders/document.rb +28 -0
- data/lib/mws/orders/entity.rb +39 -0
- data/lib/mws/orders/invoice_data.rb +23 -0
- data/lib/mws/orders/order.rb +113 -0
- data/lib/mws/orders/order_item.rb +108 -0
- data/lib/mws/orders/order_items.rb +15 -0
- data/lib/mws/orders/orders.rb +15 -0
- data/lib/mws/orders/parser.rb +52 -0
- data/lib/mws/orders/payment_execution_detail.rb +12 -0
- data/lib/mws/orders/payment_execution_detail_item.rb +15 -0
- data/lib/mws/orders/service_status.rb +24 -0
- data/lib/mws/orders/service_status_message.rb +15 -0
- data/lib/mws/orders/shipping_address.rb +35 -0
- data/lib/mws/orders/tokenable.rb +10 -0
- data/lib/mws/orders/version.rb +1 -1
- data/test/integration/test_integration.rb +26 -0
- data/test/mws/orders/test_entity.rb +88 -0
- data/test/{parsers/order_test.rb → mws/orders/test_order.rb} +11 -6
- data/test/{parsers/order_item_test.rb → mws/orders/test_order_item.rb} +4 -4
- data/test/mws/orders/test_order_items.rb +19 -0
- data/test/mws/orders/test_orders.rb +19 -0
- data/test/mws/orders/test_parser.rb +7 -0
- data/test/mws/orders/test_payment_execution_detail.rb +15 -0
- data/test/mws/orders/test_payment_execution_detail_item.rb +16 -0
- data/test/mws/orders/test_service_status.rb +24 -0
- data/test/mws/orders/test_service_status_message.rb +16 -0
- data/test/{parsers/shipping_address_test.rb → mws/orders/test_shipping_address.rb} +4 -4
- data/test/test_helper.rb +15 -6
- metadata +67 -134
- data/lib/mws/orders/client.rb +0 -88
- data/lib/mws/orders/helpers/parameters.rb +0 -53
- data/lib/mws/orders/helpers/structured_list.rb +0 -40
- data/lib/mws/orders/parsers/base.rb +0 -27
- data/lib/mws/orders/parsers/collection.rb +0 -22
- data/lib/mws/orders/parsers/invoice_data.rb +0 -23
- data/lib/mws/orders/parsers/model.rb +0 -38
- data/lib/mws/orders/parsers/order.rb +0 -108
- data/lib/mws/orders/parsers/order_item.rb +0 -107
- data/lib/mws/orders/parsers/order_items.rb +0 -17
- data/lib/mws/orders/parsers/orders.rb +0 -17
- data/lib/mws/orders/parsers/payment_execution_detail.rb +0 -17
- data/lib/mws/orders/parsers/payment_execution_detail_item.rb +0 -15
- data/lib/mws/orders/parsers/service_status.rb +0 -32
- data/lib/mws/orders/parsers/service_status_message.rb +0 -15
- data/lib/mws/orders/parsers/shipping_address.rb +0 -35
- data/lib/mws/orders/requests/base.rb +0 -55
- data/lib/mws/orders/requests/order_items.rb +0 -23
- data/lib/mws/orders/requests/orders.rb +0 -36
- data/lib/mws/orders/requests/service_status.rb +0 -18
- data/test/fixtures/mws.yml +0 -12
- data/test/helpers/parameters_test.rb +0 -34
- data/test/helpers/structured_list_test.rb +0 -17
- data/test/integration/order_items_test.rb +0 -16
- data/test/integration/orders_test.rb +0 -17
- data/test/integration/service_status_test.rb +0 -9
- data/test/integration/test_helper.rb +0 -12
- data/test/parsers/collection_test.rb +0 -7
- data/test/parsers/model_test.rb +0 -27
- data/test/parsers/order_items_test.rb +0 -13
- data/test/parsers/orders_test.rb +0 -13
- data/test/parsers/payment_execution_detail_item_test.rb +0 -16
- data/test/parsers/payment_execution_detail_test.rb +0 -13
- data/test/parsers/service_status_message_test.rb +0 -16
- data/test/parsers/service_status_test.rb +0 -38
- data/test/parsers/test_helper.rb +0 -10
- data/test/requests/order_items_test.rb +0 -36
- data/test/requests/orders_test.rb +0 -46
- data/test/requests/service_status_test.rb +0 -22
- data/test/requests/test_helper.rb +0 -18
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class OrderItemsParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('order_items').xpath('//xmlns:OrderItems')
|
6
|
-
@order_items = Parser::OrderItems.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_has_order_items
|
10
|
-
refute_empty @order_items.to_a
|
11
|
-
@order_items.each { |order_item| assert_kind_of Parser::OrderItem, order_item }
|
12
|
-
end
|
13
|
-
end
|
data/test/parsers/orders_test.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class OrdersParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('orders').xpath('//xmlns:Orders')
|
6
|
-
@orders = Parser::Orders.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_has_orders
|
10
|
-
refute_empty @orders.to_a
|
11
|
-
@orders.each { |order| assert_kind_of Parser::Order, order }
|
12
|
-
end
|
13
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class PaymentExecutionDetailItemParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('orders').xpath('//xmlns:PaymentExecutionDetailItem').first
|
6
|
-
@pedi = Parser::PaymentExecutionDetailItem.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_payment
|
10
|
-
assert_kind_of Money, @pedi.payment
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_payment_method
|
14
|
-
assert_kind_of String, @pedi.payment_method
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class PaymentExecutionDetailParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('orders').xpath('//xmlns:PaymentExecutionDetail').first
|
6
|
-
@ped = Parser::PaymentExecutionDetail.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_has_payment_execution_detail_items
|
10
|
-
refute_empty @ped.to_a
|
11
|
-
@ped.each { |pedi| assert_kind_of Parser::PaymentExecutionDetailItem, pedi }
|
12
|
-
end
|
13
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class ServiceStatusMessageParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('service_status').xpath('//xmlns:Message').first
|
6
|
-
@message = Parser::ServiceStatusMessage.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_locale
|
10
|
-
assert_kind_of String, @message.locale
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_text
|
14
|
-
assert_kind_of String, @message.text
|
15
|
-
end
|
16
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class ServiceStatusParserTest < ParserTest
|
4
|
-
def setup
|
5
|
-
node = fixture('service_status').xpath('//xmlns:GetServiceStatusResult').first
|
6
|
-
@service_status = Parser::ServiceStatus.new(node)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_status
|
10
|
-
assert_kind_of String, @service_status.status
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_timestamp
|
14
|
-
assert_kind_of Time, @service_status.timestamp
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_message_id
|
18
|
-
assert_kind_of String, @service_status.message_id
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_messages
|
22
|
-
assert_kind_of Array, @service_status.messages
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_ok?
|
26
|
-
@service_status.stub(:status, 'GREEN') do
|
27
|
-
assert @service_status.ok?
|
28
|
-
end
|
29
|
-
|
30
|
-
@service_status.stub(:status, 'RED') do
|
31
|
-
refute @service_status.ok?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_inspect
|
36
|
-
assert_equal @service_status.status, @service_status.to_s
|
37
|
-
end
|
38
|
-
end
|
data/test/parsers/test_helper.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class OrderItemsRequestTest < RequestTestHelper
|
4
|
-
def mock_response_body
|
5
|
-
<<-EOF
|
6
|
-
<Response xmlns="ns">
|
7
|
-
<NextToken>123</NextToken>
|
8
|
-
<OrderItems>
|
9
|
-
<OrderItem>
|
10
|
-
<Id>123</Id>
|
11
|
-
</OrderItem>
|
12
|
-
</OrderItems>
|
13
|
-
</Response>
|
14
|
-
EOF
|
15
|
-
end
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@order_items = Request::OrderItems.new(mock_client)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_lists_order_items
|
22
|
-
res = @order_items.list('123-1234567-1234567')
|
23
|
-
assert_kind_of Parser::OrderItems, res
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_returns_next_token
|
27
|
-
@order_items.last_response = mock_response
|
28
|
-
assert_equal '123', @order_items.next_token
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_lists_order_items_by_next_token
|
32
|
-
@order_items.last_response = mock_response
|
33
|
-
res = @order_items.list_by_next_token
|
34
|
-
assert_kind_of Parser::OrderItems, res
|
35
|
-
end
|
36
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class OrdersRequestTest < RequestTestHelper
|
4
|
-
def mock_response_body
|
5
|
-
<<-EOF
|
6
|
-
<Response xmlns="ns">
|
7
|
-
<NextToken>123</NextToken>
|
8
|
-
<Orders>
|
9
|
-
<Order>
|
10
|
-
<Id>123</Id>
|
11
|
-
</Order>
|
12
|
-
</Orders>
|
13
|
-
</Response>
|
14
|
-
EOF
|
15
|
-
end
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@orders = Request::Orders.new(mock_client)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_lists_orders
|
22
|
-
res = @orders.list(created_after: 0)
|
23
|
-
assert_kind_of Parser::Orders, res
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_returns_next_token
|
27
|
-
@orders.last_response = mock_response
|
28
|
-
assert_equal '123', @orders.next_token
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_lists_orders_by_next_token
|
32
|
-
@orders.last_response = mock_response
|
33
|
-
res = @orders.list_by_next_token
|
34
|
-
assert_kind_of Parser::Orders, res
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_gets_order
|
38
|
-
res = @orders.get('123')
|
39
|
-
assert_kind_of Parser::Orders, res
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_gets_multiple_orders
|
43
|
-
res = @orders.get('123', '321')
|
44
|
-
assert_kind_of Parser::Orders, res
|
45
|
-
end
|
46
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
|
3
|
-
class ServiceStatusRequestTest < RequestTestHelper
|
4
|
-
def mock_response_body
|
5
|
-
<<-EOF
|
6
|
-
<Response xmlns="ns">
|
7
|
-
<GetServiceStatusResult>
|
8
|
-
<Status>GREEN</Status>
|
9
|
-
</GetServiceStatusResult>
|
10
|
-
</Response>
|
11
|
-
EOF
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup
|
15
|
-
@status = Request::ServiceStatus.new(mock_client)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_gets_status
|
19
|
-
res = @status.get
|
20
|
-
assert_kind_of Parser::ServiceStatus, res
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class RequestTestHelper < Minitest::Test
|
4
|
-
def mock_response_body
|
5
|
-
raise NotImplementedError
|
6
|
-
end
|
7
|
-
|
8
|
-
def mock_response
|
9
|
-
res = Minitest::Mock.new
|
10
|
-
res.expect(:body, mock_response_body)
|
11
|
-
end
|
12
|
-
|
13
|
-
def mock_client
|
14
|
-
client = Minitest::Mock.new
|
15
|
-
client.expect(:home_marketplace_id, '123')
|
16
|
-
client.expect(:post, mock_response, [Hash])
|
17
|
-
end
|
18
|
-
end
|