amazon-mws 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gitignore +1 -0
  2. data/README.markdown +31 -0
  3. data/Rakefile +14 -0
  4. data/VERSION +1 -0
  5. data/amazon-mws.gemspec +164 -0
  6. data/examples/xml/cancel_feed_submissions.xml +16 -0
  7. data/examples/xml/cancel_report_requests.xml +18 -0
  8. data/examples/xml/error.xml +10 -0
  9. data/examples/xml/get_feed_submission_count.xml +10 -0
  10. data/examples/xml/get_feed_submission_list.xml +16 -0
  11. data/examples/xml/get_feed_submission_list_by_next_token.xml +16 -0
  12. data/examples/xml/get_feed_submission_result.xml +30 -0
  13. data/examples/xml/get_report_count.xml +9 -0
  14. data/examples/xml/get_report_list.xml +17 -0
  15. data/examples/xml/get_report_request_count.xml +8 -0
  16. data/examples/xml/get_report_request_list.xml +120 -0
  17. data/examples/xml/get_report_request_list_by_next_token.xml +20 -0
  18. data/examples/xml/get_report_schedule_count.xml +10 -0
  19. data/examples/xml/get_report_schedule_list.xml +15 -0
  20. data/examples/xml/get_report_schedule_list_by_next_token.xml +15 -0
  21. data/examples/xml/manage_report_schedule.xml +14 -0
  22. data/examples/xml/request_report.xml +17 -0
  23. data/examples/xml/submit_feed.xml +14 -0
  24. data/examples/xml/update_report_acknowledgements.xml +18 -0
  25. data/examples/xsd/Inventory.xsd +49 -0
  26. data/examples/xsd/Item.xsd +285 -0
  27. data/examples/xsd/Listings.xsd +32 -0
  28. data/examples/xsd/OrderAcknowledgement.xsd +55 -0
  29. data/examples/xsd/OrderAdjustment.xsd +94 -0
  30. data/examples/xsd/OrderFulfillment.xsd +57 -0
  31. data/examples/xsd/Override.xsd +48 -0
  32. data/examples/xsd/Price.xsd +59 -0
  33. data/examples/xsd/ProcessingReport.xsd +87 -0
  34. data/examples/xsd/Product.xsd +220 -0
  35. data/examples/xsd/Product/AutoAccessory.xsd +807 -0
  36. data/examples/xsd/Product/Beauty.xsd +114 -0
  37. data/examples/xsd/Product/CE.xsd +544 -0
  38. data/examples/xsd/Product/CameraPhoto.xsd +2410 -0
  39. data/examples/xsd/Product/FoodAndBeverages.xsd +270 -0
  40. data/examples/xsd/Product/Gourmet.xsd +85 -0
  41. data/examples/xsd/Product/Health.xsd +189 -0
  42. data/examples/xsd/Product/Home.xsd +654 -0
  43. data/examples/xsd/Product/Jewelry.xsd +603 -0
  44. data/examples/xsd/Product/Miscellaneous.xsd +157 -0
  45. data/examples/xsd/Product/MusicalInstruments.xsd +853 -0
  46. data/examples/xsd/Product/Office.xsd +550 -0
  47. data/examples/xsd/Product/PetSupplies.xsd +40 -0
  48. data/examples/xsd/Product/ProductClothing.xsd +197 -0
  49. data/examples/xsd/Product/SWVG.xsd +238 -0
  50. data/examples/xsd/Product/Sports.xsd +308 -0
  51. data/examples/xsd/Product/TiresAndWheels.xsd +159 -0
  52. data/examples/xsd/Product/Tools.xsd +66 -0
  53. data/examples/xsd/Product/ToysBaby.xsd +241 -0
  54. data/examples/xsd/Product/Wireless.xsd +77 -0
  55. data/examples/xsd/ProductImage.xsd +39 -0
  56. data/examples/xsd/Relationship.xsd +47 -0
  57. data/examples/xsd/SettlementReport.xsd +158 -0
  58. data/examples/xsd/amzn-base.xsd +1601 -0
  59. data/examples/xsd/amzn-envelope.xsd +98 -0
  60. data/examples/xsd/amzn-header.xsd +45 -0
  61. data/lib/amazon/mws.rb +86 -0
  62. data/lib/amazon/mws/authentication.rb +9 -0
  63. data/lib/amazon/mws/authentication/query_string.rb +28 -0
  64. data/lib/amazon/mws/authentication/signature.rb +43 -0
  65. data/lib/amazon/mws/base.rb +61 -0
  66. data/lib/amazon/mws/connection.rb +99 -0
  67. data/lib/amazon/mws/connection/management.rb +94 -0
  68. data/lib/amazon/mws/connection/request_builder.rb +67 -0
  69. data/lib/amazon/mws/exceptions.rb +80 -0
  70. data/lib/amazon/mws/feed.rb +223 -0
  71. data/lib/amazon/mws/feed_builder.rb +67 -0
  72. data/lib/amazon/mws/feed_enumerations.rb +46 -0
  73. data/lib/amazon/mws/feed_submission.rb +14 -0
  74. data/lib/amazon/mws/lib/extensions.rb +162 -0
  75. data/lib/amazon/mws/lib/memoizable.rb +10 -0
  76. data/lib/amazon/mws/orders.rb +9 -0
  77. data/lib/amazon/mws/report.rb +310 -0
  78. data/lib/amazon/mws/report_enumerations.rb +44 -0
  79. data/lib/amazon/mws/report_info.rb +16 -0
  80. data/lib/amazon/mws/report_request.rb +19 -0
  81. data/lib/amazon/mws/report_schedule.rb +13 -0
  82. data/lib/amazon/mws/response.rb +32 -0
  83. data/lib/amazon/mws/response/cancel_feed_submissions_response.rb +14 -0
  84. data/lib/amazon/mws/response/cancel_report_requests_response.rb +14 -0
  85. data/lib/amazon/mws/response/get_feed_submission_count_response.rb +13 -0
  86. data/lib/amazon/mws/response/get_feed_submission_list_by_next_token_response.rb +15 -0
  87. data/lib/amazon/mws/response/get_feed_submission_list_response.rb +15 -0
  88. data/lib/amazon/mws/response/get_feed_submission_result_response.rb +54 -0
  89. data/lib/amazon/mws/response/get_report_count_response.rb +13 -0
  90. data/lib/amazon/mws/response/get_report_list_response.rb +15 -0
  91. data/lib/amazon/mws/response/get_report_request_count_response.rb +13 -0
  92. data/lib/amazon/mws/response/get_report_request_list_by_next_token_response.rb +15 -0
  93. data/lib/amazon/mws/response/get_report_request_list_response.rb +15 -0
  94. data/lib/amazon/mws/response/get_report_schedule_count_response.rb +13 -0
  95. data/lib/amazon/mws/response/get_report_schedule_list_by_next_token_response.rb +15 -0
  96. data/lib/amazon/mws/response/get_report_schedule_list_response.rb +15 -0
  97. data/lib/amazon/mws/response/manage_report_schedule_response.rb +14 -0
  98. data/lib/amazon/mws/response/request_report_response.rb +14 -0
  99. data/lib/amazon/mws/response/response_error.rb +15 -0
  100. data/lib/amazon/mws/response/submit_feed_response.rb +13 -0
  101. data/lib/amazon/mws/response/update_reports_acknowledgements_response.rb +14 -0
  102. data/lib/amazon/mws/version.rb +12 -0
  103. data/pkg/amazon-mws-0.1.0.gem +0 -0
  104. data/test/authentication_test.rb +15 -0
  105. data/test/connection_test.rb +5 -0
  106. data/test/feed_builder_test.rb +15 -0
  107. data/test/feed_submission_test.rb +32 -0
  108. data/test/feed_test.rb +64 -0
  109. data/test/query_string_test.rb +21 -0
  110. data/test/report_test.rb +29 -0
  111. data/test/request_test.rb +18 -0
  112. data/test/response_test.rb +197 -0
  113. data/test/signature_test.rb +30 -0
  114. data/test/test_config.yml +5 -0
  115. data/test/test_helper.rb +22 -0
  116. metadata +179 -0
@@ -0,0 +1,44 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ module Report
5
+
6
+ module Enumerations
7
+ #https://mws.amazon.com/docs/devGuide/index.html?ReportType.html
8
+ REPORT_TYPES = {
9
+ :flat_file_open_listings => '_GET_FLAT_FILE_OPEN_LISTINGS_DATA_',
10
+ :merchant_listing => '_GET_MERCHANT_LISTINGS_DATA_',
11
+ :merchant_listings_lite => '_GET_MERCHANT_LISTINGS_DATA_LITE_',
12
+ :merchant_listings_liter => '_GET_MERCHANT_LISTINGS_DATA_LITER_',
13
+ :merchant_canceled_listings => '_GET_MERCHANT_CANCELLED_LISTINGS_DATA_',
14
+ :nemo_merchant_listings => '_GET_NEMO_MERCHANT_LISTINGS_DATA_',
15
+ :afn_inventory => '_GET_AFN_INVENTORY_DATA_',
16
+ :flat_file_actionable_order => '_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_',
17
+ :orders => '_GET_ORDERS_DATA_', #API Function: ManageReportSchedule
18
+ :flat_file_order_report => '_GET_FLAT_FILE_ORDER_REPORT_DATA_', #API Function: ManageReportSchedule
19
+ :flat_file_orders => '_GET_FLAT_FILE_ORDERS_DATA_',
20
+ :converged_flat_file_order_report => '_GET_CONVERGED_FLAT_FILE_ORDER_REPORT_DATA_'
21
+ }
22
+
23
+ SCHEDULE = {
24
+ '15 minutes' => '_15_MINUTES_',
25
+ '30 minutes' => '_30_MINUTES_',
26
+ '1 hour' => '_1_HOUR_',
27
+ '2 hours' => '_2_HOURS_',
28
+ '4 hours' => '_4_HOURS_',
29
+ '8 hours' => '_8_HOURS_',
30
+ '12 hours' => '_12_HOURS_',
31
+ '1 day' => '_1_DAY_',
32
+ '2 days' => '_2_DAYS_',
33
+ '3 days' => '_72_HOURS_',
34
+ '7 days' => '_7_DAYS_',
35
+ '14 days' => '_14_DAYS_',
36
+ '15 days' => '_15_DAYS_',
37
+ '30 days' => '_30_DAYS_',
38
+ 'Delete' => '_NEVER_'
39
+ }
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class ReportInfo < Response
5
+ xml_name "ReportInfo"
6
+
7
+ xml_reader :id, :from => "ReportId", :as => Integer
8
+ xml_reader :type, :from => "ReportType"
9
+ xml_reader :report_request_id, :as => Integer
10
+ xml_reader :available_date, :as => Time
11
+ xml_reader :acknowledged?
12
+ xml_reader :acknowledged_date, :as => Time
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class ReportRequest < Response
5
+ xml_name "ReportRequestInfo"
6
+
7
+ xml_reader :id, :from => "ReportRequestId", :as => Integer
8
+ xml_reader :report_type
9
+ xml_reader :start_date, :as => Time
10
+ xml_reader :end_date, :as => Time
11
+ xml_reader :scheduled?
12
+ xml_reader :submitted_date, :as => Time
13
+ xml_reader :report_processing_status
14
+ #xml_reader :started_processing_date, :as => Time
15
+ #xml_reader :completed_processing_date, :as => Time
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class ReportSchedule < Response
5
+ xml_name "ReportSchedule"
6
+
7
+ xml_reader :report_type
8
+ xml_reader :schedule
9
+ xml_reader :scheduled_date, :as => Time
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class Response
5
+ include ROXML
6
+ xml_convention :camelcase
7
+
8
+ # This is the factoryish method that is called!, not new
9
+ def self.format(response)
10
+ if response.content_type =~ /xml/ || response.body =~ /<?xml/
11
+ parse_xml(response)
12
+ else
13
+ response.body
14
+ end
15
+ end
16
+
17
+ def self.parse_xml(response)
18
+ if [Net::HTTPClientError, Net::HTTPServerError].any? {|error| response.is_a? error }
19
+ return ResponseError.from_xml(response.body)
20
+ else
21
+ return self.from_xml(response.body)
22
+ end
23
+ end
24
+
25
+ def accessors
26
+ roxml_references.map {|r| r.accessor}
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class CancelFeedSubmissionsResponse < Response
5
+ xml_name "CancelFeedSubmissionsResponse"
6
+ result = "CancelFeedSubmissionsResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :feed_submissions, :as => [FeedSubmission], :in => result
10
+ xml_reader :request_id, :in => "ResponseMetadata"
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class CancelReportRequestsResponse < Response
5
+ xml_name "CancelReportRequestsResponse"
6
+ result = "CancelReportRequestsResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :report_requests, :as => [ReportRequest], :in => result
10
+ xml_reader :request_id, :in => "ResponseMetadata"
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetFeedSubmissionCountResponse < Response
5
+ xml_name "GetFeedSubmissionCountResponse"
6
+ result = "GetFeedSubmissionCountResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetFeedSubmissionListByNextTokenResponse < Response
5
+ xml_name "GetFeedSubmissionListByNextTokenResponse"
6
+ result = "GetFeedSubmissionListByNextTokenResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :feed_submissions, :as => [FeedSubmission], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetFeedSubmissionListResponse < Response
5
+ xml_name "GetFeedSubmissionListResponse"
6
+ result = "GetFeedSubmissionListResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :feed_submissions, :as => [FeedSubmission], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetFeedSubmissionResultResponse < Response
5
+ class Header < Response
6
+ xml_reader :document_version, :as => Float
7
+ xml_reader :merchant_id, :from => "MerchantIdentifier"
8
+ end
9
+
10
+ class ProcessingSummary < Response
11
+ xml_name "ProcessingSummary"
12
+
13
+ xml_reader :messages_processed, :as => Integer
14
+ xml_reader :messages_successful, :as => Integer
15
+ xml_reader :messages_with_error, :as => Integer
16
+ xml_reader :messages_with_warning, :as => Integer
17
+ end
18
+
19
+ class Result < Response
20
+ xml_name "Result"
21
+
22
+ xml_reader :message_id, :from => "MessageID", :as => Integer
23
+ xml_reader :result_code
24
+ xml_reader :message_code, :from => "ResultMessageCode", :as => Integer
25
+ xml_reader :description, :from => "ResultDescription"
26
+ xml_reader :sku, :from => "SKU", :in => "AdditionalInfo", :as => Integer
27
+ end
28
+
29
+ class Message < Response
30
+ xml_name "Message"
31
+
32
+ xml_reader :id, :from => "MessageID", :as => Integer
33
+ xml_reader :document_transaction_id, :from => "DocumentTransactionID", :in => "ProcessingReport", :as => Integer
34
+ xml_reader :status_code, :in => "ProcessingReport"
35
+ xml_reader :processing_summary, :as => ProcessingSummary, :in => "ProcessingReport"
36
+ xml_reader :result, :as => Result, :in => "ProcessingReport"
37
+ end
38
+ end
39
+
40
+ class GetFeedSubmissionResultResponse
41
+ xml_name "AmazonEnvelope"
42
+
43
+ xml_reader :header, :as => Header
44
+ # flattened header
45
+ xml_reader :document_version, :as => Float, :in => "Header"
46
+ xml_reader :merchant_id, :from => "MerchantIdentifier", :in => "Header"
47
+
48
+ xml_reader :message_type
49
+ xml_reader :message, :as => Message
50
+ end
51
+
52
+ end
53
+ end
54
+
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportCountResponse < Response
5
+ xml_name "GetReportCountResponse"
6
+ result = "GetReportCountResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportListResponse < Response
5
+ xml_name "GetReportListResponse"
6
+ result = "GetReportListResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :reports, :as => [ReportInfo], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportRequestCountResponse < Response
5
+ xml_name "GetReportRequestCountResponse"
6
+ result = "GetReportRequestCountResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportRequestListByNextTokenResponse < Response
5
+ xml_name "GetReportRequestListByNextTokenResponse"
6
+ result = "GetReportRequestListByNextTokenResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :report_requests, :as => [ReportRequest], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportRequestListResponse < Response
5
+ xml_name "GetReportRequestListResponse"
6
+ result = "GetReportRequestListResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :report_requests, :as => [ReportRequest], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportScheduleCountResponse < Response
5
+ xml_name "GetReportScheduleCountResponse"
6
+ result = "GetReportScheduleCountResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportScheduleListByNextTokenResponse < Response
5
+ xml_name "GetReportScheduleListByNextTokenResponse"
6
+ result = "GetReportScheduleListByNextTokenResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :report_schedules, :as => [ReportSchedule], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class GetReportScheduleListResponse < Response
5
+ xml_name "GetReportScheduleListResponse"
6
+ result = "GetReportScheduleListResult"
7
+
8
+ xml_reader :has_next?, :in => result
9
+ xml_reader :next_token, :in => result
10
+ xml_reader :report_schedules, :as => [ReportSchedule], :in => result
11
+ xml_reader :request_id, :in => "ResponseMetadata"
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class ManageReportScheduleResponse < Response
5
+ xml_name "ManageReportScheduleResponse"
6
+ result = "ManageReportScheduleResult"
7
+
8
+ xml_reader :count, :in => result, :as => Integer
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ xml_reader :report_schedule, :in => result, :as => ReportSchedule
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class RequestReportResponse < Response
5
+ xml_name "RequestReportResponse"
6
+ result = "RequestReportResult"
7
+
8
+
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ xml_reader :report_request, :in => result, :as => ReportRequest
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,15 @@
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
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Amazon
2
+ module MWS
3
+
4
+ class SubmitFeedResponse < Response
5
+ xml_name "SubmitFeedResponse"
6
+ result = "SubmitFeedResult"
7
+
8
+ xml_reader :feed_submission, :as => FeedSubmission, :in => result
9
+ xml_reader :request_id, :in => "ResponseMetadata"
10
+ end
11
+
12
+ end
13
+ end