amazon-mws-plus 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
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,83 @@
1
+ require 'set'
2
+
3
+ module Amazon
4
+ module MWS
5
+
6
+ class FeedBuilder
7
+ attr_accessor :xml
8
+
9
+ def initialize(message_type, messages = [], params = {})
10
+ @xml = Builder::XmlMarkup.new(:indent=>2)
11
+ @message_type = message_type
12
+ @messages = messages
13
+ @params = params
14
+ @merchant_id = params[:merchant_id]
15
+ end
16
+
17
+ def render
18
+ @xml.instruct!
19
+ @xml.AmazonEnvelope("xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation"=>"amzn-envelope.xsd") do
20
+ render_header
21
+
22
+ envelope_params = { :message_type => @message_type }
23
+ envelope_params.merge!({:purge => @params[:purge]}) if Feed::PRODUCT_MESSAGE_TYPES.include?(@message_type) && @params[:purge]==true
24
+ render_envelope(envelope_params)
25
+
26
+ if !@messages.nil?
27
+ @messages.flatten.each_with_index do |message,i|
28
+ message = {'MessageID'=>i+1}.merge(message) if message[:MessageID].nil?
29
+ render_message(message, @params)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def render_header
36
+ @xml.Header do
37
+ @xml.DocumentVersion "1.01"
38
+ @xml.MerchantIdentifier @merchant_id
39
+ end
40
+ end
41
+
42
+ def render_envelope(params = {})
43
+ #@xml.EffectiveDate Time.now
44
+ @xml.MessageType(params[:message_type].to_s)
45
+ @xml.PurgeAndReplace(params[:purge]) if params[:purge]
46
+ end
47
+
48
+ def render_message(message, params = {})
49
+ if (message.is_a?(Hash) || message.is_a?(YAML::Omap))
50
+ @xml.Message do |xml|
51
+ build_xml(message, xml)
52
+ end
53
+ else
54
+ raise "Unknown type for: #{message.inspect}"
55
+ end
56
+ end
57
+
58
+ # Hack exceptional cases added for elements with 1 and 2 attributes
59
+ def build_xml(hash, xml)
60
+ hash.each {|key, value|
61
+ case value
62
+ when Hash then xml.tag!(key) {|xml| build_xml(value, xml) }
63
+ when YAML::Omap then xml.tag!(key) {|xml| build_xml(value, xml) }
64
+ #when Array then xml.tag!(key) {|xml| value.each {|v| build_xml(v, xml) } }
65
+ when Array then
66
+ case value.first
67
+ when Hash then xml.tag!(key) {|xml| value.each {|v| build_xml(v, xml) } }
68
+ else # array can include hashes for attributes, but not in the first slot
69
+ if value.length==2 && value[1].is_a?(Hash) && value[1].length==1 # first slot is not a hash, second might be (for attribute)
70
+ xml.tag!(key, value[0], value[1])
71
+ elsif value.length==3 && value[1].is_a?(Hash) && value[1].length==1 && value[2].is_a?(Hash) && value[2].length==1
72
+ xml.tag!(key, value[0], value[1], value[2])
73
+ else
74
+ value.each { |v| xml.tag!(key, v) } # accept array of non-hashes and create a <key>value_x</key> for each
75
+ end
76
+ end
77
+ else xml.tag!(key, value)
78
+ end
79
+ }
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,50 @@
1
+ module Amazon
2
+ module MWS
3
+ module Fulfillment
4
+
5
+ def get_fulfillment_order(fulfillment_order_id)
6
+ params = { "Action" => "GetFulfillmentOrder", "SellerFulfillmentOrderId" => fulfillment_order_id }
7
+ response = post(fulfillment_path,params)
8
+ return response if params[:raw_xml]
9
+ GetFulfillmentOrderResponse.format(response)
10
+ end
11
+
12
+ def list_all_fulfillment_orders(start_date_time, fulfillment_method=nil)
13
+ params = { "Action" => "ListAllFulfillmentOrders", "QueryStartDateTime" => start_date_time }
14
+ params.merge!("FulfillmentMethod" => fulfillment_method) if fulfillment_method
15
+ response = post(fulfillment_path,params)
16
+ return response if params[:raw_xml]
17
+ ListAllFulfillmentOrdersResponse.format(response)
18
+ end
19
+
20
+ def list_all_fulfillment_orders_by_next_token(token)
21
+ params = { "Action" => "ListAllFulfillmentOrdersByNextToken", "NextToken" => token }
22
+ response = post(fulfillment_path,params)
23
+ return response if params[:raw_xml]
24
+ ListAllFulfillmentOrdersByNextTokenResponse.format(response)
25
+ end
26
+
27
+ def create_fulfillment_order(order_params)
28
+ required_params = ["SellerFulfillmentOrderId", "DisplayableOrderId",'DisplayableOrderDateTime','DisplayableOrderComment','ShippingSpeedCategory', 'DestinationAddress','Items']
29
+ raise InvalidParams.new(required_params) unless (order_params.keys - required_params).empty?
30
+ params = { "Action" => "CreateFulfillmentOrder"}.merge(order_params)
31
+ response = post(fulfillment_path,params)
32
+ return response if params[:raw_xml]
33
+ CreateFulfillmentOrderResponse.format(response)
34
+ end
35
+
36
+ def cancel_fulfillment_order(order_id)
37
+ params = { "Action" => "CancelFulfillmentOrder", "SellerFulfillmentOrderId" => order_id }
38
+ response = post(fulfillment_path,params)
39
+ return response if params[:raw_xml]
40
+ CancelFulfillmentOrderResponse.format(response)
41
+ end
42
+
43
+ private
44
+ def fulfillment_path
45
+ "/FulfillmentOutboundShipment/#{Authentication::FULFILLMENT_VERSION}"
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,107 @@
1
+ module Amazon
2
+ module MWS
3
+ module Orders
4
+
5
+ def get_orders_list(params ={})
6
+ query_params = { "Action" => "ListOrders" }
7
+ query_params.merge!({"CreatedAfter" => params[:created_after]}) if params[:created_after]
8
+ query_params.merge!({"CreatedBefore" => params[:created_before]}) if params[:created_before]
9
+ query_params.merge!({"LastUpdatedAfter" =>params[:last_updated_after]}) if params[:last_updated_after]
10
+ query_params.merge!({"LastUpdatedBefore" => params[:last_updated_before]}) if params[:last_updated_before]
11
+ query_params.merge!({"BuyerEmail" => params[:buyer_email]}) if params[:buyer_email]
12
+ query_params.merge!({"SellerOrderId" => params[:seller_order_id]}) if params[:seller_order_id]
13
+ query_params.merge!({"MaxResultsPerPage" => params[:results_per_page]}) if params[:results_per_page]
14
+
15
+ if params[:fulfillment_channel]
16
+ params[:fulfillment_channel].to_a.each_with_index{|channel,i| query_params.merge!({"FulfillmentChannel.Channel.#{i+1}" => channel})}
17
+ end
18
+
19
+ if params[:order_status]
20
+ params[:order_status].to_a.each_with_index{|status,i| query_params.merge!({"OrderStatus.Status.#{i+1}" => status})}
21
+ end
22
+
23
+ if params[:marketplace_id]
24
+ params[:marketplace_id].to_a.each_with_index{|id,i| query_params.merge!({"MarketplaceId.Id.#{i+1}" => id})}
25
+ end
26
+
27
+ response = post(order_path, query_params)
28
+ if params[:raw_xml]
29
+ return response
30
+ end
31
+ RequestOrdersResponse.format(response)
32
+ end
33
+
34
+ def get_orders_list_by_next_token(params ={})
35
+ next_token = params[:next_token]
36
+
37
+ query_params = {
38
+ "Action" => "ListOrdersByNextToken"
39
+ }
40
+ if next_token
41
+ query_params.merge!({"NextToken" => next_token})
42
+ end
43
+ response = post(order_path, query_params)
44
+ if params[:raw_xml]
45
+ return response
46
+ end
47
+ RequestOrdersByNextTokenResponse.format(response)
48
+ end
49
+
50
+ def get_list_order_items(params ={})
51
+ amazon_order_id = params[:amazon_order_id]
52
+
53
+ query_params = {
54
+ "Action" => "ListOrderItems"
55
+ }
56
+ if amazon_order_id
57
+ query_params.merge!({"AmazonOrderId" => amazon_order_id})
58
+ end
59
+ response = post(order_path, query_params)
60
+ if params[:raw_xml]
61
+ return response
62
+ end
63
+ RequestOrderItemsResponse.format(response)
64
+ end
65
+
66
+ def get_list_order_items_by_next_token(params ={})
67
+ next_token = params[:next_token]
68
+
69
+ query_params = {
70
+ "Action" => "ListOrderItemsByNextToken"
71
+ }
72
+
73
+ if next_token
74
+ query_params.merge!({"NextToken" => next_token})
75
+ end
76
+ response = post(order_path, query_params)
77
+ if params[:raw_xml]
78
+ return response
79
+ end
80
+ RequestOrderItemsByNextTokenResponse.format(response)
81
+ end
82
+
83
+ def get_orders(params ={})
84
+
85
+ query_params = {
86
+ "Action" => "GetOrder"
87
+ }
88
+
89
+ if params[:amazon_order_id]
90
+ params[:amazon_order_id].to_a.each_with_index{|id,i| query_params.merge!({"AmazonOrderId.Id.#{i+1}" => id})}
91
+ end
92
+
93
+ response = post(order_path, query_params)
94
+ if params[:raw_xml]
95
+ return response
96
+ end
97
+ RequestGetOrderResponse.format(response)
98
+ end
99
+
100
+ private
101
+ def order_path
102
+ "/Orders/#{Authentication::ORDERS_VERSION}"
103
+ end
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,38 @@
1
+ module Amazon
2
+ module MWS
3
+ module Products
4
+
5
+ def get_matching_product(asins, params={})
6
+ query_params = { "Action" => "GetMatchingProduct" }
7
+ query_params["MarketplaceId"] = params[:marketplace] || @connection.marketplace_id
8
+ asins.each_with_index{|id,i| query_params.merge!({"ASINList.ASIN.#{i+1}" => id})}
9
+
10
+ response = post(product_path, query_params)
11
+
12
+ return response if params[:raw_xml]
13
+
14
+ GetMatchingProductResponse.format(response)
15
+ end
16
+
17
+ def get_matching_product_for_id(id_type, ids, params={})
18
+ query_params = { "Action" => "GetMatchingProductForId" }
19
+ query_params["MarketplaceId"] = params[:marketplace] || @connection.marketplace_id
20
+ query_params["IdType"] = id_type
21
+ ids.each_with_index{|id,i| query_params.merge!({"IdList.Id.#{i+1}" => id})}
22
+
23
+ response = post(product_path, query_params)
24
+
25
+ return response if params[:raw_xml]
26
+
27
+ GetMatchingProductForIdResponse.format(response)
28
+ end
29
+
30
+ private
31
+ def product_path
32
+ "/Products/#{Authentication::PRODUCTS_VERSION}"
33
+ end
34
+
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,330 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ module Report
5
+
6
+ #https://mws.amazon.com/docs/devGuide/index.html?ReportType.html
7
+ REPORT_TYPES = {
8
+ :flat_file_open_listings => '_GET_FLAT_FILE_OPEN_LISTINGS_DATA_',
9
+ :merchant_listing => '_GET_MERCHANT_LISTINGS_DATA_',
10
+ :merchant_listings_lite => '_GET_MERCHANT_LISTINGS_DATA_LITE_',
11
+ :merchant_listings_liter => '_GET_MERCHANT_LISTINGS_DATA_LITER_',
12
+ :merchant_canceled_listings => '_GET_MERCHANT_CANCELLED_LISTINGS_DATA_',
13
+ :nemo_merchant_listings => '_GET_NEMO_MERCHANT_LISTINGS_DATA_',
14
+ :afn_inventory => '_GET_AFN_INVENTORY_DATA_',
15
+ :flat_file_actionable_order => '_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_',
16
+ :orders => '_GET_ORDERS_DATA_', #API Function: ManageReportSchedule
17
+ :flat_file_order_report => '_GET_FLAT_FILE_ORDER_REPORT_DATA_', #API Function: ManageReportSchedule
18
+ :flat_file_orders => '_GET_FLAT_FILE_ORDERS_DATA_',
19
+ :converged_flat_file_order_report => '_GET_CONVERGED_FLAT_FILE_ORDER_REPORT_DATA_'
20
+ }
21
+
22
+ SCHEDULE = {
23
+ '15 minutes' => '_15_MINUTES_',
24
+ '30 minutes' => '_30_MINUTES_',
25
+ '1 hour' => '_1_HOUR_',
26
+ '2 hours' => '_2_HOURS_',
27
+ '4 hours' => '_4_HOURS_',
28
+ '8 hours' => '_8_HOURS_',
29
+ '12 hours' => '_12_HOURS_',
30
+ '1 day' => '_1_DAY_',
31
+ '2 days' => '_2_DAYS_',
32
+ '3 days' => '_72_HOURS_',
33
+ '7 days' => '_7_DAYS_',
34
+ '14 days' => '_14_DAYS_',
35
+ '15 days' => '_15_DAYS_',
36
+ '30 days' => '_30_DAYS_',
37
+ 'Delete' => '_NEVER_'
38
+ }
39
+
40
+ # The RequestReport operation requests the generation of a report, which
41
+ # creates a report request. Reports are retained for 90 days.
42
+ # Required Request Parameters
43
+ # ReportType - The type of report to request.
44
+ #
45
+ # Optional Request Parameters
46
+ # StartDate - Start of a date range used for selecting the data to report.
47
+ # EndDate - End of a date range used for selecting the data to report.
48
+
49
+ def request_report(report_type, params ={})
50
+ raise InvalidReportType if !REPORT_TYPES.include?(report_type)
51
+
52
+ query_params = { "Action" => "RequestReport", "ReportType" => REPORT_TYPES[report_type] }
53
+ query_params.merge!({"StartDate" => params[:start_date]}) if params[:start_date]
54
+ query_params.merge!({"EndDate" => params[:end_date]}) if params[:end_date]
55
+ response = get("/", query_params)
56
+
57
+ RequestReportResponse.format(response)
58
+ end
59
+
60
+ # GetReportRequestList
61
+ # --------------------
62
+ # The GetReportRequestList operation returns a list of report requests
63
+ # that match the query parameters.
64
+ #
65
+ # Amazon MWS limits calls to 1,000 total calls per hour per seller
66
+ # account, including calls to GetReportRequestList.
67
+ #
68
+ # The maximum number of results that will be returned in one call is one
69
+ # hundred. If there are additional results to return, HasNext will be
70
+ # returned in the response with a true value. To retrieve all the
71
+ # results, you can use the value of the NextToken parameter to call
72
+ # GetReportRequestListByNextToken until HasNext is false.
73
+
74
+ # Optional Request Parameters
75
+ #
76
+ # ReportRequestIdList - A structured list of report request IDs. If you
77
+ # pass in explicit IDs in this call, the other conditions, if specified,
78
+ # will be ignored.
79
+ #
80
+ # ReportTypeList - A structured ReportType list by which to filter
81
+ # reports.
82
+ #
83
+ # ReportProcessingStatusList -A structured list of report processing
84
+ # statuses by which to filter report requests.
85
+ #
86
+ # ReportProcessingStatus values:
87
+ #
88
+ # _SUBMITTED_
89
+ # _IN_PROGRESS_
90
+ # _CANCELLED_
91
+ # _DONE_
92
+ # _DONE_NO_DATA_
93
+ #
94
+ # MaxCount - Maximum number of reports to return in the list. If you
95
+ # specify a number greater than 100, the call will be rejected.
96
+ #
97
+ # RequestedFromDate - The earliest date you are looking for, in ISO8601
98
+ # date format (for example, "2008-07-03T18:12:22Z" or
99
+ # "2008-07-03T18:12:22.093-07:00").
100
+ #
101
+ # RequestedToDate - The most recent date you are looking for.
102
+
103
+ def get_report_request_list(params = {})
104
+ response = get("/", {"Action" => "GetReportRequestList"}.merge(params))
105
+ GetReportRequestListResponse.format(response)
106
+ end
107
+ # add a nice method
108
+ alias_method :report_request_list, :get_report_request_list
109
+
110
+ # GetReportRequestListByNextToken
111
+ # Description
112
+ #
113
+ # The GetReportRequestListByNextToken operation returns a list of report
114
+ # requests that match the query parameters, using the NextToken, which
115
+ # was supplied by a previous call to either
116
+ # GetReportRequestListByNextToken or a call to GetReportRequestList,
117
+ # where the value of HasNext was true in that previous call.
118
+
119
+ # NextToken
120
+ # Token returned in a previous call to either GetReportRequestList or
121
+ # GetReportRequestListByNextToken when the value of HasNext was true.
122
+
123
+ def get_report_request_list_by_next_token(next_token)
124
+ response =
125
+ post("/", {
126
+ "Action" => "GetReportRequestListByNextToken",
127
+ "NextToken" => next_token
128
+ })
129
+
130
+ GetReportRequestListByNextTokenResponse.format(response)
131
+ end
132
+
133
+ alias_method :report_request_list_by_next_token, :get_report_request_list_by_next_token
134
+
135
+ # GetReportRequestCount
136
+ # The GetReportRequestCount returns a count of report requests.
137
+
138
+ def get_report_request_count(params = {})
139
+ response = get("/", {"Action" => "GetReportRequestCount"})
140
+ GetReportRequestCountResponse.format(response)
141
+ end
142
+ # add a nice method
143
+ alias_method :report_request_count, :get_report_request_count
144
+
145
+ # CancelReportRequests
146
+ # The CancelReportRequests operation cancels one or more report
147
+ # requests, returning the count of the canceled report requests and the
148
+ # report request information. You can specify a number to cancel of
149
+ # greater than one hundred, but information will only be returned about
150
+ # the first one hundred report requests in the list. To return metadata
151
+ # about a greater number of canceled report requests, you can call
152
+ # GetReportRequestList. If report requests have already begun
153
+ # processing, they cannot be canceled.
154
+
155
+ #
156
+ # ReportRequestIdList
157
+ # A structured list of report request IDs. If you pass in explicit IDs in this call, the other conditions, if specified, will be ignored.
158
+ #
159
+ # ReportTypeList
160
+ # A structured ReportType list by which to filter reports.
161
+ #
162
+ # ReportProcessingStatusList
163
+ # A structured list of report processing statuses by which to filter report requests.
164
+ #
165
+ # ReportProcessingStatus
166
+ # _SUBMITTED_
167
+ # _IN_PROGRESS_
168
+ # _CANCELLED_
169
+ # _DONE_
170
+ # _DONE_NO_DATA_
171
+ #
172
+ # RequestedFromDate
173
+ # The earliest date you are looking for, in ISO8601 date format (for example, "2008-07-03T18:12:22Z" or "2008-07-03T18:12:22.093-07:00").
174
+ #
175
+ # RequestedToDate
176
+ # The most recent date you are looking for.
177
+
178
+ def cancel_report_requests(params = {})
179
+ response = get("/", {"Action" => "CancelReportRequests"}.merge(params))
180
+ CancelReportRequestsResponse.format(response)
181
+ end
182
+
183
+ # GetReportList
184
+ # The GetReportList operation returns a list of reports within the
185
+ # previous 90 days that match the query parameters. The maximum number
186
+ # of results that will be returned in one call is one hundred. If there
187
+ # are additional results to return, HasNext will be returned in the
188
+ # response with a true value. To retrieve all the results, you can use
189
+ # the value of the NextToken parameter to call GetReportListByNextToken
190
+ # until HasNext is false.
191
+ #
192
+ # Request Parameters
193
+
194
+ def get_report_list(params = {})
195
+ response = get("/", {"Action" => "GetReportList"}.merge(params))
196
+ GetReportListResponse.format(response)
197
+ end
198
+
199
+ alias_method :report_list, :get_report_list
200
+
201
+ # GetReportCount
202
+ # The GetReportCount operation returns a count of reports within the
203
+ # previous 90 days that are available for the seller to download.
204
+
205
+ # ReportTypeList
206
+ # A structured ReportType list by which to filter reports.
207
+ #
208
+ # Acknowledged
209
+ # Set to true to list reports that have been acknowledged with a prior
210
+ # call to UpdateReportAcknowledgements. Set to false to list reports
211
+ # that have not been acknowledged.
212
+ #
213
+ # AvailableFromDate
214
+ # The earliest date you are looking for, in ISO8601 date format (for
215
+ # example, "2008-07-03T18:12:22Z" or "2008-07-03T18:12:22.093-07:00").
216
+ #
217
+ # AvailableToDate
218
+ # The most recent date you are looking for.
219
+
220
+ def get_report_count(params = {})
221
+ response = get("/", {"Action" => "GetReportCount"})
222
+ GetReportCountResponse.format(response)
223
+ end
224
+
225
+ alias_method :report_count, :get_report_count
226
+
227
+ # GetReport
228
+ # Description
229
+ #
230
+ # The GetReport operation returns the contents of a report and the
231
+ # Content-MD5 header for the returned body. Reports are retained for 90
232
+ # days from the time they have been generated.
233
+ #
234
+ # Amazon MWS limits calls to 1,000 total calls per hour per seller
235
+ # account, including a limit of 60 calls per hour to GetReport.
236
+ #
237
+ # You should compute the MD5 hash of the HTTP body and compare that with
238
+ # the returned Content-MD5 header value. If they do not match, which
239
+ # means the body was corrupted during transmission, you should discard
240
+ # the result and automatically retry the call for up to three more
241
+ # times. Please notify us if you ever see such a corrupted body. You can
242
+ # contact us by using the contact form at http://mws.amazon.com
243
+ # (http://mws.amazon.com). For more information, see Using the
244
+ # Content-MD5 Header with SubmitFeed.
245
+ #
246
+
247
+ def get_report(report_id, params = {})
248
+ response = get("/", {"Action" => "GetReport", "ReportId" => report_id})
249
+ #TODO format response
250
+ end
251
+ alias_method :report, :get_report
252
+
253
+ # ManageReportSchedule
254
+ # The ManageReportSchedule operation creates, updates, or deletes a
255
+ # report schedule for a particular report type. Currently, only order
256
+ # reports can be scheduled.
257
+ #
258
+ # Request Parameters
259
+ #
260
+ # ReportType
261
+ # The type of reports that you want to schedule generation of.
262
+ # Currently, only order reports can be scheduled.
263
+ #
264
+ # Schedule
265
+ # A string that describes how often a ReportRequest should be created.
266
+ # The list of enumerated values is found in the enumeration topic,
267
+ # Schedule.
268
+ #
269
+ # ScheduledDate
270
+ # The date when the next report is scheduled to run. Limited to no more
271
+ # than 366 days in the future.
272
+
273
+ def manage_report_schedule(report_type, schedule, params={})
274
+ raise InvalidReportType if !REPORT_TYPES.include?(report_type)
275
+ raise InvalidSchedule if !SCHEDULE.include?(schedule)
276
+
277
+ response =
278
+ get("/", {
279
+ "Action" => "ManageReportSchedule",
280
+ "Schedule" => SCHEDULE[schedule],
281
+ "ReportType" => REPORT_TYPES[report_type]
282
+ })
283
+
284
+ ManageReportScheduleResponse.format(response)
285
+ end
286
+
287
+ # GetReportScheduleList
288
+ # The GetReportScheduleList operation returns a list of report schedules
289
+ # that match the query parameters. Currently, only order reports can be
290
+ # scheduled.
291
+ #
292
+ # The maximum number of results that will be returned in one call is one
293
+ # hundred. If there are additional results to return, HasNext will be
294
+ # returned in the response with a true value. To retrieve all the
295
+ # results, you can use the value of the NextToken parameter to call
296
+ # GetReportScheduleListByNextToken until HasNext is false.
297
+ # [Note] Note
298
+ #
299
+ # For this release of Amazon MWS, only order reports can be scheduled,
300
+ # so HasNext will always be False.
301
+
302
+ def get_report_schedule_list(params = {})
303
+ response = get("/", {"Action" => "GetReportScheduleList"}.merge(params))
304
+ GetReportScheduleListResponse.format(response)
305
+ end
306
+
307
+ alias_method :report_schedule_list, :get_report_schedule_list
308
+
309
+ def get_report_schedule_list_by_next_token(next_token)
310
+ response =
311
+ get("/", {
312
+ "Action" => "GetReportScheduleListByNextToken",
313
+ "NextToken" => next_token
314
+ })
315
+
316
+ GetReportScheduleListByNextTokenResponse.format(response)
317
+ end
318
+
319
+ alias_method :report_schedule_list_by_next_token, :get_report_schedule_list_by_next_token
320
+
321
+ def get_report_schedule_count(params = {})
322
+ response = get("/", {"Action" => "GetReportScheduleCount"})
323
+ GetReportScheduleCountResponse.format(response)
324
+ end
325
+
326
+ alias_method :report_schedule_count, :get_report_schedule_count
327
+
328
+ end
329
+ end
330
+ end