amazon-mws-plus 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.project +12 -0
  4. data/Gemfile +13 -0
  5. data/README.markdown +30 -0
  6. data/Rakefile +50 -0
  7. data/amazon-mws-plus.gemspec +23 -0
  8. data/amazon-mws.tmproj +27 -0
  9. data/examples/xml/cancel_feed_submissions.xml +16 -0
  10. data/examples/xml/cancel_fulfillment_order.xml +6 -0
  11. data/examples/xml/cancel_report_requests.xml +18 -0
  12. data/examples/xml/create_fulfillment_order.xml +6 -0
  13. data/examples/xml/error.xml +10 -0
  14. data/examples/xml/get_feed_submission_count.xml +10 -0
  15. data/examples/xml/get_feed_submission_list.xml +18 -0
  16. data/examples/xml/get_feed_submission_list_by_next_token.xml +16 -0
  17. data/examples/xml/get_feed_submission_result.xml +30 -0
  18. data/examples/xml/get_fulfillment_order.xml +113 -0
  19. data/examples/xml/get_fulfillment_preview.xml +148 -0
  20. data/examples/xml/get_matching_product.xml +115 -0
  21. data/examples/xml/get_matching_product_for_id.xml +119 -0
  22. data/examples/xml/get_report.xml +237 -0
  23. data/examples/xml/get_report_count.xml +9 -0
  24. data/examples/xml/get_report_list.xml +17 -0
  25. data/examples/xml/get_report_request_count.xml +8 -0
  26. data/examples/xml/get_report_request_list.xml +120 -0
  27. data/examples/xml/get_report_request_list_by_next_token.xml +20 -0
  28. data/examples/xml/get_report_schedule_count.xml +10 -0
  29. data/examples/xml/get_report_schedule_list.xml +15 -0
  30. data/examples/xml/get_report_schedule_list_by_next_token.xml +15 -0
  31. data/examples/xml/list_all_fulfillment_orders.xml +69 -0
  32. data/examples/xml/list_all_fulfillment_orders_by_next_token.xml +61 -0
  33. data/examples/xml/manage_report_schedule.xml +14 -0
  34. data/examples/xml/orders_request.xml +39 -0
  35. data/examples/xml/request_order_items.xml +51 -0
  36. data/examples/xml/request_order_items_by_next_token.xml +51 -0
  37. data/examples/xml/request_orders.xml +43 -0
  38. data/examples/xml/request_orders_by_next_token.xml +69 -0
  39. data/examples/xml/request_report.xml +17 -0
  40. data/examples/xml/submit_feed.xml +14 -0
  41. data/examples/xml/update_report_acknowledgements.xml +18 -0
  42. data/examples/xsd/Inventory.xsd +49 -0
  43. data/examples/xsd/Item.xsd +285 -0
  44. data/examples/xsd/Listings.xsd +32 -0
  45. data/examples/xsd/OrderAcknowledgement.xsd +55 -0
  46. data/examples/xsd/OrderAdjustment.xsd +94 -0
  47. data/examples/xsd/OrderFulfillment.xsd +57 -0
  48. data/examples/xsd/Override.xsd +48 -0
  49. data/examples/xsd/Price.xsd +59 -0
  50. data/examples/xsd/ProcessingReport.xsd +87 -0
  51. data/examples/xsd/Product.xsd +220 -0
  52. data/examples/xsd/Product/AutoAccessory.xsd +807 -0
  53. data/examples/xsd/Product/Beauty.xsd +114 -0
  54. data/examples/xsd/Product/CE.xsd +544 -0
  55. data/examples/xsd/Product/CameraPhoto.xsd +2410 -0
  56. data/examples/xsd/Product/FoodAndBeverages.xsd +270 -0
  57. data/examples/xsd/Product/Gourmet.xsd +85 -0
  58. data/examples/xsd/Product/Health.xsd +189 -0
  59. data/examples/xsd/Product/Home.xsd +654 -0
  60. data/examples/xsd/Product/Jewelry.xsd +603 -0
  61. data/examples/xsd/Product/Miscellaneous.xsd +157 -0
  62. data/examples/xsd/Product/MusicalInstruments.xsd +853 -0
  63. data/examples/xsd/Product/Office.xsd +550 -0
  64. data/examples/xsd/Product/PetSupplies.xsd +40 -0
  65. data/examples/xsd/Product/ProductClothing.xsd +197 -0
  66. data/examples/xsd/Product/SWVG.xsd +238 -0
  67. data/examples/xsd/Product/Sports.xsd +308 -0
  68. data/examples/xsd/Product/TiresAndWheels.xsd +159 -0
  69. data/examples/xsd/Product/Tools.xsd +62 -0
  70. data/examples/xsd/Product/ToysBaby.xsd +241 -0
  71. data/examples/xsd/Product/Wireless.xsd +77 -0
  72. data/examples/xsd/ProductImage.xsd +39 -0
  73. data/examples/xsd/Relationship.xsd +47 -0
  74. data/examples/xsd/SettlementReport.xsd +158 -0
  75. data/examples/xsd/amzn-base.xsd +1600 -0
  76. data/examples/xsd/amzn-envelope.xsd +98 -0
  77. data/examples/xsd/amzn-header.xsd +45 -0
  78. data/lib/amazon-mws.rb +6 -0
  79. data/lib/amazon/mws.rb +69 -0
  80. data/lib/amazon/mws/authentication.rb +10 -0
  81. data/lib/amazon/mws/authentication/query_string.rb +36 -0
  82. data/lib/amazon/mws/authentication/signature.rb +43 -0
  83. data/lib/amazon/mws/base.rb +74 -0
  84. data/lib/amazon/mws/connection.rb +107 -0
  85. data/lib/amazon/mws/connection/management.rb +95 -0
  86. data/lib/amazon/mws/connection/request_builder.rb +67 -0
  87. data/lib/amazon/mws/exceptions.rb +55 -0
  88. data/lib/amazon/mws/lib/extensions.rb +178 -0
  89. data/lib/amazon/mws/lib/memoizable.rb +10 -0
  90. data/lib/amazon/mws/request/feed.rb +276 -0
  91. data/lib/amazon/mws/request/feed_builder.rb +83 -0
  92. data/lib/amazon/mws/request/fulfillment.rb +50 -0
  93. data/lib/amazon/mws/request/orders.rb +107 -0
  94. data/lib/amazon/mws/request/products.rb +38 -0
  95. data/lib/amazon/mws/request/report.rb +330 -0
  96. data/lib/amazon/mws/response.rb +43 -0
  97. data/lib/amazon/mws/response/feed/cancel_feed_submissions_response.rb +15 -0
  98. data/lib/amazon/mws/response/feed/get_feed_submission_count_response.rb +13 -0
  99. data/lib/amazon/mws/response/feed/get_feed_submission_list_by_next_token_response.rb +17 -0
  100. data/lib/amazon/mws/response/feed/get_feed_submission_list_response.rb +16 -0
  101. data/lib/amazon/mws/response/feed/get_feed_submission_result_response.rb +54 -0
  102. data/lib/amazon/mws/response/feed/models/feed_submission.rb +16 -0
  103. data/lib/amazon/mws/response/feed/submit_feed_response.rb +15 -0
  104. data/lib/amazon/mws/response/fulfillment_order/cancel_fulfillment_order_response.rb +11 -0
  105. data/lib/amazon/mws/response/fulfillment_order/create_fulfillment_order_response.rb +12 -0
  106. data/lib/amazon/mws/response/fulfillment_order/get_fulfillment_order_response.rb +19 -0
  107. data/lib/amazon/mws/response/fulfillment_order/list_all_fulfillment_orders_by_next_token_response.rb +16 -0
  108. data/lib/amazon/mws/response/fulfillment_order/list_all_fulfillment_orders_response.rb +15 -0
  109. data/lib/amazon/mws/response/fulfillment_order/models/fulfillment_address.rb +18 -0
  110. data/lib/amazon/mws/response/fulfillment_order/models/fulfillment_order.rb +24 -0
  111. data/lib/amazon/mws/response/fulfillment_order/models/fulfillment_order_item.rb +20 -0
  112. data/lib/amazon/mws/response/fulfillment_order/models/fulfillment_shipment.rb +18 -0
  113. data/lib/amazon/mws/response/fulfillment_order/models/fulfillment_shipment_item.rb +14 -0
  114. data/lib/amazon/mws/response/order/models/order.rb +43 -0
  115. data/lib/amazon/mws/response/order/models/order_item.rb +48 -0
  116. data/lib/amazon/mws/response/order/models/promotion_id.rb +9 -0
  117. data/lib/amazon/mws/response/order/request_get_order_response.rb +15 -0
  118. data/lib/amazon/mws/response/order/request_order_items_response.rb +25 -0
  119. data/lib/amazon/mws/response/order/request_orders_response.rb +28 -0
  120. data/lib/amazon/mws/response/product/get_matching_proudct.rb +31 -0
  121. data/lib/amazon/mws/response/product/models/product.rb +36 -0
  122. data/lib/amazon/mws/response/report/cancel_report_requests_response.rb +16 -0
  123. data/lib/amazon/mws/response/report/get_report_count_response.rb +13 -0
  124. data/lib/amazon/mws/response/report/get_report_list_response.rb +17 -0
  125. data/lib/amazon/mws/response/report/get_report_request_count_response.rb +13 -0
  126. data/lib/amazon/mws/response/report/get_report_request_list_by_next_token_response.rb +17 -0
  127. data/lib/amazon/mws/response/report/get_report_request_list_response.rb +17 -0
  128. data/lib/amazon/mws/response/report/get_report_schedule_count_response.rb +13 -0
  129. data/lib/amazon/mws/response/report/get_report_schedule_list_by_next_token_response.rb +17 -0
  130. data/lib/amazon/mws/response/report/get_report_schedule_list_response.rb +17 -0
  131. data/lib/amazon/mws/response/report/manage_report_schedule_response.rb +16 -0
  132. data/lib/amazon/mws/response/report/models/report_info.rb +16 -0
  133. data/lib/amazon/mws/response/report/models/report_request.rb +20 -0
  134. data/lib/amazon/mws/response/report/models/report_schedule.rb +13 -0
  135. data/lib/amazon/mws/response/report/request_report_response.rb +15 -0
  136. data/lib/amazon/mws/response/report/update_reports_acknowledgements_response.rb +16 -0
  137. data/lib/amazon/mws/response/response.rb +43 -0
  138. data/lib/amazon/mws/response/response_error.rb +21 -0
  139. data/test/connection_test.rb +14 -0
  140. data/test/feed_builder_test.rb +74 -0
  141. data/test/feed_test.rb +144 -0
  142. data/test/fulfillment_order.rb +49 -0
  143. data/test/orders_test.rb +78 -0
  144. data/test/products_test.rb +28 -0
  145. data/test/query_string_test.rb +18 -0
  146. data/test/report_test.rb +88 -0
  147. data/test/response_test.rb +172 -0
  148. data/test/signature_test.rb +32 -0
  149. data/test/test_config.yml +6 -0
  150. data/test/test_helper.rb +33 -0
  151. metadata +335 -0
@@ -0,0 +1,21 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class ResponseError < Response
5
+ xml_name "ErrorResponse"
6
+
7
+ xml_reader :type, :in => "Error"
8
+ xml_reader :code, :in => "Error"
9
+ xml_reader :message, :in => "Error"
10
+ xml_reader :detail, :in => "Error"
11
+ xml_reader :request_id
12
+ end
13
+
14
+ class RequestTimeout < ResponseError
15
+ end
16
+
17
+ class InternalError < ResponseError
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class ConnectionTest < Minitest::Test
4
+ def setup
5
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
+ @connection = Amazon::MWS::Base.new(@config)
7
+ end
8
+
9
+ def test_connection_functions
10
+ assert_kind_of Amazon::MWS::Connection, @connection.connection
11
+ assert @connection.connected?
12
+ end
13
+
14
+ end
@@ -0,0 +1,74 @@
1
+ require 'test_helper'
2
+
3
+ class FeedTest < Minitest::Test
4
+ def setup
5
+ end
6
+
7
+ def test_nothing
8
+ msgs = [
9
+ { "Product" => "somethinglame",
10
+ "NestedHash" => {"hash"=> 7},
11
+ "NestedArray" => [{"NA1"=> 1}, {"NA2"=> 2}]
12
+ } ,
13
+ { "Product" => "lame1",
14
+ "NestedHash" => {"hash"=> 8},
15
+ "NestedArray" => [{"NA1"=> 1}, {"NA2"=> 2}]
16
+ } ,
17
+ ];
18
+ fb = Amazon::MWS::FeedBuilder.new(:product, msgs)
19
+ assert_instance_of FeedBuilder, fb
20
+ xml = fb.render
21
+ assert_instance_of String, xml
22
+ end
23
+
24
+ def test_element_with_attribute
25
+ fb = Amazon::MWS::FeedBuilder.new(:product_data)
26
+ fb.xml.ShippingWeight('1', 'unitOfMeasure'=>'LB')
27
+
28
+ fb2 = Amazon::MWS::FeedBuilder.new(:product_data)
29
+ fb2.xml.tag!('ShippingWeight', '1', 'unitOfMeasure'=>'LB')
30
+ assert_equal fb.render, fb2.render
31
+
32
+ messages = [{
33
+ #'MessageID' => 2,
34
+ 'OperationType' => 'Update',
35
+ 'Product'=> {
36
+ 'SKU'=>'sku1324234324',
37
+ 'ItemPackageQuantity'=>'1',
38
+ 'NumberOfItems'=>'1',
39
+ 'StandardProductID'=>{'Type'=>'UPC', 'Value'=>'814digitstring'},
40
+ 'DescriptionData'=>[
41
+ {'Title'=>'title'},
42
+ {'BulletPoint'=>['bp1', 'bp2']},
43
+ {'ShippingWeight'=>['1', 'unitOfMeasure'=>'LB']}, #TODO value is probably not the right term
44
+ {'MSRP'=>'5.43'},
45
+ {'SearchTerms' => 'asdf1'},
46
+ {'SearchTerms' => 'asdf2'}
47
+ ],#DescriptionData
48
+ 'ProductData' => {
49
+ 'Clothing'=>{
50
+ "VariationData"=> {
51
+ "Parentage"=>"child",
52
+ "Size"=>"size",
53
+ "Color"=>"color",
54
+ "VariationTheme"=>"SizeColor"
55
+ }, #VariationData
56
+ 'ClassificationData'=>[
57
+ {'ClothingType'=>'Accessory'},
58
+ {'Department'=>'d1'},
59
+ {'Department'=>'d2'}, # max 10
60
+ {'StyleKeywords'=>'style1'},
61
+ {'StyleKeywords'=>'style2'}, # max 10
62
+ {'OccasionAndLifestyle'=>'ol1'},
63
+ {'OccasionAndLifestyle'=>'ol2'} # max 10
64
+ ]#ClassificationData
65
+ }#Clothing
66
+ }#ProductData
67
+ }#Product
68
+ }]
69
+ fb3 = Amazon::MWS::FeedBuilder.new(:product_data, messages)
70
+ #puts fb3.render
71
+ assert_kind_of String, fb3.render
72
+ end
73
+
74
+ end
@@ -0,0 +1,144 @@
1
+ require 'test_helper'
2
+
3
+ class FeedTest < Minitest::Test
4
+ def setup
5
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
+ @connection = Amazon::MWS::Base.new(@config)
7
+ end
8
+
9
+ def test_submit_feed_non_stubbed
10
+ response = @connection.submit_feed(:product_data,'Product',[{ 'sku'=>'234234234234', 'product-name'=>'name name name' }])
11
+ assert_kind_of ResponseError, response
12
+ end
13
+
14
+ def test_submit_flat_file_feed
15
+ @connection.stubs(:post).returns(xml_for('submit_feed',200))
16
+ response = @connection.submit_flat_file_feed(["234234234234\tname name name\t"],false)
17
+ assert_kind_of SubmitFeedResponse, response
18
+ end
19
+
20
+ def test_submit_feed
21
+ @connection.stubs(:post).returns(xml_for('submit_feed',200))
22
+
23
+ messages = [{
24
+ #'MessageID' => 2,
25
+ 'OperationType' => 'Update',
26
+ 'Product'=> {
27
+ 'SKU'=>'sku1324234324',
28
+ 'ItemPackageQuantity'=>'1',
29
+ 'NumberOfItems'=>'1',
30
+ 'StandardProductID'=>{'Type'=>'UPC', 'Value'=>'814digitstring'},
31
+ 'DescriptionData'=>[
32
+ {'Title'=>'title'},
33
+ {'Brand'=>'brand'},
34
+ {'Designer'=>'designer'},
35
+ {'Description'=>'description'}, # max length 2000
36
+ {'BulletPoint'=>'bp1'},
37
+ {'BulletPoint'=>'bp2'}, # max 5
38
+ {'ShippingWeight'=>['1'=>'2', 'unitOfMeasure'=>'LB']}, #TODO value is probably not the right term
39
+ {'MSRP'=>'5.43'},
40
+ {'SearchTerms' => 'asdf1'},
41
+ {'SearchTerms' => 'asdf2'},
42
+ {'IsGiftWrapAvailable'=>'True'},
43
+ {'IsGiftMessageAvailable'=>'True'}
44
+ ],#DescriptionData
45
+ 'ProductData' => {
46
+ 'Clothing'=>{
47
+ "VariationData"=> {
48
+ "Parentage"=>"child",
49
+ "Size"=>"size",
50
+ "Color"=>"color",
51
+ "VariationTheme"=>"SizeColor"
52
+ }, #VariationData
53
+ 'ClassificationData'=>[
54
+ {'ClothingType'=>'Accessory'},
55
+ {'Department'=>'d1'},
56
+ {'Department'=>'d2'}, # max 10
57
+ {'StyleKeywords'=>'style1'},
58
+ {'StyleKeywords'=>'style2'}, # max 10
59
+ {'OccasionAndLifestyle'=>'ol1'},
60
+ {'OccasionAndLifestyle'=>'ol2'} # max 10
61
+ ]#ClassificationData
62
+ }#Clothing
63
+ }#ProductData
64
+ }#Product
65
+ }]
66
+
67
+ response = @connection.submit_feed('product_data','Product',messages)
68
+ assert_kind_of SubmitFeedResponse, response
69
+ assert_equal '2291326430', response.feed_submission.id
70
+ assert_equal Feed::PROCESSING_STATUSES[:submitted], response.feed_submission.feed_processing_status
71
+ assert_equal Feed::FEED_TYPES[:product_data], response.feed_submission.feed_type
72
+ end
73
+
74
+ def test_get_feed_submission_list_failure
75
+ # Without stubbing, to test request code
76
+ response = @connection.get_feed_submission_list
77
+ assert_kind_of ResponseError, response
78
+
79
+ # With stubbing
80
+ @connection.stubs(:get).returns(xml_for('error',401))
81
+ response = @connection.get_feed_submission_list
82
+ assert_kind_of ResponseError, response
83
+ end
84
+
85
+ def test_get_feed_submission_list_success
86
+ @connection.stubs(:get).returns(xml_for('get_feed_submission_list',200))
87
+ response = @connection.get_feed_submission_list
88
+ assert_kind_of GetFeedSubmissionListResponse, response
89
+ assert_equal true, response.has_next?
90
+ assert_equal '2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=', response.next_token
91
+ assert_equal '1105b931-6f1c-4480-8e97-f3b467840a9e', response.request_id
92
+ assert_equal 1, response.feed_submissions.count
93
+
94
+ fs = response.feed_submissions.first
95
+ assert_equal '2291326430', fs.id
96
+ assert_equal '_SUBMITTED_', fs.feed_processing_status
97
+ assert_equal Time.parse('2009-02-20T02:10:35+00:00'), fs.submitted_date
98
+ assert_equal Time.parse('2009-02-20T02:12:54+00:00'), fs.started_processing_date
99
+ assert_equal Time.parse('2009-02-20T02:14:13+00:00'), fs.completed_processing_date
100
+ assert_equal '_POST_PRODUCT_DATA_', fs.feed_type
101
+ end
102
+
103
+ def test_get_feed_submission_list_by_next_token
104
+ @connection.stubs(:get).returns(xml_for('get_feed_submission_list_by_next_token',200))
105
+ response = @connection.get_feed_submission_list_by_next_token('234234234234234234')
106
+ assert_kind_of GetFeedSubmissionListByNextTokenResponse, response
107
+ end
108
+
109
+ def test_get_feed_submission_count
110
+ @connection.stubs(:get).returns(xml_for('get_feed_submission_count',200))
111
+ response = @connection.get_feed_submission_count
112
+ assert_kind_of GetFeedSubmissionCountResponse, response
113
+ end
114
+
115
+ def test_cancel_feed_submissions
116
+ @connection.stubs(:get).returns(xml_for('cancel_feed_submissions',200))
117
+ response = @connection.cancel_feed_submissions
118
+ assert_kind_of CancelFeedSubmissionsResponse, response
119
+ end
120
+
121
+ def test_get_feed_submission_result
122
+ @connection.stubs(:get).returns(xml_for('get_feed_submission_result',200))
123
+ response = @connection.get_feed_submission_result('2342342342342342')
124
+ assert_kind_of GetFeedSubmissionResultResponse, response
125
+
126
+ assert_equal 'ProcessingReport', response.message_type
127
+ assert_equal 1, response.message.id
128
+ assert_equal '2060950676', response.message.document_transaction_id
129
+ assert_equal 'Complete', response.message.status_code
130
+ assert_equal 0, response.message.processing_summary.messages_processed
131
+ assert_equal 0, response.message.processing_summary.messages_successful
132
+ assert_equal 1, response.message.processing_summary.messages_with_error
133
+ assert_equal 0, response.message.processing_summary.messages_with_warning
134
+ assert_equal 1, response.message.results.count
135
+
136
+ r = response.message.results.first
137
+ assert_equal 0, r.message_id
138
+ assert_equal 'Error', r.result_code
139
+ assert_equal '6001', r.message_code
140
+ assert_equal 'XML parsing fatal error at line 1, column 1: Invalid document structure', r.description
141
+ assert_equal '0', r.sku
142
+ end
143
+
144
+ end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class FulfillmentOrderTest < Minitest::Test
4
+
5
+ def setup
6
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
7
+ @connection = Amazon::MWS::Base.new(@config)
8
+ end
9
+
10
+ def test_get_fulfillmet_order
11
+ @connection.stubs(:post).returns(xml_for('get_fulfillment_order',200))
12
+ response = @connection.get_fulfillment_order('test')
13
+ assert_kind_of GetFulfillmentOrderResponse, response
14
+ assert response.fulfillment_order
15
+ assert !response.fulfillment_order_items.blank?
16
+ assert 2, response.fulfillment_order_items.size
17
+ assert 2, response.fulfillment_shipments.size
18
+ assert response.fulfillment_shipments.first
19
+ end
20
+
21
+ def test_list_all_fulfillmet_orders
22
+ @connection.stubs(:post).returns(xml_for('list_all_fulfillment_orders',200))
23
+ response = @connection.list_all_fulfillment_orders(DateTime.now.iso8601)
24
+ assert_kind_of ListAllFulfillmentOrdersResponse, response
25
+ assert 2, response.fulfillment_orders.size
26
+ end
27
+
28
+ def test_list_all_fulfillmet_orders_by_next_token
29
+ @connection.stubs(:post).returns(xml_for('list_all_fulfillment_orders_by_next_token',200))
30
+ response = @connection.list_all_fulfillment_orders_by_next_token('token')
31
+ assert_kind_of ListAllFulfillmentOrdersByNextTokenResponse, response
32
+ assert 2, response.fulfillment_orders.size
33
+ end
34
+
35
+ def test_create_fulfillment_order
36
+ @connection.stubs(:post).returns(xml_for('create_fulfillment_order',200))
37
+ response = @connection.create_fulfillment_order({})
38
+ assert_kind_of CreateFulfillmentOrderResponse, response
39
+ assert !response.request_id.blank?
40
+ end
41
+
42
+ def test_cancel_fulfillment_order
43
+ @connection.stubs(:post).returns(xml_for('cancel_fulfillment_order',200))
44
+ response = @connection.cancel_fulfillment_order("test")
45
+ assert_kind_of CancelFulfillmentOrderResponse, response
46
+ assert !response.request_id.blank?
47
+ end
48
+
49
+ end
@@ -0,0 +1,78 @@
1
+ require 'test_helper'
2
+
3
+ class OrdersTest < Minitest::Test
4
+ def setup
5
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
+ @connection = Amazon::MWS::Base.new(@config)
7
+ end
8
+
9
+ def test_get_orders_list
10
+ @connection.stubs(:post).returns(xml_for('request_orders',200))
11
+ date = DateTime.parse('2010-10-05T18:12:20.000Z')
12
+ response = @connection.get_orders_list(
13
+ :last_updated_after => date.iso8601,
14
+ :results_per_page => 100,
15
+ :fulfillment_channel => ["MFN","AFN"],
16
+ :order_status => ["Unshipped", "PartiallyShipped", "Shipped", "Unfulfillable"],
17
+ :marketplace_id => ['ATVPDKIKX0DER']
18
+ )
19
+ assert_kind_of RequestOrdersResponse, response
20
+ assert !response.accessors.include?("code")
21
+ assert_equal '2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=', response.next_token
22
+ assert_equal date.iso8601, response.last_updated_before.iso8601
23
+
24
+ assert_kind_of Hash, response.as_hash
25
+
26
+ response = @connection.get_orders_list(:raw_xml => true)
27
+ assert_kind_of Net::HTTPOK, response
28
+ end
29
+
30
+ # to test query string
31
+ def test_get_orders_list_by_next_token_not_stubbed
32
+ response = @connection.get_orders_list_by_next_token(:next_token => '>9Sy1rjELHa2v06krKetbKrtwX7u5furPkr1n0nQYpwbNeGyEmOrLe7q8xqAchQNKurwYODTEdyqfJudhyYNc3fBN7lmKh5MlkHdivTziOHySXS65MVd54C88gfetEbGyGRFlAxb7U+eIBJtw5YQ8FDkC5gCMX3pTkWJZSz0xK1jWd/9Nyx/qDb+ZPyEg4XuzI9jEWs+xHadFX56hGcf21iVPmzhWL2hkkWxTwkMTFhirNZST/hMq2s+uAlnst6Vo8u7BHPNLl2qLGNRdpjPaV/R76L5V7brQx+mIjiAqdq7XKs1Ol1dxk5J7UX1K6D3SrVAlRqj6TtUD2s1QD6a1FegLh44xPVWbZvsy0W2YjOIO+BUh5AtWjoNqlERy2ZulUJHWppbPRMZyYJp4zi6rPGQ==')
33
+ assert_kind_of ResponseError, response
34
+ end
35
+
36
+ def test_get_orders_list_by_next_token
37
+ @connection.stubs(:post).returns(xml_for('request_orders_by_next_token',200))
38
+ response = @connection.get_orders_list_by_next_token(:next_token => '>9Sy1rjELHa2v06krKetbKrtwX7u5furPkr1n0nQYpwbNeGyEmOrLe7q8xqAchQNKurwYODTEdyqfJudhyYNc3fBN7lmKh5MlkHdivTziOHySXS65MVd54C88gfetEbGyGRFlAxb7U+eIBJtw5YQ8FDkC5gCMX3pTkWJZSz0xK1jWd/9Nyx/qDb+ZPyEg4XuzI9jEWs+xHadFX56hGcf21iVPmzhWL2hkkWxTwkMTFhirNZST/hMq2s+uAlnst6Vo8u7BHPNLl2qLGNRdpjPaV/R76L5V7brQx+mIjiAqdq7XKs1Ol1dxk5J7UX1K6D3SrVAlRqj6TtUD2s1QD6a1FegLh44xPVWbZvsy0W2YjOIO+BUh5AtWjoNqlERy2ZulUJHWppbPRMZyYJp4zi6rPGQ==')
39
+ assert_kind_of RequestOrdersByNextTokenResponse, response
40
+
41
+ assert !response.accessors.include?("code")
42
+ assert_equal DateTime.parse('2012-04-18T20:57:22.000Z').iso8601, response.last_updated_before.iso8601
43
+ assert_equal '134-562342326-223434325', response.orders[0].amazon_order_id
44
+ assert_equal '133-5333444-743334440', response.orders[1].amazon_order_id
45
+
46
+ response = @connection.get_orders_list_by_next_token(:raw_xml => true)
47
+ assert_kind_of Net::HTTPOK, response
48
+ end
49
+
50
+ def test_get_list_order_items
51
+ @connection.stubs(:post).returns(xml_for('request_order_items',200))
52
+ response = @connection.get_list_order_items(:amazon_order_id => '134-562342326-223434325')
53
+ assert_kind_of RequestOrderItemsResponse, response
54
+
55
+ response = @connection.get_list_order_items(:raw_xml => true)
56
+ assert_kind_of Net::HTTPOK, response
57
+ end
58
+
59
+ def test_get_list_order_items_by_next_token
60
+ @connection.stubs(:post).returns(xml_for('request_order_items_by_next_token',200))
61
+ response = @connection.get_list_order_items_by_next_token(:next_token => '>9Sy1rjELHa2v06krKetbKrtwX7u5furPkr1n0nQYpwbNeGyEmOrLe7q8xqAchQNKurwYODTEdyqfJudhyYNc3fBN7lmKh5MlkHdivTziOHySXS65MVd54C88gfetEbGyGRFlAxb7U+eIBJtw5YQ8FDkC5gCMX3pTkWJZSz0xK1jWd/9Nyx/qDb+ZPyEg4XuzI9jEWs+xHadFX56hGcf21iVPmzhWL2hkkWxTwkMTFhirNZST/hMq2s+uAlnst6Vo8u7BHPNLl2qLGNRdpjPaV/R76L5V7brQx+mIjiAqdq7XKs1Ol1dxk5J7UX1K6D3SrVAlRqj6TtUD2s1QD6a1FegLh44xPVWbZvsy0W2YjOIO+BUh5AtWjoNqlERy2ZulUJHWppbPRMZyYJp4zi6rPGQ==')
62
+ assert_kind_of RequestOrderItemsByNextTokenResponse, response
63
+
64
+ response = @connection.get_list_order_items_by_next_token(:raw_xml => true)
65
+ assert_kind_of Net::HTTPOK, response
66
+ end
67
+
68
+ def test_get_orders
69
+ @connection.stubs(:post).returns(xml_for('orders_request',200))
70
+ orders_arr = ['134-562342326-223434325', '133-5333444-743334440']
71
+ response = @connection.get_orders(:amazon_order_id=> orders_arr)
72
+ assert_kind_of RequestOrdersResponse, response
73
+
74
+ response = @connection.get_orders(:raw_xml => true)
75
+ assert_kind_of Net::HTTPOK, response
76
+ end
77
+
78
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class ProductsTest < Minitest::Test
4
+
5
+ def setup
6
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
7
+ @connection = Amazon::MWS::Base.new(@config)
8
+ end
9
+
10
+ def test_get_matching_product
11
+ @connection.stubs(:post).returns(xml_for('get_matching_product',200))
12
+ response = @connection.get_matching_product(["B00828DQGM"])
13
+ assert_kind_of GetMatchingProductResponse, response
14
+
15
+ response = @connection.get_matching_product(["B00828DQGM"], {:raw_xml => true})
16
+ assert_kind_of Net::HTTPOK, response
17
+ end
18
+
19
+ def test_get_matching_product_for_id
20
+ @connection.stubs(:post).returns(xml_for('get_matching_product_for_id',200))
21
+ response = @connection.get_matching_product_for_id('ASIN',["B00828DQGM"])
22
+ assert_kind_of GetMatchingProductForIdResponse, response
23
+
24
+ response = @connection.get_matching_product_for_id('ASIN',["B00828DQGM"], :raw_xml => true)
25
+ assert_kind_of Net::HTTPOK, response
26
+ end
27
+
28
+ end
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ class QueryStringTest < Minitest::Test
4
+ def setup
5
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
+ end
7
+
8
+ def test_expected_string
9
+ string = Amazon::MWS::Authentication::QueryString.new({
10
+ :merchant_id => @config['merchant_id'],
11
+ :marketplace_id => @config['marketplace_id'],
12
+ :access_key => @config['access_key'],
13
+ :secret_access_key => @config['secret_access_key'],
14
+ :path => '/?AWSAccessKeyId=opensesame&Marketplace=9876&Merchant=12345&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-03-28T10%3A32%3A40%2B02%3A00&Version=2011-01-01&Action=SubmitFeed&FeedType=_POST_PRODUCT_DATA_&Signature=4pGYXLxB9T7Gwon1BcIIeVHIxfgr3qxS3eSIwzmsGKo%3D'
15
+ })
16
+ assert_kind_of(String, string)
17
+ end
18
+ end
@@ -0,0 +1,88 @@
1
+ require 'test_helper'
2
+
3
+ class ReportTest < Minitest::Test
4
+ def setup
5
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
+ @connection = Amazon::MWS::Base.new(@config)
7
+ end
8
+
9
+ def test_request_report
10
+ @connection.stubs(:get).returns(xml_for('request_report',200))
11
+
12
+ response = @connection.request_report(:flat_file_orders)
13
+ assert_kind_of RequestReportResponse, response
14
+
15
+ response = @connection.request_report(:flat_file_orders, :start_date => Time.now.iso8601, :end_date => Time.now.iso8601)
16
+ assert_kind_of RequestReportResponse, response
17
+ end
18
+
19
+ def test_get_report_request_list
20
+ @connection.stubs(:get).returns(xml_for('get_report_request_list',200))
21
+ response = @connection.get_report_request_list()
22
+ assert_kind_of GetReportRequestListResponse, response
23
+
24
+ response = @connection.get_report_request_list('MaxCount' => 100)
25
+ assert_kind_of GetReportRequestListResponse, response
26
+ end
27
+
28
+ def test_get_report_request_list_by_next_token
29
+ @connection.stubs(:post).returns(xml_for('get_report_request_list_by_next_token',200))
30
+ response = @connection.get_report_request_list_by_next_token(:next_token=>'324532534534543543')
31
+ assert_kind_of GetReportRequestListByNextTokenResponse, response
32
+ end
33
+
34
+ def test_get_report_request_count
35
+ @connection.stubs(:get).returns(xml_for('get_report_request_count',200))
36
+ response = @connection.get_report_request_count
37
+ assert_kind_of GetReportRequestCountResponse, response
38
+ end
39
+
40
+ def test_cancel_report_requests
41
+ @connection.stubs(:get).returns(xml_for('cancel_report_requests',200))
42
+ response = @connection.cancel_report_requests
43
+ assert_kind_of CancelReportRequestsResponse, response
44
+ end
45
+
46
+ def test_get_report_list
47
+ @connection.stubs(:get).returns(xml_for('get_report_list',200))
48
+ response = @connection.get_report_list
49
+ assert_kind_of GetReportListResponse, response
50
+ end
51
+
52
+ def test_get_report_count
53
+ @connection.stubs(:get).returns(xml_for('get_report_count',200))
54
+ response = @connection.get_report_count
55
+ assert_kind_of GetReportCountResponse, response
56
+ end
57
+
58
+ def test_get_report
59
+ @connection.stubs(:get).returns(xml_for('get_report',200))
60
+ response = @connection.get_report('9053224163')
61
+ assert_kind_of String, response.body
62
+ end
63
+
64
+ def test_manage_report_schedule
65
+ @connection.stubs(:get).returns(xml_for('manage_report_schedule',200))
66
+ response = @connection.manage_report_schedule(:flat_file_open_listings,'1 hour')
67
+ assert_kind_of ManageReportScheduleResponse, response
68
+ end
69
+
70
+ def test_get_report_schedule_list
71
+ @connection.stubs(:get).returns(xml_for('get_report_schedule_list',200))
72
+ response = @connection.get_report_schedule_list
73
+ assert_kind_of GetReportScheduleListResponse, response
74
+ end
75
+
76
+ def test_get_report_schedule_list_by_next_token
77
+ @connection.stubs(:get).returns(xml_for('get_report_schedule_list_by_next_token',200))
78
+ response = @connection.get_report_schedule_list_by_next_token(:next_token=>'234234234324')
79
+ assert_kind_of GetReportScheduleListByNextTokenResponse, response
80
+ end
81
+
82
+ def test_get_report_schedule_count
83
+ @connection.stubs(:get).returns(xml_for('get_report_schedule_count',200))
84
+ response = @connection.get_report_schedule_count
85
+ assert_kind_of GetReportScheduleCountResponse, response
86
+ end
87
+
88
+ end