peddler 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mws/sellers/client.rb +0 -1
- data/lib/peddler/client.rb +53 -19
- data/lib/peddler/version.rb +1 -1
- data/test/helper.rb +2 -1
- data/test/integration/test_fulfillment_inbound_shipment.rb +9 -0
- data/test/mws.yml.1 +4 -0
- data/test/vcr_cassettes/FulfillmentInboundShipment.yml +2420 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04fe2f05cb29fdcfed397c2a449cee124e59e804
|
4
|
+
data.tar.gz: 703bbfa1b3586e6de667e9588c08160f16e44483
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2bb404705d1ebf31383bfa2175f1f42319594a7b6bd1e1f0aa49959db89da39bc49a22a59ba4baa17d4fb8a288b480ecbf8ba3fb12f9b47e98259eef1c97641
|
7
|
+
data.tar.gz: 1998213239427a3ab9bbbd5d363e707827ef01ad973d8a891426775fbe1e1f4808d29d241638b81fbf0891aed1389ab22837e14b79633035bc4d4cce3fc293ff
|
data/lib/mws/sellers/client.rb
CHANGED
@@ -11,7 +11,6 @@ module MWS
|
|
11
11
|
# Lists the marketplaces the seller participates in
|
12
12
|
#
|
13
13
|
# @see http://docs.developer.amazonservices.com/en_US/sellers/Sellers_ListMarketplaceParticipations.html
|
14
|
-
# @param next_token [String]
|
15
14
|
# @return [Peddler::XMLParser]
|
16
15
|
def list_marketplace_participations
|
17
16
|
operation('ListMarketplaceParticipations')
|
data/lib/peddler/client.rb
CHANGED
@@ -12,22 +12,17 @@ module Peddler
|
|
12
12
|
extend Forwardable
|
13
13
|
include Jeff
|
14
14
|
|
15
|
-
#
|
15
|
+
# The MWSAuthToken used to access another seller's account
|
16
|
+
# @return [String]
|
16
17
|
attr_accessor :auth_token
|
17
18
|
|
18
|
-
|
19
|
-
attr_writer :merchant_id
|
19
|
+
attr_writer :merchant_id, :marketplace_id, :path
|
20
20
|
|
21
|
-
# @
|
22
|
-
attr_writer :marketplace_id
|
23
|
-
|
24
|
-
# @return [String] the HTTP path of the API
|
25
|
-
attr_writer :path
|
26
|
-
|
27
|
-
# @return [String] the version of the API
|
21
|
+
# @api private
|
28
22
|
attr_writer :version
|
29
23
|
|
30
|
-
#
|
24
|
+
# The body of the HTTP request
|
25
|
+
# @return [String]
|
31
26
|
attr_reader :body
|
32
27
|
|
33
28
|
alias_method :configure, :tap
|
@@ -41,24 +36,34 @@ module Peddler
|
|
41
36
|
)
|
42
37
|
|
43
38
|
class << self
|
39
|
+
# @api private
|
44
40
|
attr_reader :error_handler
|
45
41
|
|
42
|
+
# @api private
|
46
43
|
def parser
|
47
44
|
@parser ||= Parser
|
48
45
|
end
|
49
46
|
|
47
|
+
# A custom parser
|
48
|
+
# @!parse attr_writer :parser
|
49
|
+
# @return [Object]
|
50
50
|
def parser=(parser)
|
51
51
|
@parser = parser
|
52
52
|
end
|
53
53
|
|
54
|
+
# @api private
|
54
55
|
def path(path = nil)
|
55
56
|
path ? @path = path : @path ||= '/'
|
56
57
|
end
|
57
58
|
|
59
|
+
# @api private
|
58
60
|
def version(version = nil)
|
59
61
|
version ? @version = version : @version
|
60
62
|
end
|
61
63
|
|
64
|
+
# Sets an error handler
|
65
|
+
# @yieldparam request [Excon::Request]
|
66
|
+
# @yieldparam response [Excon::Response]
|
62
67
|
def on_error(&blk)
|
63
68
|
@error_handler = blk
|
64
69
|
end
|
@@ -71,59 +76,88 @@ module Peddler
|
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
79
|
+
# Creates a new client instance
|
80
|
+
#
|
81
|
+
# @param opts [Hash]
|
82
|
+
# @option opts [String] :marketplace_id
|
83
|
+
# @option opts [String] :merchant_id
|
84
|
+
# @option opts [String] :aws_access_key_id
|
85
|
+
# @option opts [String] :aws_secret_access_key
|
86
|
+
# @option opts [String] :auth_token
|
74
87
|
def initialize(opts = {})
|
75
88
|
opts.each { |k, v| send("#{k}=", v) }
|
76
89
|
end
|
77
90
|
|
91
|
+
# @api private
|
78
92
|
def aws_endpoint
|
79
93
|
"https://#{host}#{path}"
|
80
94
|
end
|
81
95
|
|
96
|
+
# The merchant's Marketplace ID
|
97
|
+
# @!parse attr_reader :marketplace_id
|
98
|
+
# @return [String]
|
82
99
|
def marketplace_id
|
83
100
|
@marketplace_id ||= ENV['MWS_MARKETPLACE_ID']
|
84
101
|
end
|
85
102
|
|
103
|
+
# The merchant's Seller ID
|
104
|
+
# @!parse attr_reader :merchant_id
|
105
|
+
# @return [String]
|
86
106
|
def merchant_id
|
87
107
|
@merchant_id ||= ENV['MWS_MERCHANT_ID']
|
88
108
|
end
|
89
109
|
|
110
|
+
# @api private
|
90
111
|
def marketplace
|
91
112
|
@marketplace ||= find_marketplace
|
92
113
|
end
|
93
114
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
def headers
|
99
|
-
@headers ||= {}
|
100
|
-
end
|
101
|
-
|
115
|
+
# The HTTP path of the API
|
116
|
+
# @!parse attr_reader :path
|
117
|
+
# @return [String]
|
102
118
|
def path
|
103
119
|
@path ||= self.class.path
|
104
120
|
end
|
105
121
|
|
122
|
+
# @api private
|
106
123
|
def version
|
107
124
|
@version ||= self.class.version
|
108
125
|
end
|
109
126
|
|
127
|
+
# @!parse attr_writer :body
|
110
128
|
def body=(str)
|
111
129
|
headers['Content-Type'] = content_type(str)
|
112
130
|
@body = str
|
113
131
|
end
|
114
132
|
|
133
|
+
# @api private
|
134
|
+
def defaults
|
135
|
+
@defaults ||= { expects: 200 }
|
136
|
+
end
|
137
|
+
|
138
|
+
# @api private
|
139
|
+
def headers
|
140
|
+
@headers ||= {}
|
141
|
+
end
|
142
|
+
|
143
|
+
# Sets an error handler
|
144
|
+
# @yieldparam request [Excon::Request]
|
145
|
+
# @yieldparam response [Excon::Response]
|
115
146
|
def on_error(&blk)
|
116
147
|
@error_handler = blk
|
117
148
|
end
|
118
149
|
|
150
|
+
# @api private
|
119
151
|
def error_handler
|
120
152
|
@error_handler || self.class.error_handler
|
121
153
|
end
|
122
154
|
|
155
|
+
# @api private
|
123
156
|
def operation(action = nil)
|
124
157
|
action ? @operation = Operation.new(action) : @operation
|
125
158
|
end
|
126
159
|
|
160
|
+
# @api private
|
127
161
|
def run
|
128
162
|
opts = defaults.merge(query: operation, headers: headers)
|
129
163
|
opts.store(:body, body) if body
|
data/lib/peddler/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -58,7 +58,8 @@ VCR.configure do |c|
|
|
58
58
|
|
59
59
|
# HTTP errors are not Peddler's concern, so ignore them to ease development.
|
60
60
|
c.before_record do |interaction|
|
61
|
-
|
61
|
+
code = interaction.response.status.code
|
62
|
+
interaction.ignore! if code >= 400 && code != 414
|
62
63
|
end
|
63
64
|
|
64
65
|
# Ignore transient params when building VCR fixtures.
|
@@ -21,4 +21,13 @@ class TestFulfillmentInboundShipment < IntegrationTest
|
|
21
21
|
refute_empty res.parse
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
def test_handles_large_requests
|
26
|
+
address = Address.new('John', '1 Main St', 'New York', 'NY', '10001', 'US')
|
27
|
+
items = 100.times.map { |count| Item.new(count, 1) }
|
28
|
+
clients.each do |client|
|
29
|
+
res = client.create_inbound_shipment_plan(address, items)
|
30
|
+
assert_equal 200, res.status
|
31
|
+
end
|
32
|
+
end
|
24
33
|
end
|
data/test/mws.yml.1
ADDED