peddler 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +237 -8
- data/lib/mws/feeds.rb +1 -0
- data/lib/mws/feeds/client.rb +97 -0
- data/lib/mws/feeds/parsers/feed.rb +14 -0
- data/lib/mws/feeds/parsers/feed_submission.rb +25 -0
- data/lib/mws/feeds/parsers/feed_submission_count.rb +13 -0
- data/lib/mws/feeds/parsers/feed_submission_list.rb +20 -0
- data/lib/mws/feeds/parsers/feed_submission_result.rb +10 -0
- data/lib/mws/feeds/parsers/feed_submissions.rb +18 -0
- data/lib/mws/feeds/requests/feed.rb +38 -0
- data/lib/mws/feeds/requests/feed_submission_count.rb +20 -0
- data/lib/mws/feeds/requests/feed_submission_list.rb +28 -0
- data/lib/mws/feeds/requests/feed_submission_result.rb +18 -0
- data/lib/mws/feeds/requests/feed_submissions.rb +20 -0
- data/lib/mws/fulfillment_inbound_shipment/client.rb +7 -0
- data/lib/mws/fulfillment_inventory/client.rb +7 -0
- data/lib/mws/fulfillment_outbound_shipment/client.rb +7 -0
- data/lib/mws/off_amazon_payments/client.rb +7 -0
- data/lib/mws/orders.rb +1 -0
- data/lib/mws/orders/client.rb +88 -0
- data/lib/mws/orders/parsers/invoice_data.rb +25 -0
- data/lib/mws/orders/parsers/order.rb +113 -0
- data/lib/mws/orders/parsers/order_item.rb +110 -0
- data/lib/mws/orders/parsers/order_items.rb +20 -0
- data/lib/mws/orders/parsers/orders.rb +20 -0
- data/lib/mws/orders/parsers/payment_execution_detail.rb +20 -0
- data/lib/mws/orders/parsers/payment_execution_detail_item.rb +17 -0
- data/lib/mws/orders/parsers/service_status.rb +36 -0
- data/lib/mws/orders/parsers/service_status_message.rb +17 -0
- data/lib/mws/orders/parsers/shipping_address.rb +37 -0
- data/lib/mws/orders/requests/order_items.rb +26 -0
- data/lib/mws/orders/requests/orders.rb +39 -0
- data/lib/mws/orders/requests/service_status.rb +15 -0
- data/lib/mws/products/client.rb +7 -0
- data/lib/mws/recommendations/client.rb +7 -0
- data/lib/mws/reports/client.rb +6 -0
- data/lib/mws/sellers/client.rb +7 -0
- data/lib/mws/subscriptions/client.rb +7 -0
- data/lib/peddler.rb +11 -1
- data/lib/peddler/client.rb +62 -0
- data/lib/peddler/parsers/base.rb +15 -0
- data/lib/peddler/parsers/collection.rb +23 -0
- data/lib/peddler/parsers/model.rb +43 -0
- data/lib/peddler/parsers/text.rb +13 -0
- data/lib/peddler/parsers/xml.rb +25 -0
- data/lib/peddler/request.rb +50 -0
- data/lib/peddler/request/parameters.rb +56 -0
- data/lib/peddler/request/structured_list.rb +43 -0
- data/lib/peddler/response_wrapper.rb +32 -0
- data/lib/peddler/version.rb +1 -1
- data/test/fixtures/feeds/feed_submission.xml +14 -0
- data/test/fixtures/feeds/feed_submission_count.xml +9 -0
- data/test/fixtures/feeds/feed_submission_list.xml +17 -0
- data/test/fixtures/feeds/feed_submissions.xml +15 -0
- data/test/fixtures/mws.yml +8 -0
- data/test/fixtures/mws.yml.example +4 -0
- data/test/fixtures/orders/order_items.xml +83 -0
- data/test/fixtures/orders/orders.xml +109 -0
- data/test/fixtures/orders/service_status.xml +19 -0
- data/test/helper.rb +5 -0
- data/test/integration/feeds/test_feed_submission_count.rb +13 -0
- data/test/integration/feeds/test_feed_submission_list.rb +15 -0
- data/test/integration/feeds/test_feed_submission_result.rb +15 -0
- data/test/integration/orders/test_order_items.rb +19 -0
- data/test/integration/orders/test_orders.rb +20 -0
- data/test/integration/orders/test_service_status.rb +12 -0
- data/test/integration_helper.rb +16 -0
- data/test/mws/feeds/parsers/test_feed.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submission.rb +25 -0
- data/test/mws/feeds/parsers/test_feed_submission_count.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submission_list.rb +14 -0
- data/test/mws/feeds/parsers/test_feed_submission_result.rb +13 -0
- data/test/mws/feeds/parsers/test_feed_submissions.rb +17 -0
- data/test/mws/feeds/requests/test_feed.rb +63 -0
- data/test/mws/feeds/requests/test_feed_submission_count.rb +23 -0
- data/test/mws/feeds/requests/test_feed_submission_list.rb +40 -0
- data/test/mws/feeds/requests/test_feed_submissions.rb +29 -0
- data/test/mws/orders/parsers/test_order.rb +86 -0
- data/test/mws/orders/parsers/test_order_item.rb +69 -0
- data/test/mws/orders/parsers/test_order_items.rb +14 -0
- data/test/mws/orders/parsers/test_orders.rb +14 -0
- data/test/mws/orders/parsers/test_payment_execution_detail.rb +14 -0
- data/test/mws/orders/parsers/test_payment_execution_detail_item.rb +17 -0
- data/test/mws/orders/parsers/test_service_status.rb +39 -0
- data/test/mws/orders/parsers/test_service_status_message.rb +17 -0
- data/test/mws/orders/parsers/test_shipping_address.rb +36 -0
- data/test/mws/orders/requests/test_order_items.rb +39 -0
- data/test/mws/orders/requests/test_orders.rb +49 -0
- data/test/mws/orders/requests/test_service_status.rb +25 -0
- data/test/parser_helper.rb +11 -0
- data/test/peddler/parsers/test_collection.rb +8 -0
- data/test/peddler/parsers/test_model.rb +34 -0
- data/test/peddler/request/test_parameters.rb +35 -0
- data/test/peddler/request/test_structured_list.rb +18 -0
- data/test/peddler/test_client.rb +42 -0
- data/test/request_helper.rb +20 -0
- metadata +213 -10
- data/lib/peddler/apis.rb +0 -45
- data/lib/peddler/service.rb +0 -83
- data/test/service_test.rb +0 -42
- data/test/test_helper.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54909f8d993396b8132138eef8f201c75acebd89
|
4
|
+
data.tar.gz: 2db773a47532b898dc0e1227ada67e6ef3d343ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a028b4d07e66d3cf49078cc4b32c7ddff925f5524447e70043f3c88d4552a26d86ab1d08ae7763176a1968b23c3b0d942e827c8aa6bc15385d5513c1114c93a6
|
7
|
+
data.tar.gz: 1805a78cc4684b60d7a6f820f06a3b1a6a162773b79d27d8061a5507231ebbf57115b530ea9a1cc52fadf8bfa2bba028c4f48a0f5157b182e1a1da0c77019d70
|
data/README.md
CHANGED
@@ -2,21 +2,250 @@
|
|
2
2
|
|
3
3
|
![Peddler][1]
|
4
4
|
|
5
|
-
Peddler
|
5
|
+
**Peddler** is a full-featured Ruby interface to the [Amazon Marketplace Web
|
6
6
|
Service (MWS) APIs][2].
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
|
+
Require the library:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
require 'peddler'
|
14
|
+
```
|
15
|
+
|
16
|
+
Alternatively, require a particular API only:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
require 'mws/orders'
|
20
|
+
```
|
21
|
+
|
22
|
+
Instantiate a client with the ISO 3166-1 two-letter country code of the
|
23
|
+
marketplace and your seller credentials:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
client = MWS::Orders::Client.new('GB', 'key', 'secret', 'merchant_id')
|
27
|
+
```
|
28
|
+
|
29
|
+
Alternatively, set your credentials as environment variables in your shell:
|
30
|
+
|
31
|
+
```sh
|
32
|
+
export AWS_ACCESS_KEY_ID=key
|
33
|
+
export AWS_SECRET_ACCESS_KEY=secret
|
34
|
+
export MERCHANT_ID=merchant_id
|
35
|
+
```
|
36
|
+
|
37
|
+
Then, instantiate with the country code:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
client = MWS::Orders::Client.new('US')
|
41
|
+
```
|
42
|
+
|
43
|
+
### Feeds
|
44
|
+
|
45
|
+
The MWS Feeds API lets you upload inventory and order data to Amazon. You can
|
46
|
+
also use this API to get information about the processing of feeds.
|
47
|
+
|
48
|
+
[API methods are available on the client][3].
|
49
|
+
|
50
|
+
Instantiate a client:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
client = MWS::Feeds::Client.new('GB')
|
54
|
+
```
|
55
|
+
|
56
|
+
#### Submit Feed
|
57
|
+
|
58
|
+
Submit a feed:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
client.submit_feed(xml, '_POST_PRODUCT_DATA_')
|
62
|
+
```
|
63
|
+
|
64
|
+
#### Feed Submission List
|
65
|
+
|
66
|
+
List past feed submissions:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
# See the API for all available parameters for this and other methods.
|
70
|
+
client.get_feed_submissions
|
71
|
+
```
|
72
|
+
|
73
|
+
List the next page of feed submissions:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
client.get_feed_submissions_by_next_token
|
77
|
+
```
|
78
|
+
|
79
|
+
#### Feed Submission Count
|
80
|
+
|
81
|
+
Get the feed submission count:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
client.get_feed_submission_count(submitted_from_date: 1.day.ago)
|
85
|
+
```
|
86
|
+
|
87
|
+
#### Feed Submission Result
|
88
|
+
|
89
|
+
Get the processing report for a submitted feed.
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
client.feed_submission_result('123456')
|
93
|
+
```
|
94
|
+
|
95
|
+
### Fulfillment Inbound Shipment
|
96
|
+
|
97
|
+
This API is not implemented yet. You can still use the raw client like so:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
client = MWS::FulfillmentInboundShipment::Client.new('GB')
|
101
|
+
```
|
102
|
+
|
103
|
+
Pull requests are welcome!
|
104
|
+
|
105
|
+
### Fulfillment Inventory
|
106
|
+
|
107
|
+
This API is not implemented yet. You can still use the raw client like so:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
client = MWS::FulfillmentInventory::Client.new('GB')
|
111
|
+
```
|
112
|
+
|
113
|
+
Pull requests are welcome!
|
114
|
+
|
115
|
+
### Fulfillment Outbound Shipment
|
116
|
+
|
117
|
+
This API is not implemented yet. You can still use the raw client like so:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
client = MWS::FulfillmentOutboundShipment::Client.new('GB')
|
121
|
+
```
|
122
|
+
|
123
|
+
Pull requests are welcome!
|
124
|
+
|
125
|
+
### Off Amazon Payments
|
126
|
+
|
127
|
+
This API is not implemented yet. You can still use the raw client like so:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
client = MWS::OffAmazonPayments::Client.new('GB')
|
131
|
+
```
|
132
|
+
|
133
|
+
Pull requests are welcome!
|
134
|
+
|
135
|
+
### Orders
|
136
|
+
|
137
|
+
With the MWS Orders API, you can list orders created or updated during a time
|
138
|
+
frame you specify or retrieve information about specific orders.
|
139
|
+
|
140
|
+
[API methods are available on the client][4].
|
141
|
+
|
142
|
+
Instantiate a client:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
client = MWS::Orders::Client.new('GB')
|
146
|
+
```
|
147
|
+
|
148
|
+
#### Orders
|
149
|
+
|
150
|
+
List orders:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
# See the API for all available parameters.
|
154
|
+
client.list_orders(
|
155
|
+
created_after: 1.week.ago,
|
156
|
+
order_status: %w(Pending Unshipped)
|
157
|
+
)
|
158
|
+
```
|
159
|
+
|
160
|
+
List the next page of orders:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
client.list_orders_by_next_token
|
164
|
+
```
|
165
|
+
|
166
|
+
Get one or more orders based on their order numbers:
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
client.get_order('123-1234567-1234567')
|
170
|
+
```
|
171
|
+
|
172
|
+
All above queries will return an enumerable list of orders.
|
173
|
+
|
174
|
+
#### Order Items
|
175
|
+
|
176
|
+
List order items based on an order number you specify:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
client.list_order_items('123-1234567-1234567')
|
180
|
+
```
|
181
|
+
|
182
|
+
List the next page of order items:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
client.list_order_items_by_next_token
|
186
|
+
```
|
187
|
+
|
188
|
+
All above queries will return an enumerable list of order items.
|
189
|
+
|
190
|
+
#### Service Status
|
191
|
+
|
192
|
+
Check the operational status of the API:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
client.get_service_status
|
196
|
+
```
|
197
|
+
|
198
|
+
### Products
|
199
|
+
|
200
|
+
This API is not implemented yet. You can still use the raw client like so:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
client = MWS::Products::Client.new('GB')
|
204
|
+
```
|
205
|
+
|
206
|
+
Pull requests are welcome!
|
207
|
+
|
208
|
+
### Recommendations
|
209
|
+
|
210
|
+
This API is not implemented yet. You can still use the raw client like so:
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
client = MWS::Recommendations::Client.new('GB')
|
214
|
+
```
|
215
|
+
|
216
|
+
Pull requests are welcome!
|
217
|
+
|
218
|
+
### Reports
|
219
|
+
|
220
|
+
This API is not implemented yet. You can still use the raw client like so:
|
221
|
+
|
10
222
|
```ruby
|
11
|
-
client =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
223
|
+
client = MWS::Reports::Client.new('GB')
|
224
|
+
```
|
225
|
+
|
226
|
+
Pull requests are welcome!
|
227
|
+
|
228
|
+
### Sellers
|
229
|
+
|
230
|
+
This API is not implemented yet. You can still use the raw client like so:
|
17
231
|
|
18
|
-
|
232
|
+
```ruby
|
233
|
+
client = MWS::Sellers::Client.new('GB')
|
234
|
+
```
|
235
|
+
|
236
|
+
Pull requests are welcome!
|
237
|
+
|
238
|
+
### Subscriptions
|
239
|
+
|
240
|
+
This API is not implemented yet. You can still use the raw client like so:
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
client = MWS::Subscriptions::Client.new('GB')
|
19
244
|
```
|
20
245
|
|
246
|
+
Pull requests are welcome!
|
247
|
+
|
21
248
|
[1]: http://f.cl.ly/items/0W3V0A1Z110Q0x461b3H/mussels.jpeg
|
22
249
|
[2]: https://developer.amazonservices.com/gp/mws/docs.html
|
250
|
+
[3]: https://github.com/papercavalier/peddler/blob/master/lib/mws/feeds/client.rb
|
251
|
+
[4]: https://github.com/papercavalier/peddler/blob/master/lib/mws/orders/client.rb
|
data/lib/mws/feeds.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mws/feeds/client'
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'mws/feeds/requests/feed'
|
2
|
+
require 'mws/feeds/requests/feed_submission_list'
|
3
|
+
require 'mws/feeds/requests/feed_submission_count'
|
4
|
+
require 'mws/feeds/requests/feed_submission_result'
|
5
|
+
require 'peddler/client'
|
6
|
+
|
7
|
+
module MWS
|
8
|
+
module Feeds
|
9
|
+
class Client < ::Peddler::Client
|
10
|
+
# Public: Upload a feed for processing by Amazon MWS.
|
11
|
+
#
|
12
|
+
# content - The String content of the feed, in XML or flat file format.
|
13
|
+
# type - A String value indicating how the data should be processed.
|
14
|
+
# options - Other optional Hash query parameters used to define the
|
15
|
+
# submission.
|
16
|
+
# :marketplace_id_list - A list of one or more marketplace Ids
|
17
|
+
# that you want the feed to be applied
|
18
|
+
# to (defaults to the client's default
|
19
|
+
# country).
|
20
|
+
# :purge_and_replace - A Boolean value that enables the purge
|
21
|
+
# and replace functionality (default:
|
22
|
+
# false).
|
23
|
+
#
|
24
|
+
# Examples
|
25
|
+
#
|
26
|
+
# client.submit_feed(body, '_POST_PRODUCT_DATA_')
|
27
|
+
#
|
28
|
+
# Returns a Feed Submission.
|
29
|
+
def_delegator :feed, :submit, :submit_feed
|
30
|
+
|
31
|
+
# Public: Get a list of feed submissions submitted during a specified time
|
32
|
+
# frame.
|
33
|
+
#
|
34
|
+
# options - The Hash query parameters used to narrow the list. Refer to
|
35
|
+
# the MWS Feeds API for available parameters.
|
36
|
+
#
|
37
|
+
# Examples
|
38
|
+
#
|
39
|
+
# client.get_feed_submission_list(submitted_from_date: 1.week.ago)
|
40
|
+
#
|
41
|
+
# Returns an enumerable Feed Submission List.
|
42
|
+
def_delegator :feed_submission_list, :get, :get_feed_submission_list
|
43
|
+
|
44
|
+
# Public: List the next page of the list of feed submissions.
|
45
|
+
#
|
46
|
+
# Examples
|
47
|
+
#
|
48
|
+
# client.get_feed_submission_list_by_next_token
|
49
|
+
#
|
50
|
+
# Returns an enumerable Feed Submission List.
|
51
|
+
def_delegator :feed_submission_list, :get_by_next_token, :get_feed_submission_list_by_next_token
|
52
|
+
|
53
|
+
# Public: Returns a count of the feeds submitted during a specified time
|
54
|
+
# frame.
|
55
|
+
#
|
56
|
+
# options - The Hash query parameters used to narrow the list. Refer to
|
57
|
+
# the MWS Feeds API for available parameters.
|
58
|
+
#
|
59
|
+
# Examples
|
60
|
+
#
|
61
|
+
# client.get_feed_submission_count(submitted_from_date: 1.week.ago)
|
62
|
+
#
|
63
|
+
# Returns the Feed Submission Count.
|
64
|
+
def_delegator :feed_submission_count, :get, :get_feed_submission_count
|
65
|
+
|
66
|
+
# Public: Gets the feed processing report and the Content-MD5 header for
|
67
|
+
# the returned HTTP body.
|
68
|
+
#
|
69
|
+
# feed_submission_id - The String Feed Submission Id.
|
70
|
+
#
|
71
|
+
# Examples
|
72
|
+
#
|
73
|
+
# client.get_feed_submission_result('123456')
|
74
|
+
#
|
75
|
+
# Returns the Feed Submission Result.
|
76
|
+
def_delegator :feed_submission_result, :get, :get_feed_submission_result
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def feed
|
81
|
+
@feed ||= Requests::Feed.new(self)
|
82
|
+
end
|
83
|
+
|
84
|
+
def feed_submission_list
|
85
|
+
@feed_submission_list ||= Requests::FeedSubmissionList.new(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
def feed_submission_count
|
89
|
+
@feed_submission_count ||= Requests::FeedSubmissionCount.new(self)
|
90
|
+
end
|
91
|
+
|
92
|
+
def feed_submission_result
|
93
|
+
@feed_submission_result ||= Requests::FeedSubmissionResult.new(self)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'peddler/parsers/model'
|
2
|
+
require 'mws/feeds/parsers/feed_submission'
|
3
|
+
|
4
|
+
module MWS
|
5
|
+
module Feeds
|
6
|
+
module Parsers
|
7
|
+
class Feed < Peddler::Parsers::Model
|
8
|
+
value :submission do
|
9
|
+
FeedSubmission.new(document.xpath('xmlns:FeedSubmissionInfo').first)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'peddler/parsers/model'
|
2
|
+
|
3
|
+
module MWS
|
4
|
+
module Feeds
|
5
|
+
module Parsers
|
6
|
+
class FeedSubmission < ::Peddler::Parsers::Model
|
7
|
+
value :id do
|
8
|
+
text_at_xpath('FeedSubmissionId')
|
9
|
+
end
|
10
|
+
|
11
|
+
value :type do
|
12
|
+
text_at_xpath('FeedType')
|
13
|
+
end
|
14
|
+
|
15
|
+
value :submitted_at do
|
16
|
+
time_at_xpath('SubmittedDate')
|
17
|
+
end
|
18
|
+
|
19
|
+
value :processing_status do
|
20
|
+
text_at_xpath('FeedProcessingStatus')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'peddler/parsers/collection'
|
2
|
+
require 'mws/feeds/parsers/feed_submission'
|
3
|
+
|
4
|
+
module MWS
|
5
|
+
module Feeds
|
6
|
+
module Parsers
|
7
|
+
class FeedSubmissionList < ::Peddler::Parsers::Collection
|
8
|
+
def each(&blk)
|
9
|
+
feed_submission_nodes.each { |node| yield FeedSubmission.new(node) }
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def feed_submission_nodes
|
15
|
+
xpath('FeedSubmissionInfo')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|