peddler 1.6.7 → 2.0.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 +69 -67
- data/lib/mws/feeds/client.rb +15 -12
- data/lib/mws/finances/client.rb +12 -11
- data/lib/mws/fulfillment_inbound_shipment/client.rb +79 -107
- data/lib/mws/fulfillment_inventory/client.rb +5 -5
- data/lib/mws/fulfillment_outbound_shipment/client.rb +36 -44
- data/lib/mws/merchant_fulfillment/client.rb +11 -17
- data/lib/mws/off_amazon_payments/client.rb +38 -68
- data/lib/mws/orders/client.rb +28 -24
- data/lib/mws/products/client.rb +118 -153
- data/lib/mws/recommendations/client.rb +13 -17
- data/lib/mws/reports/client.rb +24 -23
- data/lib/mws/sellers/client.rb +5 -5
- data/lib/mws/subscriptions/client.rb +25 -36
- data/lib/peddler/client.rb +47 -124
- data/lib/peddler/errors/builder.rb +40 -14
- data/lib/peddler/errors/class_generator.rb +34 -0
- data/lib/peddler/errors/error.rb +13 -3
- data/lib/peddler/headers.rb +27 -11
- data/lib/peddler/marketplace.rb +30 -11
- data/lib/peddler/vcr_matcher.rb +11 -1
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler/xml_parser.rb +4 -2
- data/lib/peddler/xml_response_parser.rb +1 -1
- data/test/helper.rb +0 -1
- data/test/integration/test_errors.rb +2 -14
- data/test/integration/test_feeds.rb +0 -3
- data/test/integration/test_multibyte_queries.rb +1 -1
- data/test/integration/test_mws_headers.rb +3 -2
- data/test/integration/test_orders.rb +2 -1
- data/test/integration/test_products.rb +9 -9
- data/test/integration/test_recommendations.rb +1 -1
- data/test/integration/test_subscriptions.rb +2 -2
- data/test/integration_helper.rb +1 -1
- data/test/mws.yml +36 -0
- data/test/mws.yml.example +8 -12
- data/test/null_client.rb +10 -8
- data/test/unit/mws/test_feeds_client.rb +1 -2
- data/test/unit/mws/test_fulfillment_outbound_shipment_client.rb +1 -1
- data/test/unit/mws/test_off_amazon_payments_client.rb +1 -1
- data/test/unit/mws/test_orders_client.rb +7 -6
- data/test/unit/mws/test_products_client.rb +13 -28
- data/test/unit/mws/test_recommendations_client.rb +1 -2
- data/test/unit/mws/test_reports_client.rb +1 -1
- data/test/unit/mws/test_subscriptions_client.rb +1 -130
- data/test/unit/peddler/errors/test_builder.rb +54 -7
- data/test/unit/peddler/errors/test_class_generator.rb +18 -0
- data/test/unit/peddler/errors/test_error.rb +7 -2
- data/test/unit/peddler/test_client.rb +136 -190
- data/test/unit/peddler/test_flat_file_parser.rb +2 -2
- data/test/unit/peddler/test_headers.rb +19 -9
- data/test/unit/peddler/test_marketplace.rb +18 -5
- data/test/unit/peddler/test_vcr_matcher.rb +3 -1
- data/test/vcr_cassettes/Feeds.yml +4816 -5224
- data/test/vcr_cassettes/Reports.yml +3278 -2604
- metadata +8 -9
- data/lib/peddler/errors.rb +0 -12
- data/lib/peddler/errors/handler.rb +0 -59
- data/test/unit/peddler/errors/test_handler.rb +0 -62
- data/test/unit/peddler/test_errors.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bcc09df9ec8e72bf5ed2fc5f08bf6a4993bbbbcc9ddf20ae470d55f640a02fb
|
4
|
+
data.tar.gz: 22934c9e74c6e03783d159ee436bfeeff8e90ee5f4053034228874f7a53c707c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2da04631b697f1715ecfc878d018685a3791eca496384cc6a96a602173b3244d5c3bb17c0d0b1fab6236eb7d1678f278aadb75acce5a6393822026c324c01c7
|
7
|
+
data.tar.gz: 26977e23909f476a1b7f90c5a5b33baa4824391bd2bc6b5c5f212f75f64cd50f8091ab0634ff89bbdf31e76799072d5caf4e1bedcc605b72030f471a2c355678
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
|
7
7
|
**Peddler** is a Ruby interface to the [Amazon MWS API](https://developer.amazonservices.com/), a collection of web services that help Amazon sellers programmatically exchange data on their listings, orders, payments, reports, and more.
|
8
8
|
|
9
|
-
To use Amazon MWS, you must have an eligible seller account and register
|
9
|
+
To use Amazon MWS, you must have an eligible seller account and [register as an application developer](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Registering.html#DG_Registering__RegisteringAsADeveloper).
|
10
|
+
|
11
|
+
Amazon has [multiple regions](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html). Each region requires application developers to register individually.
|
10
12
|
|
11
13
|
Some MWS API sections may require additional authorisation from Amazon.
|
12
14
|
|
@@ -20,66 +22,67 @@ Require the library.
|
|
20
22
|
require "peddler"
|
21
23
|
```
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
client = MWS::Orders::Client.new
|
27
|
-
|
28
|
-
# or the shorthand
|
29
|
-
client = MWS.orders
|
30
|
-
```
|
25
|
+
A client requires the AWS credentials of the application developer. If you are working within a single MWS region, you can set them globally in your shell.
|
31
26
|
|
32
|
-
Each client requires valid MWS credentials. Set these globally in the shell.
|
33
27
|
|
34
28
|
```bash
|
35
|
-
export MWS_MARKETPLACE_ID=YOUR_MARKETPLACE_ID
|
36
|
-
export MWS_MERCHANT_ID=YOUR_MERCHANT_OR_SELLER_ID
|
37
29
|
export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
|
38
30
|
export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
|
39
31
|
```
|
40
32
|
|
41
|
-
|
33
|
+
Now, you can create a client with the Amazon marketplace you as application developer signed up on and a merchant ID. Peddler provides a class for each API section under an eponymous namespace.
|
42
34
|
|
43
35
|
```ruby
|
44
|
-
|
36
|
+
MWS::Orders::Client.new(marketplace: "ATVPDKIKX0DER",
|
37
|
+
merchant_id: "123")
|
38
|
+
|
39
|
+
# or the shorthand
|
40
|
+
MWS.orders(marketplace: "ATVPDKIKX0DER",
|
41
|
+
merchant_id: "123")
|
42
|
+
|
43
|
+
# another shortcut
|
44
|
+
MWS.orders(marketplace: "US",
|
45
|
+
merchant_id: "123")
|
45
46
|
```
|
46
47
|
|
47
|
-
If you are creating a [client for another seller](https://developer.amazonservices.com/gp/mws/faq.html#developForSeller), pass
|
48
|
+
If you are creating a [client for another seller](https://developer.amazonservices.com/gp/mws/faq.html#developForSeller), pass an MWS Auth Token as well.
|
48
49
|
|
49
50
|
```ruby
|
50
|
-
client = MWS.orders(
|
51
|
-
|
52
|
-
|
53
|
-
auth_token: "Seller's MWS Authorisation Token"
|
54
|
-
)
|
51
|
+
client = MWS.orders(marketplace: "ATVPDKIKX0DER",
|
52
|
+
merchant_id: "123",
|
53
|
+
auth_token: "123")
|
55
54
|
```
|
56
55
|
|
57
|
-
|
56
|
+
You won't be able to create a client for another seller if you are in different regions.
|
57
|
+
|
58
|
+
If you are working with sellers across multiple regions, a single set of credentials will not be enough. In that case, you can skip using global environment variables and pass your AWS credentials when creating the client.
|
58
59
|
|
59
60
|
```ruby
|
60
|
-
client = MWS.orders(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
aws_secret_access_key: "Your AWS Secret Access Key",
|
65
|
-
)
|
66
|
-
|
67
|
-
client.primary_marketplace_id = "Another Marketplace ID"
|
61
|
+
client = MWS.orders(marketplace: "ATVPDKIKX0DER",
|
62
|
+
merchant_id: "123",
|
63
|
+
aws_access_key_id: "123",
|
64
|
+
aws_secret_access_key: "123")
|
68
65
|
```
|
69
66
|
|
70
67
|
Once you have a client with valid credentials, you should be able to make requests to the API. Clients map operation names in a flat structure. Methods have positional arguments for required input and keyword arguments for optional parameters. Both method and argument names are underscored but otherwise identical to the names of the corresponding operations and parameters documented in the API.
|
71
68
|
|
69
|
+
For instance, using the above MWS Orders client:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
response = client.list_orders('ATVPDKIKX0DER')
|
73
|
+
```
|
74
|
+
|
72
75
|
### Parser
|
73
76
|
|
74
|
-
Peddler wraps successful responses in a parser that handles both XML documents and flat files:
|
77
|
+
Peddler wraps successful responses in a generic parser that handles both XML documents and flat files:
|
75
78
|
|
76
79
|
```ruby
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
response = client.get_service_status
|
81
|
+
response.parse # will return a Hash object
|
82
|
+
response.dig('Status') # delegates to Hash#dig
|
80
83
|
```
|
81
84
|
|
82
|
-
You can swap
|
85
|
+
You can swap this with a purpose-built parser.
|
83
86
|
|
84
87
|
```ruby
|
85
88
|
MWS::Orders::Client.parser = MyParser
|
@@ -89,57 +92,56 @@ For a sample implementation, see my [MWS Orders](https://github.com/hakanensari/
|
|
89
92
|
|
90
93
|
### Throttling
|
91
94
|
|
92
|
-
Amazon limits the number of requests you can submit to
|
95
|
+
Amazon limits the number of requests you can submit to some operations in a given amount of time. When you hit a limit, your request throws a `Peddler::Errors::RequestThrottled` error.
|
93
96
|
|
94
|
-
|
97
|
+
You will want to exit or back off exponentially and retry if you hit this error.
|
95
98
|
|
96
99
|
```ruby
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
begin
|
101
|
+
client.throttled_method
|
102
|
+
rescue Peddler::Errors::RequestThrottled
|
103
|
+
back_off_exponentially
|
104
|
+
retry
|
105
|
+
end
|
100
106
|
```
|
101
107
|
|
102
|
-
|
103
|
-
|
104
|
-
### Debugging
|
105
|
-
|
106
|
-
If you are having trouble with a request, read [Amazon documentation](https://developer.amazonservices.com/gp/mws/docs.html). Peddler's source links individual operations to their corresponding entries in the Amazon docs.
|
107
|
-
|
108
|
-
Note that some optional keywords have default values.
|
109
|
-
|
110
|
-
To introspect requests, set the `EXCON_DEBUG` environment variable to `1` or similar truthy value. Peddler will then log request and response internals to stdout.
|
111
|
-
|
112
|
-
### Errors
|
108
|
+
Some API sections also have an hourly request quota in addition to the numerical request quota. When you hit this quota, your request throws a `Peddler::Errors::QuotaExceeded` error.
|
113
109
|
|
114
|
-
|
110
|
+
You can introspect your quota usage on the parsed response:
|
115
111
|
|
116
112
|
```ruby
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
122
|
-
```
|
113
|
+
response = client.method_with_quota
|
114
|
+
puts response.mws_quota_remaining
|
115
|
+
# 150
|
123
116
|
|
124
|
-
Alternatively, rescue.
|
125
|
-
|
126
|
-
```ruby
|
127
117
|
begin
|
128
|
-
client.
|
129
|
-
rescue
|
130
|
-
|
131
|
-
|
118
|
+
client.method_with_quota
|
119
|
+
rescue Peddler::Errors::QuotaExceeded => error
|
120
|
+
puts error.response.mws_quota_remaining
|
121
|
+
# 0
|
132
122
|
end
|
133
123
|
```
|
134
124
|
|
135
|
-
|
125
|
+
[Read Amazon's tips on how to avoid throttling](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Throttling.html).
|
126
|
+
|
127
|
+
### Debugging
|
136
128
|
|
137
|
-
|
129
|
+
If you are having trouble with a request, read the [Amazon documentation](https://developer.amazonservices.com/gp/mws/docs.html). [Peddler's source](http://www.rubydoc.info/github/hakanensari/peddler) also links individual operations to their corresponding entries in the Amazon docs.
|
130
|
+
|
131
|
+
Note that some optional keywords have default values.
|
132
|
+
|
133
|
+
To introspect requests, set the `EXCON_DEBUG` environment variable to `1` or similar truthy value. Peddler will then log request and response internals to stdout.
|
134
|
+
|
135
|
+
If you contact Amazon MWS support, they will ask you for the **RequestId** and **Timestamp** of affected requests.
|
138
136
|
|
139
137
|
```ruby
|
140
|
-
|
138
|
+
response = client.problem_method
|
139
|
+
puts response.mws_request_id
|
140
|
+
puts response.mws_timestamp
|
141
141
|
```
|
142
142
|
|
143
|
+
You can access the same attributes on `error.response`. See example in <a href="#throttling">above</a>.
|
144
|
+
|
143
145
|
## The APIs
|
144
146
|
|
145
147
|
### Feeds
|
data/lib/mws/feeds/client.rb
CHANGED
@@ -7,13 +7,14 @@ module MWS
|
|
7
7
|
# The MWS Feeds API lets you upload inventory and order data to Amazon. You
|
8
8
|
# can also use this API to get information about the processing of feeds.
|
9
9
|
class Client < ::Peddler::Client
|
10
|
-
version '2009-01-01'
|
10
|
+
self.version = '2009-01-01'
|
11
|
+
self.path = "/Feeds/#{version}"
|
11
12
|
|
12
13
|
# Uploads a feed
|
13
14
|
#
|
14
15
|
# @note Feed size is limited to 2,147,483,647 bytes (2^31 -1) per feed.
|
15
|
-
# @see
|
16
|
-
# @see
|
16
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_SubmitFeed.html
|
17
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_FeedType.html
|
17
18
|
# @param [String] feed_content an XML or flat file feed
|
18
19
|
# @param [String] feed_type the feed type
|
19
20
|
# @param [Hash] opts
|
@@ -22,8 +23,10 @@ module MWS
|
|
22
23
|
# @return [Peddler::XMLParser]
|
23
24
|
def submit_feed(feed_content, feed_type, opts = {})
|
24
25
|
self.body = feed_content
|
26
|
+
|
25
27
|
operation('SubmitFeed')
|
26
|
-
.add(opts
|
28
|
+
.add(opts)
|
29
|
+
.add('FeedType' => feed_type)
|
27
30
|
.structure!('MarketplaceIdList', 'Id')
|
28
31
|
|
29
32
|
run
|
@@ -31,8 +34,8 @@ module MWS
|
|
31
34
|
|
32
35
|
# Lists feed submissions
|
33
36
|
#
|
34
|
-
# @see
|
35
|
-
# @see
|
37
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionList.html
|
38
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_FeedType.html
|
36
39
|
# @param [Hash] opts
|
37
40
|
# @option opts [Array<String>, String] :feed_submission_id_list
|
38
41
|
# @option opts [Integer] :max_count
|
@@ -53,7 +56,7 @@ module MWS
|
|
53
56
|
|
54
57
|
# Lists the next page of feed submissions
|
55
58
|
#
|
56
|
-
# @see
|
59
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionListByNextToken.html
|
57
60
|
# @param [String] next_token
|
58
61
|
# @return [Peddler::XMLParser]
|
59
62
|
def get_feed_submission_list_by_next_token(next_token)
|
@@ -65,8 +68,8 @@ module MWS
|
|
65
68
|
|
66
69
|
# Counts submitted feeds
|
67
70
|
#
|
68
|
-
# @see
|
69
|
-
# @see
|
71
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionCount.html
|
72
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_FeedType.html
|
70
73
|
# @param [Hash] opts
|
71
74
|
# @option opts [Array<String>, String] :feed_type_list
|
72
75
|
# @option opts [Array<String>, String] :feed_processing_status_list
|
@@ -84,8 +87,8 @@ module MWS
|
|
84
87
|
|
85
88
|
# Cancels one or more feed submissions
|
86
89
|
#
|
87
|
-
# @see
|
88
|
-
# @see
|
90
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_CancelFeedSubmissions.html
|
91
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_FeedType.html
|
89
92
|
# @param [Hash] opts
|
90
93
|
# @option opts [Array<String>, String] :feed_submission_id_list
|
91
94
|
# @option opts [Array<String>, String] :feed_type_list
|
@@ -103,7 +106,7 @@ module MWS
|
|
103
106
|
|
104
107
|
# Gets the processing report for a feed and its Content-MD5 header
|
105
108
|
#
|
106
|
-
# @see
|
109
|
+
# @see https://docs.developer.amazonservices.com/en_US/feeds/Feeds_GetFeedSubmissionResult.html
|
107
110
|
# @param [Integer, String] feed_submission_id
|
108
111
|
# @return [Peddler::XMLParser] if the report is in XML format
|
109
112
|
# @return [Peddler::FlatFileParser] if the report is a flat file
|
data/lib/mws/finances/client.rb
CHANGED
@@ -7,12 +7,12 @@ module MWS
|
|
7
7
|
# With the MWS Finances API you can retrieve financial transactions for your
|
8
8
|
# seller account.
|
9
9
|
class Client < ::Peddler::Client
|
10
|
-
version '2015-05-01'
|
11
|
-
path "/Finances/#{version}"
|
10
|
+
self.version = '2015-05-01'
|
11
|
+
self.path = "/Finances/#{version}"
|
12
12
|
|
13
13
|
# Lists financial events
|
14
14
|
#
|
15
|
-
# @see
|
15
|
+
# @see https://docs.developer.amazonservices.com/en_US/finances/Finances_ListFinancialEvents.html
|
16
16
|
# @param [Hash] opts
|
17
17
|
# @option opts [Integer] :max_results_per_page
|
18
18
|
# @option opts [String] :amazon_order_id
|
@@ -21,13 +21,15 @@ module MWS
|
|
21
21
|
# @option opts [String, #iso8601] :posted_before
|
22
22
|
# @return [Peddler::XMLParser]
|
23
23
|
def list_financial_events(opts = {})
|
24
|
-
operation('ListFinancialEvents')
|
24
|
+
operation('ListFinancialEvents')
|
25
|
+
.add(opts)
|
26
|
+
|
25
27
|
run
|
26
28
|
end
|
27
29
|
|
28
30
|
# Lists the next page of financial events
|
29
31
|
#
|
30
|
-
# @see
|
32
|
+
# @see https://docs.developer.amazonservices.com/en_US/finances/Finances_ListFinancialEventsByNextToken.html
|
31
33
|
# @param [String] next_token
|
32
34
|
# @return [Peddler::XMLParser]
|
33
35
|
def list_financial_events_by_next_token(next_token)
|
@@ -39,7 +41,7 @@ module MWS
|
|
39
41
|
|
40
42
|
# Lists financial event groups
|
41
43
|
#
|
42
|
-
# @see
|
44
|
+
# @see https://docs.developer.amazonservices.com/en_US/finances/Finances_ListFinancialEventGroups.html
|
43
45
|
# @param [String, #iso8601] financial_event_group_started_after
|
44
46
|
# @param [Hash] opts
|
45
47
|
# @option opts [Integer] :max_results_per_page
|
@@ -48,16 +50,16 @@ module MWS
|
|
48
50
|
def list_financial_event_groups(financial_event_group_started_after,
|
49
51
|
opts = {})
|
50
52
|
operation('ListFinancialEventGroups')
|
51
|
-
.add('FinancialEventGroupStartedAfter' =>
|
52
|
-
financial_event_group_started_after)
|
53
53
|
.add(opts)
|
54
|
+
.add('FinancialEventGroupStartedAfter' =>
|
55
|
+
financial_event_group_started_after)
|
54
56
|
|
55
57
|
run
|
56
58
|
end
|
57
59
|
|
58
60
|
# Lists the next page of financial event groups
|
59
61
|
#
|
60
|
-
# @see
|
62
|
+
# @see https://docs.developer.amazonservices.com/en_US/finances/Finances_ListFinancialEventGroupsByNextToken.html
|
61
63
|
# @param [String] next_token
|
62
64
|
# @return [Peddler::XMLParser]
|
63
65
|
def list_financial_event_groups_by_next_token(next_token)
|
@@ -69,11 +71,10 @@ module MWS
|
|
69
71
|
|
70
72
|
# Gets API status
|
71
73
|
#
|
72
|
-
# @see
|
74
|
+
# @see https://docs.developer.amazonservices.com/en_US/finances/Finances_GetServiceStatus.html
|
73
75
|
# @return [Peddler::XMLParser]
|
74
76
|
def get_service_status
|
75
77
|
operation('GetServiceStatus')
|
76
|
-
|
77
78
|
run
|
78
79
|
end
|
79
80
|
end
|
@@ -9,21 +9,19 @@ module MWS
|
|
9
9
|
# also request lists of inbound shipments or inbound shipment items based on
|
10
10
|
# criteria that you specify.
|
11
11
|
class Client < ::Peddler::Client
|
12
|
-
version '2010-10-01'
|
13
|
-
path "/FulfillmentInboundShipment/#{version}"
|
12
|
+
self.version = '2010-10-01'
|
13
|
+
self.path = "/FulfillmentInboundShipment/#{version}"
|
14
14
|
|
15
15
|
# Returns inbound guidance for a list of items by Seller SKU
|
16
16
|
#
|
17
|
-
# @see
|
17
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetInboundGuidanceForSKU.html
|
18
18
|
# @param [String] marketplace_id
|
19
|
-
# @param [String]
|
19
|
+
# @param [Array<String>] seller_sku_list
|
20
20
|
# @return [Peddler::XMLParser]
|
21
|
-
def get_inbound_guidance_for_sku(marketplace_id, *
|
21
|
+
def get_inbound_guidance_for_sku(marketplace_id, *seller_sku_list)
|
22
22
|
operation('GetInboundGuidanceForSKU')
|
23
|
-
.add(
|
24
|
-
|
25
|
-
'SellerSKUList' => seller_skus
|
26
|
-
)
|
23
|
+
.add('MarketplaceId' => marketplace_id,
|
24
|
+
'SellerSKUList' => seller_sku_list)
|
27
25
|
.structure!('SellerSKUList', 'Id')
|
28
26
|
|
29
27
|
run
|
@@ -31,16 +29,13 @@ module MWS
|
|
31
29
|
|
32
30
|
# Returns inbound guidance for a list of items by ASIN
|
33
31
|
#
|
34
|
-
# @see
|
32
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetInboundGuidanceForASIN.html
|
35
33
|
# @param [String] marketplace_id
|
36
|
-
# @param [String]
|
34
|
+
# @param [Array<String>] asin_list
|
37
35
|
# @return [Peddler::XMLParser]
|
38
|
-
def get_inbound_guidance_for_asin(marketplace_id, *
|
36
|
+
def get_inbound_guidance_for_asin(marketplace_id, *asin_list)
|
39
37
|
operation('GetInboundGuidanceForASIN')
|
40
|
-
.add(
|
41
|
-
'MarketplaceId' => marketplace_id,
|
42
|
-
'ASINList' => asins
|
43
|
-
)
|
38
|
+
.add('MarketplaceId' => marketplace_id, 'ASINList' => asin_list)
|
44
39
|
.structure!('ASINList', 'Id')
|
45
40
|
|
46
41
|
run
|
@@ -48,7 +43,7 @@ module MWS
|
|
48
43
|
|
49
44
|
# Returns the information required to create an inbound shipment
|
50
45
|
#
|
51
|
-
# @see
|
46
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_CreateInboundShipmentPlan.html
|
52
47
|
# @param [Struct, Hash] ship_from_address
|
53
48
|
# @param [Array<Struct, Hash>] inbound_shipment_plan_request_items
|
54
49
|
# @param [Hash] opts
|
@@ -58,13 +53,10 @@ module MWS
|
|
58
53
|
inbound_shipment_plan_request_items,
|
59
54
|
opts = {})
|
60
55
|
operation('CreateInboundShipmentPlan')
|
61
|
-
.add(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
inbound_shipment_plan_request_items
|
66
|
-
)
|
67
|
-
)
|
56
|
+
.add(opts)
|
57
|
+
.add('ShipFromAddress' => ship_from_address,
|
58
|
+
'InboundShipmentPlanRequestItems' =>
|
59
|
+
inbound_shipment_plan_request_items)
|
68
60
|
.structure!('InboundShipmentPlanRequestItems', 'member')
|
69
61
|
|
70
62
|
run
|
@@ -72,7 +64,7 @@ module MWS
|
|
72
64
|
|
73
65
|
# Creates an inbound shipment
|
74
66
|
#
|
75
|
-
# @see
|
67
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_CreateInboundShipment.html
|
76
68
|
# @param [String] shipment_id
|
77
69
|
# @param [Struct, Hash] inbound_shipment_header
|
78
70
|
# @param [Hash] opts
|
@@ -80,19 +72,15 @@ module MWS
|
|
80
72
|
# @return [Peddler::XMLParser]
|
81
73
|
def create_inbound_shipment(shipment_id, inbound_shipment_header,
|
82
74
|
opts = {})
|
83
|
-
build_inbound_shipment_operation(
|
84
|
-
|
85
|
-
shipment_id,
|
86
|
-
inbound_shipment_header,
|
87
|
-
opts
|
88
|
-
)
|
75
|
+
build_inbound_shipment_operation('CreateInboundShipment', shipment_id,
|
76
|
+
inbound_shipment_header, opts)
|
89
77
|
|
90
78
|
run
|
91
79
|
end
|
92
80
|
|
93
81
|
# Updates an existing inbound shipment
|
94
82
|
#
|
95
|
-
# @see
|
83
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_UpdateInboundShipment.html
|
96
84
|
# @param [String] shipment_id
|
97
85
|
# @param [Struct, Hash] inbound_shipment_header
|
98
86
|
# @param [Hash] opts
|
@@ -100,42 +88,33 @@ module MWS
|
|
100
88
|
# @return [Peddler::XMLParser]
|
101
89
|
def update_inbound_shipment(shipment_id, inbound_shipment_header,
|
102
90
|
opts = {})
|
103
|
-
build_inbound_shipment_operation(
|
104
|
-
|
105
|
-
shipment_id,
|
106
|
-
inbound_shipment_header,
|
107
|
-
opts
|
108
|
-
)
|
91
|
+
build_inbound_shipment_operation('UpdateInboundShipment', shipment_id,
|
92
|
+
inbound_shipment_header, opts)
|
109
93
|
|
110
94
|
run
|
111
95
|
end
|
112
96
|
|
113
97
|
# Returns pre-order information, including dates
|
114
98
|
#
|
115
|
-
# @see
|
99
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPreorderInfo.html
|
116
100
|
# @param [String] shipment_id
|
117
101
|
# @return [Peddler::XMLParser]
|
118
102
|
def get_preorder_info(shipment_id)
|
119
103
|
operation('GetPreorderInfo')
|
120
|
-
.add(
|
121
|
-
'ShipmentId' => shipment_id
|
122
|
-
)
|
104
|
+
.add('ShipmentId' => shipment_id)
|
123
105
|
|
124
106
|
run
|
125
107
|
end
|
126
108
|
|
127
109
|
# Confirms a shipment for pre-order
|
128
110
|
#
|
129
|
-
# @see
|
111
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ConfirmPreorder.html
|
130
112
|
# @param [String] shipment_id
|
131
113
|
# @param [#iso8601] need_by_date
|
132
114
|
# @return [Peddler::XMLParser]
|
133
115
|
def confirm_preorder(shipment_id, need_by_date)
|
134
116
|
operation('ConfirmPreorder')
|
135
|
-
.add(
|
136
|
-
'ShipmentId' => shipment_id,
|
137
|
-
'NeedByDate' => need_by_date
|
138
|
-
)
|
117
|
+
.add('ShipmentId' => shipment_id, 'NeedByDate' => need_by_date)
|
139
118
|
|
140
119
|
run
|
141
120
|
end
|
@@ -143,16 +122,14 @@ module MWS
|
|
143
122
|
# Returns labeling requirements and item preparation instructions to help
|
144
123
|
# you prepare items for an inbound shipment
|
145
124
|
#
|
146
|
-
# @see
|
125
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPrepInstructionsForSKU.html
|
147
126
|
# @param [String] ship_to_country_code
|
148
|
-
# @param [String]
|
127
|
+
# @param [Array<String>] seller_sku_list
|
149
128
|
# @return [Peddler::XMLParser]
|
150
|
-
def get_prep_instructions_for_sku(ship_to_country_code, *
|
129
|
+
def get_prep_instructions_for_sku(ship_to_country_code, *seller_sku_list)
|
151
130
|
operation('GetPrepInstructionsForSKU')
|
152
|
-
.add(
|
153
|
-
|
154
|
-
'ShipToCountryCode' => ship_to_country_code
|
155
|
-
)
|
131
|
+
.add('SellerSKUList' => seller_sku_list,
|
132
|
+
'ShipToCountryCode' => ship_to_country_code)
|
156
133
|
.structure!('SellerSKUList', 'Id')
|
157
134
|
|
158
135
|
run
|
@@ -161,16 +138,14 @@ module MWS
|
|
161
138
|
# Returns item preparation instructions to help with item sourcing
|
162
139
|
# decisions
|
163
140
|
#
|
164
|
-
# @see
|
141
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPrepInstructionsForASIN.html
|
165
142
|
# @param [String] ship_to_country_code
|
166
|
-
# @param [String]
|
143
|
+
# @param [Array<String>] asin_list
|
167
144
|
# @return [Peddler::XMLParser]
|
168
|
-
def get_prep_instructions_for_asin(ship_to_country_code, *
|
145
|
+
def get_prep_instructions_for_asin(ship_to_country_code, *asin_list)
|
169
146
|
operation('GetPrepInstructionsForASIN')
|
170
|
-
.add(
|
171
|
-
|
172
|
-
'ShipToCountryCode' => ship_to_country_code
|
173
|
-
)
|
147
|
+
.add('ASINList' => asin_list,
|
148
|
+
'ShipToCountryCode' => ship_to_country_code)
|
174
149
|
.structure!('ASINList', 'Id')
|
175
150
|
|
176
151
|
run
|
@@ -178,7 +153,7 @@ module MWS
|
|
178
153
|
|
179
154
|
# Sends transportation information to Amazon about an inbound shipment
|
180
155
|
#
|
181
|
-
# @see
|
156
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_PutTransportContent.html
|
182
157
|
# @param [String] shipment_id
|
183
158
|
# @param [Boolean] is_partnered
|
184
159
|
# @param [String] shipment_type
|
@@ -187,12 +162,9 @@ module MWS
|
|
187
162
|
def put_transport_content(shipment_id, is_partnered, shipment_type,
|
188
163
|
transport_details)
|
189
164
|
operation('PutTransportContent')
|
190
|
-
.add(
|
191
|
-
|
192
|
-
|
193
|
-
'ShipmentType' => shipment_type,
|
194
|
-
'TransportDetails' => transport_details
|
195
|
-
)
|
165
|
+
.add('ShipmentId' => shipment_id, 'IsPartnered' => is_partnered,
|
166
|
+
'ShipmentType' => shipment_type,
|
167
|
+
'TransportDetails' => transport_details)
|
196
168
|
.structure!('PackageList', 'member')
|
197
169
|
.structure!('PalletList', 'member')
|
198
170
|
|
@@ -201,50 +173,58 @@ module MWS
|
|
201
173
|
|
202
174
|
# Requests an estimate of the shipping cost for an inbound shipment
|
203
175
|
#
|
204
|
-
# @see
|
176
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_EstimateTransportRequest.html
|
205
177
|
# @param [String] shipment_id
|
206
178
|
# @return [Peddler::XMLParser]
|
207
179
|
def estimate_transport_request(shipment_id)
|
208
|
-
operation('EstimateTransportRequest')
|
180
|
+
operation('EstimateTransportRequest')
|
181
|
+
.add('ShipmentId' => shipment_id)
|
182
|
+
|
209
183
|
run
|
210
184
|
end
|
211
185
|
|
212
186
|
# Returns current transportation information about an inbound shipment
|
213
187
|
#
|
214
|
-
# @see
|
188
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetTransportContent.html
|
215
189
|
# @param [String] shipment_id
|
216
190
|
# @return [Peddler::XMLParser]
|
217
191
|
def get_transport_content(shipment_id)
|
218
|
-
operation('GetTransportContent')
|
192
|
+
operation('GetTransportContent')
|
193
|
+
.add('ShipmentId' => shipment_id)
|
194
|
+
|
219
195
|
run
|
220
196
|
end
|
221
197
|
|
222
198
|
# Confirms that you accept the Amazon-partnered shipping estimate and you
|
223
199
|
# request that the Amazon-partnered carrier ship your inbound shipment
|
224
200
|
#
|
225
|
-
# @see
|
201
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ConfirmTransportRequest.html
|
226
202
|
# @param [String] shipment_id
|
227
203
|
# @return [Peddler::XMLParser]
|
228
204
|
def confirm_transport_request(shipment_id)
|
229
|
-
operation('ConfirmTransportRequest')
|
205
|
+
operation('ConfirmTransportRequest')
|
206
|
+
.add('ShipmentId' => shipment_id)
|
207
|
+
|
230
208
|
run
|
231
209
|
end
|
232
210
|
|
233
211
|
# Voids a previously-confirmed request to ship your inbound shipment using
|
234
212
|
# an Amazon-partnered carrier
|
235
213
|
#
|
236
|
-
# @see
|
214
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_VoidTransportRequest.html
|
237
215
|
# @param [String] shipment_id
|
238
216
|
# @return [Peddler::XMLParser]
|
239
217
|
def void_transport_request(shipment_id)
|
240
|
-
operation('VoidTransportRequest')
|
218
|
+
operation('VoidTransportRequest')
|
219
|
+
.add('ShipmentId' => shipment_id)
|
220
|
+
|
241
221
|
run
|
242
222
|
end
|
243
223
|
|
244
224
|
# Returns PDF document data for printing package labels for an inbound
|
245
225
|
# shipment
|
246
226
|
#
|
247
|
-
# @see
|
227
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPackageLabels.html
|
248
228
|
# @param [String] shipment_id
|
249
229
|
# @param [String] page_type
|
250
230
|
# @param [Hash] opts
|
@@ -252,10 +232,8 @@ module MWS
|
|
252
232
|
# @return [Peddler::XMLParser]
|
253
233
|
def get_package_labels(shipment_id, page_type, opts = {})
|
254
234
|
operation('GetPackageLabels')
|
255
|
-
.add(opts
|
256
|
-
|
257
|
-
'PageType' => page_type
|
258
|
-
))
|
235
|
+
.add(opts)
|
236
|
+
.add('ShipmentId' => shipment_id, 'PageType' => page_type)
|
259
237
|
|
260
238
|
run
|
261
239
|
end
|
@@ -263,7 +241,7 @@ module MWS
|
|
263
241
|
# Returns unique package labels for faster and more accurate shipment
|
264
242
|
# processing at the Amazon fulfillment centre
|
265
243
|
#
|
266
|
-
# @see
|
244
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetUniquePackageLabels.html
|
267
245
|
# @param [String] shipment_id
|
268
246
|
# @param [String] page_type
|
269
247
|
# @param [Array<String>] package_labels_to_print
|
@@ -271,11 +249,8 @@ module MWS
|
|
271
249
|
def get_unique_package_labels(shipment_id, page_type,
|
272
250
|
package_labels_to_print)
|
273
251
|
operation('GetUniquePackageLabels')
|
274
|
-
.add(
|
275
|
-
|
276
|
-
'PageType' => page_type,
|
277
|
-
'PackageLabelsToPrint' => package_labels_to_print
|
278
|
-
)
|
252
|
+
.add('ShipmentId' => shipment_id, 'PageType' => page_type,
|
253
|
+
'PackageLabelsToPrint' => package_labels_to_print)
|
279
254
|
.structure!('PackageLabelsToPrint', 'member')
|
280
255
|
|
281
256
|
run
|
@@ -283,18 +258,15 @@ module MWS
|
|
283
258
|
|
284
259
|
# Returns pallet labels
|
285
260
|
#
|
286
|
-
# @see
|
261
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPalletLabels.html
|
287
262
|
# @param [String] shipment_id
|
288
263
|
# @param [String] page_type
|
289
264
|
# @param [Integer] number_of_pallets
|
290
265
|
# @return [Peddler::XMLParser]
|
291
266
|
def get_pallet_labels(shipment_id, page_type, number_of_pallets)
|
292
267
|
operation('GetPalletLabels')
|
293
|
-
.add(
|
294
|
-
|
295
|
-
'PageType' => page_type,
|
296
|
-
'NumberOfPallets' => number_of_pallets
|
297
|
-
)
|
268
|
+
.add('ShipmentId' => shipment_id, 'PageType' => page_type,
|
269
|
+
'NumberOfPallets' => number_of_pallets)
|
298
270
|
|
299
271
|
run
|
300
272
|
end
|
@@ -302,17 +274,18 @@ module MWS
|
|
302
274
|
# Returns PDF document data for printing a bill of lading for an inbound
|
303
275
|
# shipment
|
304
276
|
#
|
305
|
-
# @see
|
277
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetBillOfLading.html
|
306
278
|
# @param [String] shipment_id
|
307
279
|
# @return [Peddler::XMLParser]
|
308
280
|
def get_bill_of_lading(shipment_id)
|
309
|
-
operation('GetBillOfLading')
|
281
|
+
operation('GetBillOfLading')
|
282
|
+
.add('ShipmentId' => shipment_id)
|
310
283
|
run
|
311
284
|
end
|
312
285
|
|
313
286
|
# Returns a list of inbound shipments based on criteria that you specify
|
314
287
|
#
|
315
|
-
# @see
|
288
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ListInboundShipments.html
|
316
289
|
# @param [Hash] opts
|
317
290
|
# @option opts [Array<String>] :shipment_status_list
|
318
291
|
# @option opts [Array<String>] :shipment_id_list
|
@@ -330,7 +303,7 @@ module MWS
|
|
330
303
|
|
331
304
|
# Returns the next page of inbound shipments
|
332
305
|
#
|
333
|
-
# @see
|
306
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ListInboundShipmentsByNextToken.html
|
334
307
|
# @param [String] next_token
|
335
308
|
# @return [Peddler::XMLParser]
|
336
309
|
def list_inbound_shipments_by_next_token(next_token)
|
@@ -343,20 +316,22 @@ module MWS
|
|
343
316
|
# Returns a list of items in a specified inbound shipment, or a list of
|
344
317
|
# items that were updated within a specified time frame
|
345
318
|
#
|
346
|
-
# @see
|
319
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ListInboundShipmentItems.html
|
347
320
|
# @param [Hash] opts
|
348
321
|
# @option opts [String] :shipment_id
|
349
322
|
# @option opts [String, #iso8601] :last_updated_after
|
350
323
|
# @option opts [String, #iso8601] :last_updated_before
|
351
324
|
# @return [Peddler::XMLParser]
|
352
325
|
def list_inbound_shipment_items(opts = {})
|
353
|
-
operation('ListInboundShipmentItems')
|
326
|
+
operation('ListInboundShipmentItems')
|
327
|
+
.add(opts)
|
328
|
+
|
354
329
|
run
|
355
330
|
end
|
356
331
|
|
357
332
|
# Returns the next page of inbound shipment items
|
358
333
|
#
|
359
|
-
# @see
|
334
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_ListInboundShipmentItemsByNextToken.html
|
360
335
|
# @param [String] next_token
|
361
336
|
# @return [Peddler::XMLParser]
|
362
337
|
def list_inbound_shipment_items_by_next_token(next_token)
|
@@ -368,7 +343,7 @@ module MWS
|
|
368
343
|
|
369
344
|
# Gets the operational status of the API
|
370
345
|
#
|
371
|
-
# @see
|
346
|
+
# @see https://docs.developer.amazonservices.com/en_US/fba_inbound/MWS_GetServiceStatus.html
|
372
347
|
# @return [Peddler::XMLParser]
|
373
348
|
def get_service_status
|
374
349
|
operation('GetServiceStatus')
|
@@ -380,12 +355,9 @@ module MWS
|
|
380
355
|
def build_inbound_shipment_operation(operation_name, shipment_id,
|
381
356
|
inbound_shipment_header, opts)
|
382
357
|
operation(operation_name)
|
383
|
-
.add(
|
384
|
-
|
385
|
-
|
386
|
-
'InboundShipmentHeader' => inbound_shipment_header
|
387
|
-
)
|
388
|
-
)
|
358
|
+
.add(opts)
|
359
|
+
.add('ShipmentId' => shipment_id,
|
360
|
+
'InboundShipmentHeader' => inbound_shipment_header)
|
389
361
|
.structure!('InboundShipmentItems', 'member')
|
390
362
|
end
|
391
363
|
end
|