peddler 0.3.1 → 0.4.1

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.
data/LICENSE CHANGED
@@ -1,10 +1,10 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2009-2010 Paper Cavalier
3
+ Copyright (c) 2012 Paper Cavalier
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
7
+ "Software"), to deal in the Software without restriction, including
8
8
  without limitation the rights to use, copy, modify, merge, publish,
9
9
  distribute, sublicense, and/or sell copies of the Software, and to
10
10
  permit persons to whom the Software is furnished to do so, subject to
@@ -13,7 +13,7 @@ the following conditions:
13
13
  The above copyright notice and this permission notice shall be
14
14
  included in all copies or substantial portions of the Software.
15
15
 
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
17
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
18
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
19
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
data/README.md CHANGED
@@ -1,128 +1,65 @@
1
- Peddler
2
- =======
1
+ # Peddler
3
2
 
4
- Peddler is a Ruby wrapper to the Amazon Inventory management API.
3
+ [![travis][1]][2]
5
4
 
6
- ![Peddler](http://github.com/papercavalier/peddler/raw/master/mussels.jpg)
5
+ ![Peddler][3]
7
6
 
8
- Example usage
9
- -------------
7
+ Peddler wraps the [Amazon Marketplace Web Service (MWS) APIs][4].
10
8
 
11
- Set up a client:
9
+ ```ruby
10
+ service = Peddler.new 'US'
12
11
 
13
- client = Peddler::Client.new(
14
- :username => 'foo@bar.com',
15
- :password => 'secret',
16
- :region => :us)
12
+ service.configure key: 'key',
13
+ secret: 'secret',
14
+ seller: 'seller'
17
15
 
18
- Create an inventory file:
16
+ service.status # => "GREEN"
17
+ ```
19
18
 
20
- batch = client.new_inventory_batch
21
- item = client.new_inventory_item(
22
- :product_id => '1234567890',
23
- :price => 100.00,
24
- :sku => 'SKU-123',
25
- :quantity => 10)
26
- batch << item
19
+ ## Feeds
27
20
 
28
- Repeat ad infinitum and upload:
21
+ The Feeds API lets you upload inventory and order data to Amazon.
29
22
 
30
- batch.upload
23
+ ## Fulfillment Inbound Shipment
31
24
 
32
- The batch now should have an upload ID. Now, check the error log:
25
+ With the Fulfillment Inbound Shipment API, you can create and update inbound
26
+ shipments of inventory in the Amazon Fulfillment Network. You can also request
27
+ lists of inbound shipments or inbound shipment items based on criteria that you
28
+ specify.
33
29
 
34
- upload_log = client.new_report(
35
- :upload,
36
- :id => batch.id)
37
- upload_log.body
38
- => "Feed Processing Summary:\n\tNumber of records processed\t\t1\n\tNumber of records successful\t\t1\n\n"
30
+ ## Fulfillment Inventory
39
31
 
40
- You are wondering if you have any new orders:
32
+ The Fulfillment Inventory API lets you see what is available in your inventory.
33
+ It's a real-time reporting mechanism that returns your current or
34
+ recently-changed inventory supply in the Amazon fulfillment network.
41
35
 
42
- orders_report = client.new_report :order
43
- orders = client.detab(orders_report.body)
44
- p orders.size
45
- => 1500
46
- p orders[0].item_name
47
- => "A Thousand Plateaus: Capitalism and Schizophrenia (Paperback) by Gilles Deleuze"
36
+ ## Fulfillment Outbound Shipment
48
37
 
49
- After processing the orders, post back the results to Amazon:
38
+ The Fulfillment Outbound Shipment API is designed to help you integrate
39
+ Fulfillment by Amazon with any payment processing application or inventory
40
+ management system currently in use.
50
41
 
51
- feed = client.new_order_fulfillment_feed
52
- fulfilled_order = client.new_fulfilled_order(
53
- :order_id => '123-1234567-1234567',
54
- :order_date => '2009-08-01',
55
- :carrier_code => 'USPS',
56
- :tracking_number => '0308 0330 0000 0000 0000')
57
- feed << fulfilled_order
42
+ ## Orders
58
43
 
59
- Once done, upload:
44
+ The Orders API helps you build simple applications that retrieve only the order
45
+ information that you need.
60
46
 
61
- feed.upload
47
+ ## Products
62
48
 
63
- Want to see the processing report?
49
+ The Products API helps you get information to match your products to existing
50
+ product listings on Amazon Marketplace websites and to make sourcing and
51
+ pricing decisions for listing those products on Amazon Marketplace websites.
64
52
 
65
- p feed.status
66
- => "_SUBMITTED_"
53
+ ## Reports
67
54
 
68
- Refresh until you get:
55
+ The Reports API lets you request reports about your inventory and orders.
69
56
 
70
- p feed.status!
71
- => "_DONE_"
57
+ ## Sellers
72
58
 
73
- Then, check the report:
59
+ The Sellers API lets sellers retrieve information about their seller account,
60
+ such as the marketplaces they participate in.
74
61
 
75
- p feed.download.to_s
76
-
77
- You have an order you can't fill and haven't shipped yet. No problem:
78
-
79
- feed = client.new_order_cancellation_feed
80
- cancelled_order = client.new_cancelled_order(
81
- :order_id => '123-1234567-1234567',
82
- :cancellation_reason_code => 'NoInventory',
83
- :amazon_order_item_code => '12341234567890')
84
- feed << cancelled_order
85
- feed.upload
86
- sleep(60)
87
- feed.status!
88
- => "_DONE_"
89
- p feed.download.to_s
90
- => ...
91
-
92
- To post a refund for an already-shipped item, you use the batch refund method:
93
-
94
- refunds = client.new_refund_batch
95
- refund = client.new_refund(
96
- :order_id => '123-1234567-1234567',
97
- :payments_transaction_id => '12341234567890',
98
- :refund_amount => 1.00,
99
- :reason => 'GeneralAdjustment',
100
- :message => 'With our apologies.')
101
- refunds << refund
102
- refunds.upload
103
-
104
- For a change, let's download something different from Amazon, like a preorder report:
105
-
106
- preorder_report = client.new_report(
107
- :preorder,
108
- :product_line => 'Books',
109
- :frequency => 2)
110
- preorders = client.detab(preorder_report.body)
111
- p preorders.size
112
- => 2000
113
- p preorders[0].asin
114
- => "1234567890"
115
- p preorders[0].average_asking_price
116
- => "100"
117
-
118
- [Read source](http://gloss.papercavalier.com/peddler) for more info.
119
-
120
- Todo
121
- ----
122
-
123
- Switch to using the [Amazon Marketplace Web Service (Amazon MWS)](https://mws.amazon.com/index.html).
124
-
125
- Compatibility
126
- -------------
127
-
128
- Specs pass against Ruby 1.8.7, Ruby 1.9.2, and Rubinius 1.1.
62
+ [1]: https://secure.travis-ci.org/papercavalier/peddler.png
63
+ [2]: http://travis-ci.org/papercavalier/peddler
64
+ [3]: http://f.cl.ly/items/0W3V0A1Z110Q0x461b3H/mussels.jpeg
65
+ [4]: https://developer.amazonservices.com/gp/mws/docs.html
data/lib/peddler/feeds.rb CHANGED
@@ -1,187 +1,7 @@
1
- module Peddler
2
-
3
- # This module includes functionality to handle the charge-when-ship-related
4
- # feeds Amazon added to the API in 2009.
5
- module Feeds
6
-
7
- # This is a downloadable file. Outputs Amazon's response verbatim for now.
8
- class Download
9
- attr_accessor :id, :type, :related_reference_id, :available_at, :acknowledged
10
-
11
- MAPPED_PARAMS = {
12
- 'DownloadId' => 'id',
13
- 'DownloadType' => 'type',
14
- 'RelatedReferenceId' => 'related_reference_id',
15
- 'AvailableDate' => 'available_at',
16
- 'Acknowledged' => 'acknowledged'}
17
-
18
- def initialize(transport, params={})
19
- @transport = transport
20
- params.each_pair{ |k, v| self.send "#{MAPPED_PARAMS[k]}=", v }
21
- end
22
-
23
- # Retrieves and returns report.
24
- def to_s
25
- @body ||= download_report
26
- end
27
-
28
- private
29
-
30
- def download_report
31
- return nil if @id.nil?
32
- @transport.modernize_request
33
- @transport.query_params.merge!({
34
- 'Action' => 'download',
35
- 'downloadId' => @id})
36
- @transport.execute_request
37
- end
38
- end
39
-
40
- # This is the base class.
41
- class Feed
42
- attr_writer :file_content
43
- attr_accessor :batch, :download, :status, :type, :id, :submitted_at, :started_processing_at, :completed_processing_at, :messages_processed, :messages_successful, :messages_with_errors, :messages_with_warnings
44
-
45
- MAPPED_PARAMS = {
46
- 'UploadStatus' => 'status',
47
- 'UploadType' => 'type',
48
- 'UploadId' => 'id',
49
- 'SubmittedDate' => 'submitted_at',
50
- 'StartedProcessingDate' => 'started_processing_at',
51
- 'CompletedProcessingDate' => 'completed_processing_at',
52
- 'CompletedProcesssingDate' => 'completed_processing_at',
53
- 'MessagesProcessed' => 'messages_processed',
54
- 'MessagesSuccessful' => 'messages_successful',
55
- 'MessagesWithErrors' => 'messages_with_errors',
56
- 'MessagesWithWarnings' => 'messages_with_warnings'}
57
-
58
- def initialize(transport)
59
- @transport = transport
60
- @batch = []
61
- end
62
-
63
- # Returns content of the upload file.
64
- def file_content
65
- return @file_content if @file_content
66
- out = @file_header
67
- @batch.each{ |item| out << item.to_s }
68
- @file_content = out
69
- end
70
-
71
- # Returns status and will also refresh if not already "done."
72
- def status!
73
- return @status if @status.nil? || @status =~ /_DONE_/
74
- refresh_status
75
- @status
76
- end
77
-
78
- # Uploads batch.
79
- def upload
80
- raise PeddlerError.new('Batch already uploaded') unless @id.nil?
81
- @transport.modernize_request
82
- @transport.query_params.merge!({
83
- 'Action' => 'upload',
84
- 'uploadType' => @type})
85
- @transport.body = file_content
86
- res = @transport.execute_request
87
- process_response(res)
88
- @status
89
- end
1
+ require 'peddler/service'
90
2
 
91
- # Adds an item to the batch.
92
- def <<(item)
93
- @batch << item
94
- end
95
-
96
- private
97
-
98
- def refresh_status
99
- @transport.modernize_request
100
- @transport.query_params.merge!({
101
- 'Action' => 'uploadStatus',
102
- 'uploadId' => @id})
103
- res = @transport.execute_request
104
- process_response(res)
105
- end
106
-
107
- def process_response(res)
108
- upload = Hash.from_xml(res)['Response']['Upload'] || Hash.from_xml(res)['Response']['UploadsStatusList']['Upload']
109
- upload.each_pair do |key, value|
110
- if key == 'RelatedDownloadsList'
111
- @download = Peddler::Feeds::Download.new(@transport, value['Download'])
112
- else
113
- self.send "#{MAPPED_PARAMS[key]}=", value
114
- end
115
- end
116
- end
117
- end
118
-
119
- module OrderFulfillment
120
- # This class contains methods to upload order fulfillment info to Amazon.
121
- # See sections 7.1 through 7.3 in the API documentation for more detail.
122
- class Batch < Peddler::Feeds::Feed
123
- def initialize(transport)
124
- @file_header = "order-id\torder-item-id\tquantity\tship-date\tcarrier-code\tcarrier-name\ttracking-number\tship-method\r\n"
125
- @type = '_POST_FLAT_FILE_FULFILLMENT_DATA_'
126
- super(transport)
127
- end
128
- end
129
-
130
- # This is an order fulfillment item.
131
- class Item
132
- attr_accessor :order_id, :order_item_id, :quantity, :ship_date, :carrier_name, :tracking_number, :ship_method
133
- attr_reader :carrier_code
134
-
135
- def initialize(params={})
136
- params.each_pair{ |key, value| send("#{key}=", value) }
137
- end
138
-
139
- # Validates when setting carrier code.
140
- def carrier_code=(carrier_code)
141
- @carrier_code = carrier_code if %w{USPS UPS FedEx other}.include?(carrier_code)
142
- end
143
-
144
- # Outputs a formatted line for the tab-delimited upload file.
145
- def to_s
146
- "#{@order_id}\t#{@order_item_id}\t#{@quantity}\t#{@ship_date}\t#{@carrier_code}\t#{@carrier_name}\t#{@tracking_number}\t#{@ship_method}\r\n"
147
- end
148
- end
149
- end
150
-
151
- # This module contains methods to upload cancelled orders to Amazon.
152
- # See section 7.4 in the API documentation for more detail.
153
- module OrderCancellation
154
- class Batch < Peddler::Feeds::Feed
155
- def initialize(transport)
156
- @file_header = "TemplateType=OrderCancellation Version=1.0/1.0.3 This row for Amazon.com use only. Do not modify or delete.\r\n" +
157
- "order-id\tcancellation-reason-code\tamazon-order-item-code\r\n"
158
- @type = '_POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA_'
159
- super(transport)
160
- end
161
- end
162
-
163
- # This is a cancelled order item.
164
- class Item
165
- attr_accessor :order_id, :amazon_order_item_code
166
- attr_reader :cancellation_reason_code
167
-
168
- def initialize(params={})
169
- params.each_pair{ |key, value| send("#{key}=", value) }
170
- end
171
-
172
- # Validates when setting cancellation reason code.
173
- def cancellation_reason_code=(cancellation_reason_code)
174
- @cancellation_reason_code = cancellation_reason_code if %w{ BuyerCanceled CustomerExchange CustomerReturn GeneralAdjustment MerchandiseNotReceived NoInventory ShippingAddressUndeliverable }.include?(cancellation_reason_code)
175
- end
176
-
177
- # Outputs a formatted line for the tab-delimited upload file.
178
- def to_s
179
- if @cancellation_reason_code.nil? != @amazon_order_item_code.nil?
180
- raise PeddlerError.new('Provide codes for both cancellation reason and Amazon order item (or omit both).')
181
- end
182
- "#{@order_id}\t#{@cancellation_reason_code}\t#{@amazon_order_item_code}\r\n"
183
- end
184
- end
185
- end
3
+ module Peddler
4
+ # The Feeds API lets you upload inventory and order data to Amazon.
5
+ class Feeds < Service
186
6
  end
187
7
  end
@@ -0,0 +1,11 @@
1
+ require 'peddler/service'
2
+
3
+ # With the Fulfillment Inbound Shipment API, you can create and update inbound
4
+ # shipments of inventory in the Amazon Fulfillment Network. You can also
5
+ # request lists of inbound shipments or inbound shipment items based on
6
+ # criteria that you specify.
7
+ module Peddler
8
+ class FulfillmentInboundShipment < Service
9
+ path 'FulfillmentInboundShipment/2010-10-01'
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'peddler/service'
2
+
3
+ module Peddler
4
+ # The Fulfillment Inventory API lets you see what is available in your
5
+ # inventory. It's a real-time reporting mechanism that returns your current
6
+ # or recently-changed inventory supply in the Amazon fulfillment network.
7
+ class FulfillmentInventory < Service
8
+ path 'FulfillmentInventory/2010-10-01'
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'peddler/service'
2
+
3
+ module Peddler
4
+ # The Fulfillment Outbound Shipment API is designed to help you integrate
5
+ # Fulfillment by Amazon with any payment processing application or inventory
6
+ # management system currently in use.
7
+ class FulfillmentOutboundShipment < Service
8
+ path 'FulfillmentOutboundShipment/2010-10-01'
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'peddler/service'
2
+
3
+ module Peddler
4
+ # The Orders API helps you build simple applications that retrieve only the
5
+ # order information that you need.
6
+ class Orders < Service
7
+ path 'Orders/2011-01-01'
8
+ end
9
+ end
10
+
@@ -0,0 +1,11 @@
1
+ require 'peddler/service'
2
+
3
+ module Peddler
4
+ # The Products API helps you get information to match your products to
5
+ # existing product listings on Amazon Marketplace websites and to make
6
+ # sourcing and pricing decisions for listing those products on Amazon
7
+ # Marketplace websites.
8
+ class Products < Service
9
+ path 'Products/2011-10-01'
10
+ end
11
+ end
@@ -1,97 +1,7 @@
1
- module Peddler
2
-
3
- # This module generates and downloads unshipped order reports.
4
- # I decided to keep this out of Peddler::LegacyReports because the API is
5
- # quite different.
6
- module Reports
7
-
8
- # This is an unshipped orders report. It is very similar to the feed
9
- # objects, so I'm just porting over the class.
10
- class UnshippedOrdersReport < Peddler::Feeds::Feed
11
- alias :unshipped_orders :batch
12
- attr_accessor :starts_at, :ends_at, :scheduled
13
-
14
- MAPPED_PARAMS = {
15
- 'ReportID' => 'id',
16
- 'StartDate' => 'starts_at',
17
- 'EndDate' => 'ends_at',
18
- 'DownloadType' => 'type',
19
- 'Scheduled' => 'scheduled',
20
- 'ReportStatus' => 'status',
21
- 'SubmittedDate' => 'submitted_at',
22
- 'StartedProcessingDate' => 'started_processing_at',
23
- 'CompletedProcessingDate' => 'completed_processing_at',
24
- 'CompletedProcesssingDate' => 'completed_processing_at'}
25
-
26
- # Creates new unshipped order report. It will send a request to
27
- # Amazon to generate the report if the report ID is not already set.
28
- def initialize(transport, params={})
29
- super(transport)
30
- params.each_pair{ |key, value| self.send "#{key}=", value }
31
- @starts_at ||= (Date.today - 7).strftime("%Y-%m-%dT00:00:00-00:00")
32
- @ends_at ||= (Date.today + 1).strftime("%Y-%m-%dT00:00:00-00:00")
33
- #@type ||= "_GET_CONVERGED_FLAT_FILE_ACTIONABLE_ORDER_DATA_"
34
- @type ||= "_GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_"
35
- if @id.nil?
36
- generate_report
37
- end
38
- self
39
- end
40
-
41
- private
42
-
43
- def refresh_status
44
- @transport.modernize_request
45
- @transport.query_params.merge!({
46
- "Action" => "reportStatus",
47
- "reportId" => @id})
48
- res = @transport.execute_request
49
- process_response(res)
50
- end
1
+ require 'peddler/service'
51
2
 
52
- def generate_report
53
- @transport.modernize_request
54
- @transport.query_params.merge!({
55
- 'Action' => 'generateReport',
56
- 'startDate' => @starts_at,
57
- 'endDate' => @ends_at,
58
- 'downloadType' => @type})
59
- res = @transport.execute_request
60
- process_response(res)
61
- end
62
-
63
- def process_response(res)
64
- hash = Hash.from_xml(res)
65
- report = Hash.from_xml(res)['Response']['Report'] || Hash.from_xml(res)['Response']['ReportsList']['Report']
66
- report.each_pair do |key, value|
67
- if key == "ListOfDownloads"
68
- @download = Peddler::Feeds::Download.new(@transport, value['Download'])
69
- @batch = Peddler::Handlers::TabDelimitedHandler.decode_response(@download.to_s)
70
- else
71
- self.send "#{MAPPED_PARAMS[key]}=", value
72
- end
73
- end
74
- end
75
- end
76
-
77
- # This is an unshipped order.
78
- class Item
79
- attr_accessor :order_id, :order_item_id, :quantity, :ship_date, :carrier_name, :tracking_number, :ship_method
80
- attr_reader :carrier_code
81
-
82
- def initialize(params={})
83
- params.each_pair{ |key, value| send("#{key}=", value) }
84
- end
85
-
86
- # Validates when setting carrier code.
87
- def carrier_code=(carrier_code)
88
- @carrier_code = carrier_code if %w{USPS UPS FedEx other}.include?(carrier_code)
89
- end
90
-
91
- # Outputs a formatted line for the tab-delimited upload file.
92
- def to_s
93
- "#{@order_id}\t#{@order_item_id}\t#{@quantity}\t#{@ship_date}\t#{@carrier_code}\t#{@carrier_name}\t#{@tracking_number}\t#{@ship_method}\r\n"
94
- end
95
- end
3
+ module Peddler
4
+ # The Reports API lets you request reports about your inventory and orders.
5
+ class Reports < Service
96
6
  end
97
7
  end
@@ -0,0 +1,9 @@
1
+ require 'peddler/service'
2
+
3
+ module Peddler
4
+ # The Sellers API lets sellers retrieve information about their seller
5
+ # account, such as the marketplaces they participate in.
6
+ class Sellers < Service
7
+ path 'Sellers/2011-07-01'
8
+ end
9
+ end
@@ -0,0 +1,106 @@
1
+ require 'jeff'
2
+
3
+ module Peddler
4
+ BadLocale = Class.new ArgumentError
5
+ MissingSeller = Class.new ArgumentError
6
+
7
+ # A wrapper around a Marketplace Web Services (MWS) endpoint.
8
+ class Service
9
+ include Jeff
10
+
11
+ class << self
12
+ # Gets/Sets the path of the MWS endpoint.
13
+ #
14
+ # path - A String path (optional).
15
+ def path(path = nil)
16
+ @path = path if path
17
+ @path
18
+ end
19
+ end
20
+
21
+ params 'SellerId' => -> { seller }
22
+
23
+ # A list of MWS hosts.
24
+ HOSTS = {
25
+ 'CA' => 'mws.amazonservices.ca',
26
+ 'CN' => 'mws.amazonservices.com.cn',
27
+ 'DE' => 'mws-eu.amazonservices.com',
28
+ 'ES' => 'mws-eu.amazonservices.com',
29
+ 'FR' => 'mws-eu.amazonservices.com',
30
+ 'IN' => 'mws.amazonservices.in',
31
+ 'IT' => 'mws-eu.amazonservices.com',
32
+ 'JP' => 'mws.amazonservices.jp',
33
+ 'UK' => 'mws-eu.amazonservices.com',
34
+ 'US' => 'mws.amazonservices.com'
35
+ }
36
+
37
+ # A list of MWS marketplace ids.
38
+ MARKETPLACES = {
39
+ 'CA' => 'A2EUQ1WTGCTBG2',
40
+ 'CN' => nil,
41
+ 'DE' => 'A1PA6795UKMFR9',
42
+ 'ES' => 'A1RKKUPIHCS9HS',
43
+ 'FR' => 'A13V1IB3VIYZZH',
44
+ 'IN' => nil,
45
+ 'IT' => 'APJ6JRA9NG5V4',
46
+ 'JP' => 'A1VC38T7YXB528',
47
+ 'UK' => 'A1F83G8C2ARO7P',
48
+ 'US' => 'ATVPDKIKX0DER'
49
+ }
50
+
51
+ def self.inherited(base)
52
+ base.params params
53
+ end
54
+
55
+ # Creates a new service endpoint for given locale.
56
+ #
57
+ # locale - The String MWS API locale.
58
+ #
59
+ # Raises a Bad Locale error if locale is not valid.
60
+ def initialize(locale)
61
+ @host = HOSTS[@locale = locale] or raise BadLocale
62
+ end
63
+
64
+ # Configures the MWS endpoint.
65
+ #
66
+ # credentials - The Hash credentials.
67
+ # :key - The String Amazon Web Services (AWS) key.
68
+ # :secret - The String AWS secret.
69
+ # :seller - The String MWS Seller Id.
70
+ #
71
+ # Returns nothing.
72
+ def configure(credentials)
73
+ credentials.each { |key, val| self.send "#{key}=", val }
74
+ end
75
+
76
+ # Returns the String MWS endpoint.
77
+ def endpoint
78
+ "https://#{@host}/#{self.class.path}"
79
+ end
80
+
81
+ # Returns a String Marketplace id.
82
+ #
83
+ # locale - The String MWS API locale (default: the locale of the service
84
+ # endpoint).
85
+ def marketplace(locale = nil)
86
+ MARKETPLACES[locale || @locale] or raise BadLocale
87
+ end
88
+
89
+ # Gets the String MWS seller id.
90
+ #
91
+ # Raises a Missing Seller error if seller id is missing.
92
+ def seller
93
+ @seller or raise MissingSeller
94
+ end
95
+
96
+ # Sets the String MWS seller id.
97
+ attr_writer :seller
98
+
99
+ # Gets the String service status.
100
+ def status
101
+ get(query: { 'Action' => 'GetServiceStatus' })
102
+ .body
103
+ .match(/GREEN_?I?|YELLOW|RED/)[0]
104
+ end
105
+ end
106
+ end
@@ -1,3 +1,3 @@
1
1
  module Peddler
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.1'
3
3
  end