peddler 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f41b36a62c193efceb4d464ce3447e4934c8ca97907ca6940c431914f0b1406
4
- data.tar.gz: f28498baf2e3c8aa67bd983e74f9c4ca4daffcb15424a25ededee6b72fa3606a
3
+ metadata.gz: 5e7134fb2dff4131780197cb98d282b481c650c9042b71c235557db707d02e10
4
+ data.tar.gz: 491ddd1e18e480cb2b4250eb1cee4422239cc511ff2c6c1ade32d2ec7717e89e
5
5
  SHA512:
6
- metadata.gz: b62d1f3d5eec15b6e2a7d3fee02445a3edc2596a6c8bafbf25deac633a01f401467cbe7d4214a4e1bf6a3b8958ec437b4ac1ed1f7d5a1c7f3638cdfcb80815ba
7
- data.tar.gz: d5c7e57ed43bdf7f1aeba013a499d10b5bdf18361b1f5edf2e25eb82703ddec81eafe596aa0ae57fc920a1591d5ab399ef2c7093bb350c1f319e3e3709a857f8
6
+ metadata.gz: ed79ae488893ad0fd4e4fceebbbeb28074f1b8825dae4b23827db946e3d332b199ce29212de4d48970d2a54316a7aacf9121e9f58581aa57d3be7e75047dcad2
7
+ data.tar.gz: dbcc2289dcc8dafbd1dc157fdcfcdb6e11712c89a7c1f1ba35ddd280a54a33ef8e382cf5926da276286a24eeb5b15b766ff72be81b07d6bc914ab0677b75fbdb
@@ -155,8 +155,8 @@ module MWS
155
155
  # Work around a bug upstream
156
156
  #
157
157
  # @see https://github.com/hakanensari/peddler/issues/122
158
- rescue Peddler::Errors::Error => error
159
- raise unless error.message.include?("Value null at 'asinList'")
158
+ rescue Peddler::Errors::Error => e
159
+ raise unless e.message.include?("Value null at 'asinList'")
160
160
 
161
161
  get_prep_instructions_for_asin_with_bad_params(ship_to_country_code,
162
162
  *asin_list)
@@ -12,6 +12,7 @@ module MWS
12
12
  # Creates a report request
13
13
  #
14
14
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_RequestReport.html
15
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
15
16
  # @param [String] report_type
16
17
  # @param [Hash] opts
17
18
  # @option opts [String, #iso8601] :start_date
@@ -31,6 +32,7 @@ module MWS
31
32
  # Lists report requests
32
33
  #
33
34
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportRequestList.html
35
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
34
36
  # @param [Hash] opts
35
37
  # @option opts [Array<String>, String] :report_request_id_list
36
38
  # @option opts [Array<String>, String] :report_type_list
@@ -64,6 +66,7 @@ module MWS
64
66
  # Counts requested reports
65
67
  #
66
68
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportRequestCount.html
69
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
67
70
  # @param [Hash] opts
68
71
  # @option opts [Array<String>, String] :report_type_list
69
72
  # @option opts [Array<String>, String] :report_processing_status_list
@@ -82,6 +85,7 @@ module MWS
82
85
  # Cancels one or more report requests
83
86
  #
84
87
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_CancelReportRequests.html
88
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
85
89
  # @param [Hash] opts
86
90
  # @option opts [Array<String>, String] :report_type_list
87
91
  # @option opts [Array<String>, String] :report_processing_status_list
@@ -100,6 +104,7 @@ module MWS
100
104
  # Lists reports
101
105
  #
102
106
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportList.html
107
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
103
108
  # @param [Hash] opts
104
109
  # @option opts [Integer] :max_count
105
110
  # @option opts [Array<String>, String] :report_type_list
@@ -132,6 +137,7 @@ module MWS
132
137
  # Counts reports
133
138
  #
134
139
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportCount.html
140
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
135
141
  # @param [Hash] opts
136
142
  # @option opts [Array<String>, String] :report_type_list
137
143
  # @option opts [Boolean] :acknowledged
@@ -162,6 +168,7 @@ module MWS
162
168
  # Creates, updates, or deletes a report request schedule
163
169
  #
164
170
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ManageReportSchedule.html
171
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
165
172
  # @param [String] report_type
166
173
  # @param [String] schedule
167
174
  # @param [Hash] opts
@@ -178,6 +185,7 @@ module MWS
178
185
  # Lists scheduled reports
179
186
  #
180
187
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportScheduleList.html
188
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
181
189
  # @param [Array<String>] report_type_list
182
190
  # @return [Peddler::XMLParser]
183
191
  def get_report_schedule_list(*report_type_list)
@@ -199,6 +207,7 @@ module MWS
199
207
  # Counts scheduled reports
200
208
  #
201
209
  # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportScheduleCount.html
210
+ # @see https://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html
202
211
  # @param [Array<String>] report_type_list
203
212
  # @return [Peddler::XMLParser]
204
213
  def get_report_schedule_count(*report_type_list)
@@ -116,8 +116,8 @@ module Peddler
116
116
  self.body = nil if res.status == 200
117
117
 
118
118
  parser.new(res, encoding)
119
- rescue ::Excon::Error::HTTPStatus => error
120
- handle_http_status_error(error)
119
+ rescue ::Excon::Error::HTTPStatus => e
120
+ handle_http_status_error(e)
121
121
  end
122
122
 
123
123
  private
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peddler
4
+ # Parses content metadata provided in the headers of a response
5
+ class Content
6
+ # @api private
7
+ attr_reader :headers
8
+
9
+ # @api private
10
+ def initialize(headers)
11
+ @headers = headers.select { |key| key.start_with?('Content') }
12
+ end
13
+
14
+ # The size of the response body in bytes
15
+ # @return [String, nil]
16
+ def length
17
+ return unless headers['Content-Length']
18
+
19
+ headers['Content-Length'].to_i
20
+ end
21
+
22
+ # The MD5 digest of the response body
23
+ # @return [String, nil]
24
+ def md5
25
+ headers['Content-MD5']
26
+ end
27
+
28
+ # The MIME type of the response
29
+ # @return [String, nil]
30
+ def media_type
31
+ return unless headers['Content-Type']
32
+
33
+ headers['Content-Type'].split(';').first
34
+ end
35
+
36
+ # The general category into which the MIME type falls
37
+ # @return [String, nil]
38
+ def type
39
+ return unless media_type
40
+
41
+ media_type.split('/').first
42
+ end
43
+
44
+ # The exact kind of data of the specified type the MIME type represents
45
+ # @return [String, nil]
46
+ def subtype
47
+ return unless media_type
48
+
49
+ media_type.split('/').last
50
+ end
51
+
52
+ # The character encoding of the response
53
+ # @return [Encoding, nil]
54
+ def charset
55
+ match_data = headers['Content-Type']&.match(/charset=(.*);?/)
56
+ return unless match_data
57
+
58
+ Encoding.find(match_data[1])
59
+ end
60
+
61
+ # Whether the response is an XML document
62
+ # @return [Boolean, nil]
63
+ def xml?
64
+ return unless subtype
65
+
66
+ subtype == 'xml'
67
+ end
68
+ end
69
+ end
@@ -39,7 +39,7 @@ module Peddler
39
39
  def scrub_body!(encoding)
40
40
  return if body.encoding == Encoding::UTF_8
41
41
 
42
- self.body = body.dup.force_encoding(encoding)
42
+ self.body = body.dup.force_encoding(content_charset || encoding)
43
43
  end
44
44
 
45
45
  def extract_content_and_summary
@@ -1,8 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peddler
4
- # Parses MWS-specific headers
4
+ # Parses useful metadata returned in response headers
5
5
  module Headers
6
+ # The size of the response body in bytes
7
+ # @return [String, nil]
8
+ def content_length
9
+ return unless headers['Content-Length']
10
+
11
+ headers['Content-Length'].to_i
12
+ end
13
+
14
+ # The MD5 digest of the response body
15
+ # @return [String, nil]
16
+ def content_md5
17
+ headers['Content-MD5']
18
+ end
19
+
20
+ # The MIME type of the response
21
+ # @return [String, nil]
22
+ def content_media_type
23
+ return unless headers['Content-Type']
24
+
25
+ headers['Content-Type'].split(';').first
26
+ end
27
+
28
+ # The general category into which the MIME type falls
29
+ # @return [String, nil]
30
+ def content_type
31
+ return unless content_media_type
32
+
33
+ content_media_type.split('/').first
34
+ end
35
+
36
+ # The exact kind of data of the specified type the MIME type represents
37
+ # @return [String, nil]
38
+ def content_subtype
39
+ return unless content_media_type
40
+
41
+ content_media_type.split('/').last
42
+ end
43
+
44
+ # The character encoding of the response
45
+ # @return [Encoding, nil]
46
+ def content_charset
47
+ match_data = headers['Content-Type']&.match(/charset=(.*);?/)
48
+ return unless match_data
49
+
50
+ Encoding.find(match_data[1])
51
+ end
52
+
6
53
  # The max hourly request quota for the requested operation
7
54
  # @return [Integer, nil]
8
55
  def mws_quota_max
@@ -39,9 +39,6 @@ module Peddler
39
39
  end
40
40
  end
41
41
 
42
- # Caveat: We use supersets Windows-31J and CP1252 in place of Shift_JIS and
43
- # ISO 8859-1 respectively to handle some edge cases. These should be safe to
44
- # drop in as replacements.
45
42
  def encoding
46
43
  case country_code
47
44
  when 'JP'
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peddler
4
+ # Parses MWS metadata provided in the headers of a response
5
+ class MWS
6
+ # @api private
7
+ attr_reader :headers
8
+
9
+ # @api private
10
+ def initialize(headers)
11
+ @headers = headers.select { |key| key.start_with?('x-mws') }
12
+ end
13
+
14
+ # The max hourly request quota for the requested operation
15
+ # @return [Integer, nil]
16
+ def quota_max
17
+ return unless headers['x-mws-quota-max']
18
+
19
+ headers['x-mws-quota-max'].to_i
20
+ end
21
+
22
+ # The remaining hourly request quota for the requested operation
23
+ # @return [Integer, nil]
24
+ def quota_remaining
25
+ return unless headers['x-mws-quota-remaining']
26
+
27
+ headers['x-mws-quota-remaining'].to_i
28
+ end
29
+
30
+ # When the hourly request quota for the requested operation resets
31
+ # @return [Time, nil]
32
+ def quota_resets_on
33
+ return unless headers['x-mws-quota-resetsOn']
34
+
35
+ Time.parse(headers['x-mws-quota-resetsOn'])
36
+ end
37
+
38
+ # The ID of the request
39
+ # @return [String, nil]
40
+ def request_id
41
+ headers['x-mws-request-id']
42
+ end
43
+
44
+ # The timestamp of the request
45
+ # @return [Time, nil]
46
+ def timestamp
47
+ return unless headers['x-mws-timestamp']
48
+
49
+ Time.parse(headers['x-mws-timestamp'])
50
+ end
51
+
52
+ # The context of the response
53
+ # @return [String, nil]
54
+ def response_context
55
+ headers['x-mws-response-context']
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peddler
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
5
5
  end
@@ -14,12 +14,4 @@ class TestErrors < IntegrationTest
14
14
  end
15
15
  end
16
16
  end
17
-
18
- def test_request_throttled
19
- clients.each do |client|
20
- assert_raises Peddler::Errors::RequestThrottled do
21
- client.get_order('foo')
22
- end
23
- end
24
- end
25
17
  end
@@ -11,6 +11,11 @@ class TestMWSHeaders < IntegrationTest
11
11
  res = client.get_lowest_priced_offers_for_asin(client.marketplace.id,
12
12
  '1780935374', 'New')
13
13
  refute_nil res.mws_quota_max
14
+ refute_nil res.mws_quota_remaining
15
+ refute_nil res.mws_quota_resets_on
16
+ refute_nil res.mws_request_id
17
+ refute_nil res.mws_timestamp
18
+ refute_nil res.mws_response_context
14
19
  end
15
20
  end
16
21
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'integration_helper'
4
+ require 'mws/reports'
5
+
6
+ class TestStringEncodings < IntegrationTest
7
+ use 'Reports'
8
+
9
+ def setup
10
+ skip unless ENV['LIVE']
11
+ end
12
+
13
+ def test_flat_file_responses
14
+ get_report('_GET_SELLER_FEEDBACK_DATA_') do |res|
15
+ assert_equal res.content_charset, res.body.encoding
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def get_report(report_type, start_date: Date.today - 30)
22
+ clients.each do |client|
23
+ res = client.request_report(report_type, start_date: start_date)
24
+ report_request_id = res.dig('ReportRequestInfo', 'ReportRequestId')
25
+ loop do
26
+ sleep 15
27
+ res = client.get_report_request_list(report_request_id_list:
28
+ report_request_id)
29
+ status = res.dig('ReportRequestInfo', 'ReportProcessingStatus')
30
+ next unless status.include?('_DONE_')
31
+
32
+ report_id = res.dig('ReportRequestInfo', 'GeneratedReportId')
33
+ yield client.get_report(report_id)
34
+ break
35
+ end
36
+ end
37
+ end
38
+ end
@@ -54,6 +54,14 @@ class TestPeddlerFlatFileParser < MiniTest::Test
54
54
  refute_empty parser.content
55
55
  end
56
56
 
57
+ def test_encoding_if_passed_in_header
58
+ body = build_body("Foo\nfür\n", encoding: Encoding::UTF_8)
59
+ parser = Peddler::FlatFileParser.new(build_mock_response(body,
60
+ charset: 'UTF-8'),
61
+ Encoding::CP1252)
62
+ assert_equal 'für', parser.parse[0]['Foo']
63
+ end
64
+
57
65
  def test_handling_japanese_flat_files
58
66
  body = build_body("Foo\nこんにちは\n", encoding: Encoding::SHIFT_JIS)
59
67
  parser = Peddler::FlatFileParser.new(build_mock_response(body), Encoding::WINDOWS_31J)
@@ -91,11 +99,12 @@ class TestPeddlerFlatFileParser < MiniTest::Test
91
99
  str.dup.encode(encoding)
92
100
  end
93
101
 
94
- def build_mock_response(body, ascii: true)
102
+ def build_mock_response(body, ascii: true, charset: nil)
95
103
  body.force_encoding(Encoding::ASCII_8BIT) if ascii
96
104
  headers = {
97
105
  'Content-MD5' => Digest::MD5.base64digest(body)
98
106
  }
107
+ headers['Content-Type'] = "text/plain;charset=#{charset}" if charset
99
108
 
100
109
  OpenStruct.new(body: body, headers: headers)
101
110
  end
@@ -10,6 +10,9 @@ class TestPeddlerHeaders < MiniTest::Test
10
10
 
11
11
  def setup
12
12
  @headers = {
13
+ 'Content-Length' => '100',
14
+ 'Content-MD5' => 'rkkx1Xv/k56/onrN0m7E/Q==',
15
+ 'Content-Type' => 'text/plain;charset=UTF-8',
13
16
  'x-mws-quota-max' => '200.0',
14
17
  'x-mws-quota-remaining' => '200.0',
15
18
  'x-mws-quota-resetsOn' => '2017-01-30T00:03:00.000Z',
@@ -19,6 +22,51 @@ class TestPeddlerHeaders < MiniTest::Test
19
22
  }
20
23
  end
21
24
 
25
+ def test_content_length
26
+ assert_kind_of Integer, content_length
27
+ end
28
+
29
+ def test_content_md5
30
+ assert content_md5
31
+ end
32
+
33
+ def test_content_media_type
34
+ assert content_media_type
35
+ end
36
+
37
+ def test_content_type
38
+ assert content_type
39
+ end
40
+
41
+ def test_content_subtype
42
+ assert content_subtype
43
+ end
44
+
45
+ def test_content_charset
46
+ assert_kind_of Encoding, content_charset
47
+ end
48
+
49
+ def test_no_content_length
50
+ @headers.delete('Content-Length')
51
+ assert_nil content_length
52
+ end
53
+
54
+ def test_no_content_type
55
+ @headers.delete('Content-Type')
56
+ assert_nil content_media_type
57
+ assert_nil content_type
58
+ assert_nil content_subtype
59
+ assert_nil content_charset
60
+ end
61
+
62
+ def test_no_content_charset
63
+ @headers['Content-Type'] = 'text/xml'
64
+ assert content_media_type
65
+ assert content_type
66
+ assert content_subtype
67
+ assert_nil content_charset
68
+ end
69
+
22
70
  def test_mws_quota_max
23
71
  assert_kind_of Integer, mws_quota_max
24
72
  end
@@ -441,445 +441,4 @@ http_interactions:
441
441
  </ErrorResponse>
442
442
  http_version:
443
443
  recorded_at: Mon, 23 May 2016 12:17:08 GMT
444
- - request:
445
- method: post
446
- uri: https://mws.amazonservices.com/Orders/2013-09-01
447
- body:
448
- encoding: UTF-8
449
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A25%3A16Z&Version=2013-09-01&Signature=PxxDltfEifbWVzOka2AIu%2BS4JdOtTe%2BinKYqPi1%2B2iw%3D
450
- headers:
451
- User-Agent:
452
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
453
- Content-Type:
454
- - application/x-www-form-urlencoded
455
- response:
456
- status:
457
- code: 503
458
- message:
459
- headers:
460
- Server:
461
- - Server
462
- Date:
463
- - Mon, 23 May 2016 12:25:16 GMT
464
- Content-Type:
465
- - text/xml
466
- Content-Length:
467
- - '291'
468
- Connection:
469
- - keep-alive
470
- x-mws-request-id:
471
- - c09da471-3728-45bd-b149-011107c6b222
472
- x-mws-timestamp:
473
- - '2016-05-23T12:25:16.616Z'
474
- x-mws-response-context:
475
- - NjwFjq6NP9uKH9Af1NGr1x+LsCj2WwqkWXNsTBkYiXZlNsJ8pl1i+/gTf/YxABEMxhTUNJB6UynL
476
- fVn4cBVpOQ==
477
- Vary:
478
- - Accept-Encoding,User-Agent
479
- body:
480
- encoding: UTF-8
481
- string: |
482
- <?xml version="1.0"?>
483
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
484
- <Error>
485
- <Type></Type>
486
- <Code>RequestThrottled</Code>
487
- <Message>Request is throttled</Message>
488
- </Error>
489
- <RequestID>c09da471-3728-45bd-b149-011107c6b222</RequestID>
490
- </ErrorResponse>
491
- http_version:
492
- recorded_at: Mon, 23 May 2016 12:25:16 GMT
493
- - request:
494
- method: post
495
- uri: https://mws-eu.amazonservices.com/Orders/2013-09-01
496
- body:
497
- encoding: UTF-8
498
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A25%3A30Z&Version=2013-09-01&Signature=2Q4itZiyhGRa1gv4WxdPXz02OraSOyuqZnyTR9QVYkA%3D
499
- headers:
500
- User-Agent:
501
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
502
- Content-Type:
503
- - application/x-www-form-urlencoded
504
- response:
505
- status:
506
- code: 503
507
- message:
508
- headers:
509
- Server:
510
- - Server
511
- Date:
512
- - Mon, 23 May 2016 12:25:31 GMT
513
- Content-Type:
514
- - text/xml
515
- Content-Length:
516
- - '291'
517
- Connection:
518
- - keep-alive
519
- x-mws-request-id:
520
- - 7e25a2e4-32ee-4e6f-9e55-87a7466cfa76
521
- x-mws-timestamp:
522
- - '2016-05-23T12:25:31.071Z'
523
- x-mws-response-context:
524
- - VKqFU1/KuOtUTSZ9hzO/1Tz2lAgZN6R+E1Hu9GVhDpD7QU8PSbL4SQhLAmIbrxaiElKpSnRxkhyv
525
- NaM9fPte4Q==
526
- Vary:
527
- - Accept-Encoding,User-Agent
528
- body:
529
- encoding: UTF-8
530
- string: |
531
- <?xml version="1.0"?>
532
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
533
- <Error>
534
- <Type></Type>
535
- <Code>RequestThrottled</Code>
536
- <Message>Request is throttled</Message>
537
- </Error>
538
- <RequestID>7e25a2e4-32ee-4e6f-9e55-87a7466cfa76</RequestID>
539
- </ErrorResponse>
540
- http_version:
541
- recorded_at: Mon, 23 May 2016 12:25:31 GMT
542
- - request:
543
- method: post
544
- uri: https://mws-eu.amazonservices.com/Orders/2013-09-01
545
- body:
546
- encoding: UTF-8
547
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A25%3A31Z&Version=2013-09-01&Signature=o%2FXv5yNJiV14RGA0gVC0QY7M9%2FU8Cx8CzvFxz36%2FIN8%3D
548
- headers:
549
- User-Agent:
550
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
551
- Content-Type:
552
- - application/x-www-form-urlencoded
553
- response:
554
- status:
555
- code: 503
556
- message:
557
- headers:
558
- Server:
559
- - Server
560
- Date:
561
- - Mon, 23 May 2016 12:25:31 GMT
562
- Content-Type:
563
- - text/xml
564
- Content-Length:
565
- - '291'
566
- Connection:
567
- - keep-alive
568
- x-mws-request-id:
569
- - 46605ebf-ff3a-4413-8f10-07698078db28
570
- x-mws-timestamp:
571
- - '2016-05-23T12:25:31.340Z'
572
- x-mws-response-context:
573
- - QgEen8lhyUfFg2KboDYF5Yu8MuocS3bvS0G50Z0U1ZFnJ8G3JbKQNzx+XkxHTNeyORu1+z6efJNB
574
- lHXQnDK7OQ==
575
- Vary:
576
- - Accept-Encoding,User-Agent
577
- body:
578
- encoding: UTF-8
579
- string: |
580
- <?xml version="1.0"?>
581
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
582
- <Error>
583
- <Type></Type>
584
- <Code>RequestThrottled</Code>
585
- <Message>Request is throttled</Message>
586
- </Error>
587
- <RequestID>46605ebf-ff3a-4413-8f10-07698078db28</RequestID>
588
- </ErrorResponse>
589
- http_version:
590
- recorded_at: Mon, 23 May 2016 12:25:31 GMT
591
- - request:
592
- method: post
593
- uri: https://mws.amazonservices.com/Orders/2013-09-01
594
- body:
595
- encoding: UTF-8
596
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A26%3A15Z&Version=2013-09-01&Signature=IZu%2FVXyk42RToI%2FBx42JvU4rcaOVydIJy5FxE06tQRg%3D
597
- headers:
598
- User-Agent:
599
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
600
- Content-Type:
601
- - application/x-www-form-urlencoded
602
- response:
603
- status:
604
- code: 503
605
- message:
606
- headers:
607
- Server:
608
- - Server
609
- Date:
610
- - Mon, 23 May 2016 12:26:16 GMT
611
- Content-Type:
612
- - text/xml
613
- Content-Length:
614
- - '291'
615
- Connection:
616
- - keep-alive
617
- x-mws-request-id:
618
- - 7f0f0820-dc56-41d1-9962-580e1b92966d
619
- x-mws-timestamp:
620
- - '2016-05-23T12:26:16.027Z'
621
- x-mws-response-context:
622
- - CFLgOA9pzgjsRxjXR7bINfg1tMGVNb+3mfQZa4+The0i8HWIxM06sLRJUOt0hq426i8PIO3bFVNQ
623
- JuMPU0CUzQ==
624
- Vary:
625
- - Accept-Encoding,User-Agent
626
- body:
627
- encoding: UTF-8
628
- string: |
629
- <?xml version="1.0"?>
630
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
631
- <Error>
632
- <Type></Type>
633
- <Code>RequestThrottled</Code>
634
- <Message>Request is throttled</Message>
635
- </Error>
636
- <RequestID>7f0f0820-dc56-41d1-9962-580e1b92966d</RequestID>
637
- </ErrorResponse>
638
- http_version:
639
- recorded_at: Mon, 23 May 2016 12:26:16 GMT
640
- - request:
641
- method: post
642
- uri: https://mws-eu.amazonservices.com/Orders/2013-09-01
643
- body:
644
- encoding: UTF-8
645
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A26%3A36Z&Version=2013-09-01&Signature=S9d0UNtrXTA%2FL7BZB14TAVZvtIlopBhmoyHmzTPejbc%3D
646
- headers:
647
- User-Agent:
648
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
649
- Content-Type:
650
- - application/x-www-form-urlencoded
651
- response:
652
- status:
653
- code: 503
654
- message:
655
- headers:
656
- Server:
657
- - Server
658
- Date:
659
- - Mon, 23 May 2016 12:26:36 GMT
660
- Content-Type:
661
- - text/xml
662
- Content-Length:
663
- - '291'
664
- Connection:
665
- - keep-alive
666
- x-mws-request-id:
667
- - 429d190c-0c4a-46c8-b9a9-5f46511b53b3
668
- x-mws-timestamp:
669
- - '2016-05-23T12:26:36.747Z'
670
- x-mws-response-context:
671
- - cfmuZjCu4F8iJQa0nKHETjvnCfAVDCAkt/Us5XzHjlsIROVZ0G6zeLPb5hhIJiCCX83im4tq9GN4
672
- 34itm7iJzA==
673
- Vary:
674
- - Accept-Encoding,User-Agent
675
- body:
676
- encoding: UTF-8
677
- string: |
678
- <?xml version="1.0"?>
679
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
680
- <Error>
681
- <Type></Type>
682
- <Code>RequestThrottled</Code>
683
- <Message>Request is throttled</Message>
684
- </Error>
685
- <RequestID>429d190c-0c4a-46c8-b9a9-5f46511b53b3</RequestID>
686
- </ErrorResponse>
687
- http_version:
688
- recorded_at: Mon, 23 May 2016 12:26:36 GMT
689
- - request:
690
- method: post
691
- uri: https://mws.amazonservices.jp/Orders/2013-09-01
692
- body:
693
- encoding: UTF-8
694
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A28%3A23Z&Version=2013-09-01&Signature=R%2B8ZRIBw3XDPt9F9Mfoo%2Bw%2Bot6dqahDq2BYqXTOh6Zc%3D
695
- headers:
696
- User-Agent:
697
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
698
- Content-Type:
699
- - application/x-www-form-urlencoded
700
- response:
701
- status:
702
- code: 503
703
- message:
704
- headers:
705
- Server:
706
- - Server
707
- Date:
708
- - Mon, 23 May 2016 12:28:24 GMT
709
- Content-Type:
710
- - text/xml
711
- Content-Length:
712
- - '278'
713
- Connection:
714
- - keep-alive
715
- x-mws-request-id:
716
- - 759022d5-6990-4bfc-9351-7cc67d008955
717
- x-mws-timestamp:
718
- - '2016-05-23T12:28:24.370Z'
719
- x-mws-response-context:
720
- - lyk6D6bzzrWJabg2K47GU1ZWgRd9GuKznFtvfMEq8ZR/luGH+UkRBES1fTrCUabXCkaaMdOy0bKq
721
- 6z4ZKfQuwg==
722
- Vary:
723
- - Accept-Encoding,User-Agent
724
- body:
725
- encoding: UTF-8
726
- string: |
727
- <?xml version="1.0"?>
728
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
729
- <Error>
730
- <Type></Type>
731
- <Code>RequestThrottled</Code>
732
- <Message>Request is throttled</Message>
733
- </Error>
734
- <RequestID>759022d5-6990-4bfc-9351-7cc67d008955</RequestID>
735
- </ErrorResponse>
736
- http_version:
737
- recorded_at: Mon, 23 May 2016 12:28:24 GMT
738
- - request:
739
- method: post
740
- uri: https://mws-eu.amazonservices.com/Orders/2013-09-01
741
- body:
742
- encoding: UTF-8
743
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A29%3A37Z&Version=2013-09-01&Signature=7hG243Xw2rPWKYyfIKoGUA0LTRDLL6H3FJYfeG9y5kQ%3D
744
- headers:
745
- User-Agent:
746
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
747
- Content-Type:
748
- - application/x-www-form-urlencoded
749
- response:
750
- status:
751
- code: 503
752
- message:
753
- headers:
754
- Server:
755
- - Server
756
- Date:
757
- - Mon, 23 May 2016 12:29:37 GMT
758
- Content-Type:
759
- - text/xml
760
- Content-Length:
761
- - '291'
762
- Connection:
763
- - keep-alive
764
- x-mws-request-id:
765
- - 19f0a252-96de-4a79-8052-b66fb4f441be
766
- x-mws-timestamp:
767
- - '2016-05-23T12:29:37.344Z'
768
- x-mws-response-context:
769
- - lyk6D6bzzrWJabg2K47GU1ZWgRd9GuKznFtvfMEq8ZR/luGH+UkRBES1fTrCUabXCkaaMdOy0bKq
770
- 6z4ZKfQuwg==
771
- Vary:
772
- - Accept-Encoding,User-Agent
773
- body:
774
- encoding: UTF-8
775
- string: |
776
- <?xml version="1.0"?>
777
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
778
- <Error>
779
- <Type></Type>
780
- <Code>RequestThrottled</Code>
781
- <Message>Request is throttled</Message>
782
- </Error>
783
- <RequestID>19f0a252-96de-4a79-8052-b66fb4f441be</RequestID>
784
- </ErrorResponse>
785
- http_version:
786
- recorded_at: Mon, 23 May 2016 12:29:37 GMT
787
- - request:
788
- method: post
789
- uri: https://mws-eu.amazonservices.com/Orders/2013-09-01
790
- body:
791
- encoding: UTF-8
792
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A30%3A11Z&Version=2013-09-01&Signature=%2Be9QXTopUhMUaQ0kEmtB2pEUEjt7vI7LoLVqNtV6ZCA%3D
793
- headers:
794
- User-Agent:
795
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
796
- Content-Type:
797
- - application/x-www-form-urlencoded
798
- response:
799
- status:
800
- code: 503
801
- message:
802
- headers:
803
- Server:
804
- - Server
805
- Date:
806
- - Mon, 23 May 2016 12:30:11 GMT
807
- Content-Type:
808
- - text/xml
809
- Content-Length:
810
- - '291'
811
- Connection:
812
- - keep-alive
813
- x-mws-request-id:
814
- - 840d7fe6-fbf4-4bc6-a7d6-018269e8e57b
815
- x-mws-timestamp:
816
- - '2016-05-23T12:30:11.392Z'
817
- x-mws-response-context:
818
- - oE6oYNMqkjV8eW/BRjuzEzjF3NARnODl8w8C4anviesEnSpZ96k17Rg+xbcBCWGmYUake7FbiO4k
819
- r3+dcWKcsg==
820
- Vary:
821
- - Accept-Encoding,User-Agent
822
- body:
823
- encoding: UTF-8
824
- string: |
825
- <?xml version="1.0"?>
826
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
827
- <Error>
828
- <Type></Type>
829
- <Code>RequestThrottled</Code>
830
- <Message>Request is throttled</Message>
831
- </Error>
832
- <RequestID>840d7fe6-fbf4-4bc6-a7d6-018269e8e57b</RequestID>
833
- </ErrorResponse>
834
- http_version:
835
- recorded_at: Mon, 23 May 2016 12:30:11 GMT
836
- - request:
837
- method: post
838
- uri: https://mws.amazonservices.com/Orders/2013-09-01
839
- body:
840
- encoding: UTF-8
841
- string: AWSAccessKeyId=AWS_ACCESS_KEY_ID&Action=GetOrder&AmazonOrderId.Id.1=foo&SellerId=MERCHANT_ID&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2016-05-23T12%3A33%3A44Z&Version=2013-09-01&Signature=afEobB041YouF04d%2F8460n2%2ByPiR6UVaShWiAKFuOQo%3D
842
- headers:
843
- User-Agent:
844
- - Jeff/1.5.1 (Language=Ruby; Hakans-MacBook.home)
845
- Content-Type:
846
- - application/x-www-form-urlencoded
847
- response:
848
- status:
849
- code: 503
850
- message:
851
- headers:
852
- Server:
853
- - Server
854
- Date:
855
- - Mon, 23 May 2016 12:33:45 GMT
856
- Content-Type:
857
- - text/xml
858
- Content-Length:
859
- - '291'
860
- Connection:
861
- - keep-alive
862
- x-mws-request-id:
863
- - 5ca0af8a-0443-4a26-8b63-a9764863c7d8
864
- x-mws-timestamp:
865
- - '2016-05-23T12:33:45.154Z'
866
- x-mws-response-context:
867
- - ecBayQO8iftN3M2GSxDGtX4wcqNrso6pTS5SBv8W1UYGGcnV/9z023Ged2cfmM21hd96dLt8fxTW
868
- mxislaXEhA==
869
- Vary:
870
- - Accept-Encoding,User-Agent
871
- body:
872
- encoding: UTF-8
873
- string: |
874
- <?xml version="1.0"?>
875
- <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
876
- <Error>
877
- <Type></Type>
878
- <Code>RequestThrottled</Code>
879
- <Message>Request is throttled</Message>
880
- </Error>
881
- <RequestID>5ca0af8a-0443-4a26-8b63-a9764863c7d8</RequestID>
882
- </ErrorResponse>
883
- http_version:
884
- recorded_at: Mon, 23 May 2016 12:33:45 GMT
885
444
  recorded_with: VCR 3.0.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peddler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -84,13 +84,13 @@ files:
84
84
  - lib/mws/recommendations/client.rb
85
85
  - lib/mws/reports.rb
86
86
  - lib/mws/reports/client.rb
87
- - lib/mws/reports/parser.rb
88
87
  - lib/mws/sellers.rb
89
88
  - lib/mws/sellers/client.rb
90
89
  - lib/mws/subscriptions.rb
91
90
  - lib/mws/subscriptions/client.rb
92
91
  - lib/peddler.rb
93
92
  - lib/peddler/client.rb
93
+ - lib/peddler/content.rb
94
94
  - lib/peddler/errors/builder.rb
95
95
  - lib/peddler/errors/class_generator.rb
96
96
  - lib/peddler/errors/error.rb
@@ -98,6 +98,7 @@ files:
98
98
  - lib/peddler/flat_file_parser.rb
99
99
  - lib/peddler/headers.rb
100
100
  - lib/peddler/marketplace.rb
101
+ - lib/peddler/mws.rb
101
102
  - lib/peddler/operation.rb
102
103
  - lib/peddler/parser.rb
103
104
  - lib/peddler/structured_list.rb
@@ -107,14 +108,15 @@ files:
107
108
  - lib/peddler/xml_response_parser.rb
108
109
  - test/credentials.rb
109
110
  - test/helper.rb
110
- - test/integration/test_errors.rb
111
+ - test/integration/internals/test_errors.rb
112
+ - test/integration/internals/test_multibyte_queries.rb
113
+ - test/integration/internals/test_mws_headers.rb
114
+ - test/integration/internals/test_string_encodings.rb
111
115
  - test/integration/test_feeds.rb
112
116
  - test/integration/test_fulfillment_inbound_shipment.rb
113
117
  - test/integration/test_fulfillment_inventory.rb
114
118
  - test/integration/test_fulfillment_outbound_shipment.rb
115
119
  - test/integration/test_merchant_fulfillment.rb
116
- - test/integration/test_multibyte_queries.rb
117
- - test/integration/test_mws_headers.rb
118
120
  - test/integration/test_off_amazon_payments.rb
119
121
  - test/integration/test_orders.rb
120
122
  - test/integration/test_products.rb
@@ -185,15 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
187
  requirements:
186
188
  - - ">="
187
189
  - !ruby/object:Gem::Version
188
- version: '2.3'
190
+ version: '2.4'
189
191
  required_rubygems_version: !ruby/object:Gem::Requirement
190
192
  requirements:
191
193
  - - ">="
192
194
  - !ruby/object:Gem::Version
193
195
  version: '0'
194
196
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.7.6
197
+ rubygems_version: 3.0.3
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: Wraps the Amazon MWS APIs
@@ -231,15 +232,16 @@ test_files:
231
232
  - test/helper.rb
232
233
  - test/integration/test_orders.rb
233
234
  - test/integration/test_recommendations.rb
234
- - test/integration/test_multibyte_queries.rb
235
235
  - test/integration/test_feeds.rb
236
236
  - test/integration/test_fulfillment_outbound_shipment.rb
237
237
  - test/integration/test_fulfillment_inbound_shipment.rb
238
- - test/integration/test_mws_headers.rb
239
238
  - test/integration/test_reports.rb
240
239
  - test/integration/test_subscriptions.rb
240
+ - test/integration/internals/test_multibyte_queries.rb
241
+ - test/integration/internals/test_mws_headers.rb
242
+ - test/integration/internals/test_errors.rb
243
+ - test/integration/internals/test_string_encodings.rb
241
244
  - test/integration/test_merchant_fulfillment.rb
242
- - test/integration/test_errors.rb
243
245
  - test/integration/test_sellers.rb
244
246
  - test/integration/test_products.rb
245
247
  - test/integration/test_off_amazon_payments.rb
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'peddler/flat_file_parser'
4
- require 'peddler/xml_response_parser'
5
-
6
- module MWS
7
- module Reports
8
- # @api private
9
- module Parser
10
- class << self
11
- # We're massaging data produced by a motley army of developers. It's
12
- # messy.
13
- def new(res, encoding)
14
- # Don't parse if there's no body
15
- return res unless res.body
16
-
17
- if xml?(res)
18
- XMLResponseParser.new(res)
19
- else
20
- # Amazon returns a variety of content types for flat files. I simply
21
- # assume anything not XML is a flat file.
22
- FlatFileParser.new(res, encoding)
23
- end
24
- end
25
-
26
- def xml?(res)
27
- return true if res.headers['Content-Type'].start_with?('text/xml')
28
- return true if res.body.start_with?('<?xml')
29
-
30
- false
31
- end
32
- end
33
- end
34
- end
35
- end