peddler 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -145
  3. data/lib/mws/feeds/client.rb +7 -1
  4. data/lib/mws/feeds/parsers/feed.rb +3 -3
  5. data/lib/mws/feeds/parsers/feed_submission_count.rb +2 -5
  6. data/lib/mws/feeds/parsers/{feed_submission.rb → feed_submission_info.rb} +1 -1
  7. data/lib/mws/feeds/parsers/feed_submission_list.rb +6 -3
  8. data/lib/mws/feeds/parsers/feed_submissions.rb +2 -2
  9. data/lib/mws/feeds/requests/feed_submission_list.rb +4 -2
  10. data/lib/mws/orders/client.rb +12 -2
  11. data/lib/mws/orders/parsers/order_items.rb +3 -0
  12. data/lib/mws/orders/parsers/orders.rb +6 -3
  13. data/lib/mws/orders/requests/order_items.rb +4 -2
  14. data/lib/mws/orders/requests/orders.rb +4 -2
  15. data/lib/mws/reports/client.rb +243 -0
  16. data/lib/mws/reports/parsers/report.rb +10 -0
  17. data/lib/mws/reports/parsers/report_acknowledgements.rb +20 -0
  18. data/lib/mws/reports/parsers/report_count.rb +10 -0
  19. data/lib/mws/reports/parsers/report_info.rb +29 -0
  20. data/lib/mws/reports/parsers/report_list.rb +23 -0
  21. data/lib/mws/reports/parsers/report_request_count.rb +10 -0
  22. data/lib/mws/reports/parsers/report_request_info.rb +49 -0
  23. data/lib/mws/reports/parsers/report_request_list.rb +23 -0
  24. data/lib/mws/reports/parsers/report_requests.rb +18 -0
  25. data/lib/mws/reports/parsers/report_schedule.rb +21 -0
  26. data/lib/mws/reports/parsers/report_schedule_count.rb +10 -0
  27. data/lib/mws/reports/parsers/report_schedule_list.rb +23 -0
  28. data/lib/mws/reports/parsers/report_scheduler.rb +19 -0
  29. data/lib/mws/reports/requests/report.rb +18 -0
  30. data/lib/mws/reports/requests/report_acknowledgements.rb +27 -0
  31. data/lib/mws/reports/requests/report_count.rb +20 -0
  32. data/lib/mws/reports/requests/report_list.rb +30 -0
  33. data/lib/mws/reports/requests/report_request_count.rb +20 -0
  34. data/lib/mws/reports/requests/report_request_info.rb +21 -0
  35. data/lib/mws/reports/requests/report_request_list.rb +30 -0
  36. data/lib/mws/reports/requests/report_requests.rb +20 -0
  37. data/lib/mws/reports/requests/report_schedule_count.rb +19 -0
  38. data/lib/mws/reports/requests/report_schedule_list.rb +23 -0
  39. data/lib/mws/reports/requests/report_scheduler.rb +29 -0
  40. data/lib/mws/sellers/client.rb +46 -0
  41. data/lib/mws/sellers/parsers/marketplace.rb +33 -0
  42. data/lib/mws/sellers/parsers/marketplace_participations.rb +32 -0
  43. data/lib/mws/sellers/parsers/participation.rb +21 -0
  44. data/lib/mws/sellers/parsers/service_status.rb +36 -0
  45. data/lib/mws/sellers/parsers/service_status_message.rb +17 -0
  46. data/lib/mws/sellers/requests/marketplace_participations.rb +27 -0
  47. data/lib/mws/sellers/requests/service_status.rb +15 -0
  48. data/lib/peddler/parsers/base.rb +2 -2
  49. data/lib/peddler/parsers/counter.rb +13 -0
  50. data/lib/peddler/parsers/model.rb +4 -5
  51. data/lib/peddler/parsers/text.rb +0 -5
  52. data/lib/peddler/parsers/tokenable.rb +13 -0
  53. data/lib/peddler/parsers/xml.rb +10 -5
  54. data/lib/peddler/request/parameters.rb +2 -1
  55. data/lib/peddler/request/structured_list.rb +5 -0
  56. data/lib/peddler/request.rb +13 -15
  57. data/lib/peddler/response/base.rb +0 -0
  58. data/lib/peddler/response/payload/base.rb +0 -0
  59. data/lib/peddler/response/payload/csv.rb +0 -0
  60. data/lib/peddler/response/payload/xml.rb +0 -0
  61. data/lib/peddler/{response_wrapper.rb → response.rb} +6 -11
  62. data/lib/peddler/version.rb +1 -1
  63. data/test/fixtures/mws.yml +4 -0
  64. data/test/fixtures/reports/report.xml +8 -0
  65. data/test/fixtures/reports/report_acknowledgements.xml +18 -0
  66. data/test/fixtures/reports/report_count.xml +9 -0
  67. data/test/fixtures/reports/report_list.xml +17 -0
  68. data/test/fixtures/reports/report_request_count.xml +9 -0
  69. data/test/fixtures/reports/report_request_list.xml +24 -0
  70. data/test/fixtures/reports/report_requests.xml +19 -0
  71. data/test/fixtures/reports/report_schedule_count.xml +10 -0
  72. data/test/fixtures/reports/report_schedule_list.xml +16 -0
  73. data/test/fixtures/reports/report_scheduler.xml +15 -0
  74. data/test/fixtures/sellers/market_participations.xml +27 -0
  75. data/test/fixtures/sellers/service_status.xml +9 -0
  76. data/test/integration/feeds/test_feed_submission_list.rb +2 -0
  77. data/test/integration/orders/test_orders.rb +3 -0
  78. data/test/integration/reports/test_report.rb +15 -0
  79. data/test/integration/reports/test_report_count.rb +13 -0
  80. data/test/integration/reports/test_report_list.rb +17 -0
  81. data/test/integration/reports/test_report_request_count.rb +13 -0
  82. data/test/integration/reports/test_report_request_list.rb +17 -0
  83. data/test/integration/reports/test_report_schedule_count.rb +13 -0
  84. data/test/integration/reports/test_report_schedule_list.rb +13 -0
  85. data/test/integration/reports/test_report_scheduler.rb +16 -0
  86. data/test/integration/sellers/test_marketplace_participations.rb +13 -0
  87. data/test/integration/sellers/test_service_status.rb +12 -0
  88. data/test/integration_helper.rb +3 -0
  89. data/test/mws/feeds/parsers/test_feed.rb +2 -2
  90. data/test/mws/feeds/parsers/{test_feed_submission.rb → test_feed_submission_info.rb} +3 -3
  91. data/test/mws/feeds/parsers/test_feed_submission_list.rb +5 -1
  92. data/test/mws/feeds/parsers/test_feed_submission_result.rb +1 -1
  93. data/test/mws/feeds/requests/test_feed_submission_list.rb +3 -6
  94. data/test/mws/orders/parsers/test_order_items.rb +4 -0
  95. data/test/mws/orders/parsers/test_orders.rb +4 -0
  96. data/test/mws/orders/parsers/test_service_status.rb +1 -1
  97. data/test/mws/orders/requests/test_order_items.rb +3 -6
  98. data/test/mws/orders/requests/test_orders.rb +3 -6
  99. data/test/mws/reports/parsers/test_report_acknowledgments.rb +14 -0
  100. data/test/mws/reports/parsers/test_report_count.rb +13 -0
  101. data/test/mws/reports/parsers/test_report_info.rb +29 -0
  102. data/test/mws/reports/parsers/test_report_list.rb +18 -0
  103. data/test/mws/reports/parsers/test_report_request_count.rb +13 -0
  104. data/test/mws/reports/parsers/test_report_request_info.rb +49 -0
  105. data/test/mws/reports/parsers/test_report_request_list.rb +18 -0
  106. data/test/mws/reports/parsers/test_report_requests.rb +17 -0
  107. data/test/mws/reports/parsers/test_report_schedule_count.rb +13 -0
  108. data/test/mws/reports/parsers/test_report_schedule_list.rb +18 -0
  109. data/test/mws/reports/parsers/test_report_scheduler.rb +17 -0
  110. data/test/mws/reports/requests/test_acknowledgements.rb +36 -0
  111. data/test/mws/reports/requests/test_report_count.rb +23 -0
  112. data/test/mws/reports/requests/test_report_info.rb +29 -0
  113. data/test/mws/reports/requests/test_report_list.rb +39 -0
  114. data/test/mws/reports/requests/test_report_request_count.rb +23 -0
  115. data/test/mws/reports/requests/test_report_request_list.rb +44 -0
  116. data/test/mws/reports/requests/test_report_requests.rb +29 -0
  117. data/test/mws/reports/requests/test_report_schedule_count.rb +22 -0
  118. data/test/mws/reports/requests/test_report_schedule_list.rb +36 -0
  119. data/test/mws/reports/requests/test_report_scheduler.rb +33 -0
  120. data/test/mws/sellers/parsers/test_market_participations.rb +19 -0
  121. data/test/mws/sellers/parsers/test_service_status.rb +35 -0
  122. data/test/mws/sellers/requests/test_marketplace_participation_list.rb +39 -0
  123. data/test/mws/sellers/requests/test_service_status.rb +25 -0
  124. data/test/peddler/parsers/test_model.rb +36 -0
  125. data/test/request_helper.rb +1 -1
  126. metadata +171 -42
  127. data/test/peddler/test_request.rb +0 -18
@@ -0,0 +1,30 @@
1
+ require 'peddler/request'
2
+ require 'mws/reports/parsers/report_request_list'
3
+
4
+ module MWS
5
+ module Reports
6
+ module Requests
7
+ class ReportRequestList < ::Peddler::Request
8
+ def get(options = {})
9
+ parameters(:get_report_request_list)
10
+ .update(options)
11
+ .timestamp!
12
+ .format_structured_lists!
13
+ .camelize_keys!
14
+
15
+ execute
16
+ end
17
+
18
+ def get_by_next_token(token = next_token)
19
+ return false unless token
20
+
21
+ parameters(:get_report_request_list_by_next_token)
22
+ .update(next_token: token)
23
+ .camelize_keys!
24
+
25
+ execute
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ require 'peddler/request'
2
+ require 'mws/reports/parsers/report_requests'
3
+
4
+ module MWS
5
+ module Reports
6
+ module Requests
7
+ class ReportRequests < ::Peddler::Request
8
+ def cancel(options = {})
9
+ parameters(:cancel_report_requests)
10
+ .update(options)
11
+ .timestamp!
12
+ .format_structured_lists!
13
+ .camelize_keys!
14
+
15
+ execute
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'peddler/request'
2
+ require 'mws/reports/parsers/report_schedule_count'
3
+
4
+ module MWS
5
+ module Reports
6
+ module Requests
7
+ class ReportScheduleCount < ::Peddler::Request
8
+ def get(*types)
9
+ parameters(:get_report_schedule_count)
10
+ .update(report_type_list: types)
11
+ .format_structured_lists!
12
+ .camelize_keys!
13
+
14
+ execute
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'peddler/request'
2
+ require 'mws/reports/parsers/report_schedule_list'
3
+
4
+ module MWS
5
+ module Reports
6
+ module Requests
7
+ class ReportScheduleList < ::Peddler::Request
8
+ def get(*types)
9
+ parameters(:get_report_schedule_list)
10
+ .update(report_type_list: types)
11
+ .format_structured_lists!
12
+ .camelize_keys!
13
+
14
+ execute
15
+ end
16
+
17
+ def get_by_next_token(token = next_token)
18
+ raise NotImplementedError
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'peddler/request'
2
+ require 'mws/reports/parsers/report_scheduler'
3
+
4
+ module MWS
5
+ module Reports
6
+ module Requests
7
+ class ReportScheduler < ::Peddler::Request
8
+ def manage(type, schedule, scheduled_at = nil)
9
+ options = {
10
+ report_type: type,
11
+ schedule: schedule
12
+ }
13
+ options.update(scheduled_date: scheduled_at) if scheduled_at
14
+
15
+ parameters(:get_report_count)
16
+ .update(options)
17
+ .timestamp!
18
+ .camelize_keys!
19
+
20
+ execute
21
+ end
22
+
23
+ def delete(type)
24
+ manage(type, '_NEVER_')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,7 +1,53 @@
1
+ require 'mws/sellers/requests/marketplace_participations'
2
+ require 'mws/sellers/requests/service_status'
3
+ require 'peddler/client'
4
+
1
5
  module MWS
2
6
  module Sellers
7
+ # The Sellers API lets sellers retrieve information about their seller
8
+ # account, such as the marketplaces they participate in.
3
9
  class Client < ::Peddler::Client
4
10
  path 'Sellers/2011-07-01'
11
+
12
+ # Public: List marketplaces that the seller submitting the request can
13
+ # sell in and her participations, which include seller-specific
14
+ # information in that marketplace.
15
+ #
16
+ # Examples
17
+ #
18
+ # client.list_marketplace_participations
19
+ #
20
+ # Returns Marketplace Participations.
21
+ def_delegator :marketplace_participations, :list, :list_marketplace_participations
22
+
23
+ # Public: List the next page of marketplace participations using the
24
+ # NextToken parameter.
25
+ #
26
+ # Examples
27
+ #
28
+ # client.list_marketplace_participations_by_next_token
29
+ #
30
+ # Returns Marketplace Participations.
31
+ def_delegator :marketplace_participations, :list_by_next_token, :list_marketplace_participations_by_next_token
32
+
33
+ # Public: Get the service status of the API.
34
+ #
35
+ # Examples
36
+ #
37
+ # client.get_service_status
38
+ #
39
+ # Returns the Service Status.
40
+ def_delegator :service_status, :get, :get_service_status
41
+
42
+ private
43
+
44
+ def marketplace_participations
45
+ @marketplace_participations ||= Requests::MarketplaceParticipations.new(self)
46
+ end
47
+
48
+ def service_status
49
+ @service_status ||= Requests::ServiceStatus.new(self)
50
+ end
5
51
  end
6
52
  end
7
53
  end
@@ -0,0 +1,33 @@
1
+ require 'peddler/parsers/model'
2
+
3
+ module MWS
4
+ module Sellers
5
+ module Parsers
6
+ class Marketplace < ::Peddler::Parsers::Model
7
+ value(:id) do
8
+ text_at_xpath('MarketplaceId')
9
+ end
10
+
11
+ value(:name) do
12
+ text_at_xpath('Name')
13
+ end
14
+
15
+ value(:default_country_code) do
16
+ text_at_xpath('DefaultCountryCode')
17
+ end
18
+
19
+ value(:default_currency_code) do
20
+ text_at_xpath('DefaultCurrencyCode')
21
+ end
22
+
23
+ value(:default_language_code) do
24
+ text_at_xpath('DefaultLanguageCode')
25
+ end
26
+
27
+ value(:domain_name) do
28
+ text_at_xpath('DomainName')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'peddler/parsers/model'
2
+ require 'mws/sellers/parsers/marketplace'
3
+ require 'mws/sellers/parsers/participation'
4
+ require 'peddler/parsers/tokenable'
5
+
6
+ module MWS
7
+ module Sellers
8
+ module Parsers
9
+ class MarketplaceParticipations < ::Peddler::Parsers::Model
10
+ include ::Peddler::Parsers::Tokenable
11
+
12
+ value(:marketplaces) do
13
+ marketplace_nodes.map { |node| Marketplace.new(node) }
14
+ end
15
+
16
+ value(:participations) do
17
+ participation_nodes.map { |node| Participation.new(node) }
18
+ end
19
+
20
+ private
21
+
22
+ def participation_nodes
23
+ xpath('ListParticipations/Participation')
24
+ end
25
+
26
+ def marketplace_nodes
27
+ xpath('ListMarketplaces/Marketplace')
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ require 'peddler/parsers/model'
2
+
3
+ module MWS
4
+ module Sellers
5
+ module Parsers
6
+ class Participation < ::Peddler::Parsers::Model
7
+ value(:marketplace_id) do
8
+ text_at_xpath('MarketplaceId')
9
+ end
10
+
11
+ value(:seller_id) do
12
+ text_at_xpath('SellerId')
13
+ end
14
+
15
+ value(:has_seller_suspended_listings?) do
16
+ boolean_at_xpath('HasSellerSuspendedListings')
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ require 'mws/sellers/parsers/service_status_message'
2
+ require 'peddler/parsers/model'
3
+
4
+ module MWS
5
+ module Sellers
6
+ module Parsers
7
+ class ServiceStatus < ::Peddler::Parsers::Model
8
+ value :status do
9
+ text_at_xpath('Status')
10
+ end
11
+
12
+ value :timestamp do
13
+ time_at_xpath('Timestamp')
14
+ end
15
+
16
+ value :message_id do
17
+ text_at_xpath('MessageId')
18
+ end
19
+
20
+ value :messages do
21
+ xpath('Messages/Message').map { |node| ServiceStatusMessage.new(node) }
22
+ end
23
+
24
+ def ok?
25
+ status == 'GREEN'
26
+ end
27
+
28
+ def inspect
29
+ status
30
+ end
31
+
32
+ alias :to_s :inspect
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ require 'peddler/parsers/model'
2
+
3
+ module MWS
4
+ module Sellers
5
+ module Parsers
6
+ class ServiceStatusMessage < ::Peddler::Parsers::Model
7
+ value :locale do
8
+ text_at_xpath('Locale')
9
+ end
10
+
11
+ value :text do
12
+ text_at_xpath('Text')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'peddler/request'
2
+ require 'mws/sellers/parsers/marketplace_participations'
3
+
4
+ module MWS
5
+ module Sellers
6
+ module Requests
7
+ class MarketplaceParticipations < ::Peddler::Request
8
+ def list
9
+ parameters(:list_marketplace_participations)
10
+ .camelize_keys!
11
+
12
+ execute
13
+ end
14
+
15
+ def list_by_next_token(token = next_token)
16
+ return false unless token
17
+
18
+ parameters(:list_marketplace_participations_by_next_token)
19
+ .update(next_token: token)
20
+ .camelize_keys!
21
+
22
+ execute
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'peddler/request'
2
+ require 'mws/sellers/parsers/service_status'
3
+
4
+ module MWS
5
+ module Sellers
6
+ module Requests
7
+ class ServiceStatus < ::Peddler::Request
8
+ def get
9
+ parameters(:get_service_status)
10
+ execute
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,8 +1,8 @@
1
1
  module Peddler
2
2
  module Parsers
3
3
  class Base
4
- def self.handle?(type)
5
- raise NotImplementedError
4
+ def self.xml?
5
+ false
6
6
  end
7
7
 
8
8
  attr :document
@@ -0,0 +1,13 @@
1
+ require 'peddler/parsers/model'
2
+
3
+ module Peddler
4
+ module Parsers
5
+ class Counter < Model
6
+ value :count do
7
+ integer_at_xpath('Count')
8
+ end
9
+
10
+ alias :to_i :count
11
+ end
12
+ end
13
+ end
@@ -10,6 +10,10 @@ module Peddler
10
10
  class Model < XML
11
11
  include Structure
12
12
 
13
+ def boolean_at_xpath(path)
14
+ !!text_at_xpath(path).match(/true|yes/i)
15
+ end
16
+
13
17
  def float_at_xpath(path)
14
18
  str = text_at_xpath(path)
15
19
  str.to_f if str
@@ -29,11 +33,6 @@ module Peddler
29
33
  Money.new(amount, currency_code)
30
34
  end
31
35
 
32
- def text_at_xpath(path)
33
- node = at_xpath(path)
34
- node.text if node
35
- end
36
-
37
36
  def time_at_xpath(path)
38
37
  str = text_at_xpath(path)
39
38
  Time.parse(CGI.unescape(str)) if str
@@ -3,11 +3,6 @@ require 'peddler/parsers/base'
3
3
  module Peddler
4
4
  module Parsers
5
5
  class Text < Base
6
- def self.handle?(type)
7
- type == :txt
8
- end
9
-
10
- alias :to_s :document
11
6
  end
12
7
  end
13
8
  end
@@ -0,0 +1,13 @@
1
+ module Peddler
2
+ module Parsers
3
+ module Tokenable
4
+ def next_token
5
+ text_at_xpath('NextToken')
6
+ end
7
+
8
+ def has_next_token?
9
+ !!next_token
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,21 +3,26 @@ require 'peddler/parsers/base'
3
3
  module Peddler
4
4
  module Parsers
5
5
  class XML < Base
6
- def self.handle?(type)
7
- type == :xml
6
+ def self.xml?
7
+ true
8
+ end
9
+
10
+ def text_at_xpath(path)
11
+ node = at_xpath(path)
12
+ node.text if node
8
13
  end
9
14
 
10
15
  def at_xpath(path)
11
- document.at_xpath(with_namespace(path))
16
+ document.at_xpath(add_namespace(path))
12
17
  end
13
18
 
14
19
  def xpath(path)
15
- document.xpath(with_namespace(path))
20
+ document.xpath(add_namespace(path))
16
21
  end
17
22
 
18
23
  private
19
24
 
20
- def with_namespace(path)
25
+ def add_namespace(path)
21
26
  path.split('/').map { |attr| "xmlns:#{attr}" }.join('/')
22
27
  end
23
28
  end
@@ -23,7 +23,8 @@ module Peddler
23
23
 
24
24
  each do |key, value|
25
25
  if StructuredList.handle?(key)
26
- lists.update(StructuredList.new(key).build(delete(key)))
26
+ list = StructuredList.new(key).build(delete(key))
27
+ lists.update(list)
27
28
  end
28
29
  end
29
30
 
@@ -13,6 +13,11 @@ module Peddler
13
13
  payment_method: %w(PaymentMethod),
14
14
  tfm_shipment_status: %w(TFMShipmentStatus Status),
15
15
  amazon_order_id: %w(AmazonOrderId Id),
16
+ # Reports
17
+ report_id_list: %w(ReportIdList Id),
18
+ report_request_id_list: %w(ReportRequestIdList Id),
19
+ report_type_list: %w(ReportTypeList Type),
20
+ report_processing_status_list: %w(ReportProcessingStatusList Status),
16
21
  }
17
22
 
18
23
  attr :keys
@@ -1,18 +1,11 @@
1
- require 'forwardable'
2
-
3
1
  require 'peddler/request/parameters'
4
- require 'peddler/response_wrapper'
2
+ require 'peddler/response'
5
3
 
6
4
  module Peddler
7
5
  class Request
8
- extend Forwardable
9
-
10
- def_delegator :last_response, :next_token
11
- def_delegator :last_response, :xml_payload, :last_xml_payload
12
-
13
6
  attr :client, :headers
14
7
 
15
- attr_accessor :body, :last_response
8
+ attr_accessor :body, :last_parsed_response
16
9
 
17
10
  def initialize(client)
18
11
  @client = client
@@ -25,8 +18,12 @@ module Peddler
25
18
  end
26
19
 
27
20
  def execute
28
- fetch
29
- parse
21
+ res = fetch
22
+ parse(res)
23
+ end
24
+
25
+ def next_token
26
+ last_parsed_response.next_token if last_parsed_response
30
27
  end
31
28
 
32
29
  def has_next_token?
@@ -40,15 +37,16 @@ module Peddler
40
37
  end
41
38
 
42
39
  def fetch
43
- opts = { query: parameters, headers: headers }
40
+ opts = { query: parameters, headers: headers, idempotent: true, expects: 200 }
44
41
  opts.update(body: body) if body
45
42
  res = client.post(opts)
46
43
 
47
- @last_response = ResponseWrapper.new(res)
44
+ Response.new(res)
48
45
  end
49
46
 
50
- def parse
51
- parser.new(parser.handle?(:xml) ? last_xml_payload : last_response.body)
47
+ def parse(response)
48
+ document = parser.xml? ? response.result_node : response.body
49
+ @last_parsed_response = parser.new(document)
52
50
  end
53
51
  end
54
52
  end
File without changes
File without changes
File without changes
File without changes
@@ -2,31 +2,26 @@ require 'forwardable'
2
2
  require 'nokogiri'
3
3
 
4
4
  module Peddler
5
- class ResponseWrapper
5
+ class Response
6
6
  extend Forwardable
7
7
 
8
- def_delegator :response, :body
8
+ attr :http_response
9
9
 
10
- attr :response
10
+ def_delegator :http_response, :body
11
11
 
12
- def initialize(response)
13
- @response = response
12
+ def initialize(http_response)
13
+ @http_response = http_response
14
14
  end
15
15
 
16
16
  def document
17
17
  Nokogiri::XML(body)
18
18
  end
19
19
 
20
- def xml_payload
20
+ def result_node
21
21
  root = document.root
22
22
  path = root.name.sub('Response', 'Result')
23
23
 
24
24
  root.xpath("xmlns:#{path}")
25
25
  end
26
-
27
- def next_token
28
- node = xml_payload.at_xpath('xmlns:NextToken')
29
- node.text if node
30
- end
31
26
  end
32
27
  end
@@ -1,3 +1,3 @@
1
1
  module Peddler
2
- VERSION = '0.6.3'
2
+ VERSION = '0.6.4'
3
3
  end
@@ -1,3 +1,7 @@
1
+ - country: US
2
+ aws_access_key_id: AKIAJ767ZET2BZR4UDDQ
3
+ aws_secret_access_key: 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
4
+ seller_id: A2H6NH4SQYFZ4M
1
5
  - country: GB
2
6
  aws_access_key_id: AKIAJJDQ2MJTMPXKJE4A
3
7
  aws_secret_access_key: BhGTh8zXIEuMjKlRJIrX+cXYqWFFYmzcGXscGblS
@@ -0,0 +1,8 @@
1
+ order-id order-item-id purchase-date payments-date buyer-email buyer-name buyer-phone-number sku product-name quantity-purchased currency item-price item-tax shipping-price shipping-tax ship-service-level recipient-name ship-address-1 ship-address-2 ship-address-3 ship-city ship-state ship-postal-code ship-country ship-phone-number delivery-start-date delivery-end-date delivery-time-zone delivery-Instructions
2
+ 103-26010-55904394929210114 2011-02-09T02:46:57-08:00
3
+ 2011-02-09T02:46:57-08:00 0g9lx423zn5@marketplace.amazon.com
4
+ Joe Customer 404-555-1212 JW-RT1-HLD9 The Structure of Aikido:
5
+ Volume 1: Kenjutsu and Taijutsu Sword and Open-Hand Movement
6
+ Relationships (Structure of Aikido, Vol 1) 1 USD 19.49 0.00 3.99
7
+ 0.00 Standard Joe Customer 123 Main Street LAWRENCE CA 90044-2463
8
+ US 404-555-1212
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0"?>
2
+ <UpdateReportAcknowledgementsResponse
3
+ xmlns="http://mws.amazonservices.com/doc/2009-01-01/">
4
+ <UpdateReportAcknowledgementsResult>
5
+ <Count>1</Count>
6
+ <ReportInfo>
7
+ <ReportId>841997483</ReportId>
8
+ <ReportType>_GET_MERCHANT_LISTINGS_DATA_</ReportType>
9
+ <ReportRequestId>2234038326</ReportRequestId>
10
+ <AvailableDate>2009-01-06T03:48:36+00:00</AvailableDate>
11
+ <Acknowledged>true</Acknowledged>
12
+ <AcknowledgedDate>2009-02-20T02:10:41+00:00</AcknowledgedDate>
13
+ </ReportInfo>
14
+ </UpdateReportAcknowledgementsResult>
15
+ <ResponseMetadata>
16
+ <RequestId>42a578a7-ed92-486b-ac67-5de7464fcdfa</RequestId>
17
+ </ResponseMetadata>
18
+ </UpdateReportAcknowledgementsResponse>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0"?>
2
+ <GetReportCountResponse xmlns="http://mws.amazonservices.com/doc/2009-01-01/">
3
+ <GetReportCountResult>
4
+ <Count>166</Count>
5
+ </GetReportCountResult>
6
+ <ResponseMetadata>
7
+ <RequestId>a497aadb-5ea1-49bf-aa14-dabe914465e3</RequestId>
8
+ </ResponseMetadata>
9
+ </GetReportCountResponse>