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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +16 -25
  4. data/lib/mws-orders.rb +2 -29
  5. data/lib/mws/orders/collection.rb +29 -0
  6. data/lib/mws/orders/document.rb +28 -0
  7. data/lib/mws/orders/entity.rb +39 -0
  8. data/lib/mws/orders/invoice_data.rb +23 -0
  9. data/lib/mws/orders/order.rb +113 -0
  10. data/lib/mws/orders/order_item.rb +108 -0
  11. data/lib/mws/orders/order_items.rb +15 -0
  12. data/lib/mws/orders/orders.rb +15 -0
  13. data/lib/mws/orders/parser.rb +52 -0
  14. data/lib/mws/orders/payment_execution_detail.rb +12 -0
  15. data/lib/mws/orders/payment_execution_detail_item.rb +15 -0
  16. data/lib/mws/orders/service_status.rb +24 -0
  17. data/lib/mws/orders/service_status_message.rb +15 -0
  18. data/lib/mws/orders/shipping_address.rb +35 -0
  19. data/lib/mws/orders/tokenable.rb +10 -0
  20. data/lib/mws/orders/version.rb +1 -1
  21. data/test/integration/test_integration.rb +26 -0
  22. data/test/mws/orders/test_entity.rb +88 -0
  23. data/test/{parsers/order_test.rb → mws/orders/test_order.rb} +11 -6
  24. data/test/{parsers/order_item_test.rb → mws/orders/test_order_item.rb} +4 -4
  25. data/test/mws/orders/test_order_items.rb +19 -0
  26. data/test/mws/orders/test_orders.rb +19 -0
  27. data/test/mws/orders/test_parser.rb +7 -0
  28. data/test/mws/orders/test_payment_execution_detail.rb +15 -0
  29. data/test/mws/orders/test_payment_execution_detail_item.rb +16 -0
  30. data/test/mws/orders/test_service_status.rb +24 -0
  31. data/test/mws/orders/test_service_status_message.rb +16 -0
  32. data/test/{parsers/shipping_address_test.rb → mws/orders/test_shipping_address.rb} +4 -4
  33. data/test/test_helper.rb +15 -6
  34. metadata +67 -134
  35. data/lib/mws/orders/client.rb +0 -88
  36. data/lib/mws/orders/helpers/parameters.rb +0 -53
  37. data/lib/mws/orders/helpers/structured_list.rb +0 -40
  38. data/lib/mws/orders/parsers/base.rb +0 -27
  39. data/lib/mws/orders/parsers/collection.rb +0 -22
  40. data/lib/mws/orders/parsers/invoice_data.rb +0 -23
  41. data/lib/mws/orders/parsers/model.rb +0 -38
  42. data/lib/mws/orders/parsers/order.rb +0 -108
  43. data/lib/mws/orders/parsers/order_item.rb +0 -107
  44. data/lib/mws/orders/parsers/order_items.rb +0 -17
  45. data/lib/mws/orders/parsers/orders.rb +0 -17
  46. data/lib/mws/orders/parsers/payment_execution_detail.rb +0 -17
  47. data/lib/mws/orders/parsers/payment_execution_detail_item.rb +0 -15
  48. data/lib/mws/orders/parsers/service_status.rb +0 -32
  49. data/lib/mws/orders/parsers/service_status_message.rb +0 -15
  50. data/lib/mws/orders/parsers/shipping_address.rb +0 -35
  51. data/lib/mws/orders/requests/base.rb +0 -55
  52. data/lib/mws/orders/requests/order_items.rb +0 -23
  53. data/lib/mws/orders/requests/orders.rb +0 -36
  54. data/lib/mws/orders/requests/service_status.rb +0 -18
  55. data/test/fixtures/mws.yml +0 -12
  56. data/test/helpers/parameters_test.rb +0 -34
  57. data/test/helpers/structured_list_test.rb +0 -17
  58. data/test/integration/order_items_test.rb +0 -16
  59. data/test/integration/orders_test.rb +0 -17
  60. data/test/integration/service_status_test.rb +0 -9
  61. data/test/integration/test_helper.rb +0 -12
  62. data/test/parsers/collection_test.rb +0 -7
  63. data/test/parsers/model_test.rb +0 -27
  64. data/test/parsers/order_items_test.rb +0 -13
  65. data/test/parsers/orders_test.rb +0 -13
  66. data/test/parsers/payment_execution_detail_item_test.rb +0 -16
  67. data/test/parsers/payment_execution_detail_test.rb +0 -13
  68. data/test/parsers/service_status_message_test.rb +0 -16
  69. data/test/parsers/service_status_test.rb +0 -38
  70. data/test/parsers/test_helper.rb +0 -10
  71. data/test/requests/order_items_test.rb +0 -36
  72. data/test/requests/orders_test.rb +0 -46
  73. data/test/requests/service_status_test.rb +0 -22
  74. 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
@@ -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
@@ -1,10 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- class ParserTest < MiniTest::Test
4
- def fixture(type)
5
- file = File.expand_path("../../fixtures/#{type}.xml", __FILE__)
6
- body = File.read(file)
7
-
8
- Nokogiri(body)
9
- end
10
- end
@@ -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