Class: Peddler::Service
Overview
A wrapper around a Marketplace Web Services (MWS) endpoint.
Direct Known Subclasses
Feeds, FulfillmentInboundShipment, FulfillmentInventory, FulfillmentOutboundShipment, Orders, Products, Reports, Sellers
Constant Summary collapse
- HOSTS =
A list of MWS hosts.
{ 'CA' => 'mws.amazonservices.ca', 'CN' => 'mws.amazonservices.com.cn', 'DE' => 'mws-eu.amazonservices.com', 'ES' => 'mws-eu.amazonservices.com', 'FR' => 'mws-eu.amazonservices.com', 'IN' => 'mws.amazonservices.in', 'IT' => 'mws-eu.amazonservices.com', 'JP' => 'mws.amazonservices.jp', 'UK' => 'mws-eu.amazonservices.com', 'US' => 'mws.amazonservices.com' }
- MARKETPLACES =
A list of MWS marketplace ids.
{ 'CA' => 'A2EUQ1WTGCTBG2', 'CN' => nil, 'DE' => 'A1PA6795UKMFR9', 'ES' => 'A1RKKUPIHCS9HS', 'FR' => 'A13V1IB3VIYZZH', 'IN' => nil, 'IT' => 'APJ6JRA9NG5V4', 'JP' => 'A1VC38T7YXB528', 'UK' => 'A1F83G8C2ARO7P', 'US' => 'ATVPDKIKX0DER' }
Instance Attribute Summary collapse
-
#seller ⇒ Object
Gets the String MWS seller id.
Class Method Summary collapse
- .inherited(base) ⇒ Object
-
.path(path = nil) ⇒ Object
Gets/Sets the path of the MWS endpoint.
Instance Method Summary collapse
-
#configure(credentials) ⇒ Object
Configure the MWS endpoint.
-
#endpoint ⇒ Object
Returns the String MWS endpoint.
-
#initialize(locale) ⇒ Service
constructor
Create a new service endpoint for given locale.
-
#marketplace(locale = nil) ⇒ Object
Returns a String Marketplace id.
-
#status ⇒ Object
Gets the String service status.
Constructor Details
Instance Attribute Details
#seller ⇒ Object
Gets the String MWS seller id.
Raises a Missing Seller error if seller id is missing.
92 93 94 |
# File 'lib/peddler/service.rb', line 92 def seller @seller or raise MissingSeller end |
Class Method Details
.inherited(base) ⇒ Object
51 52 53 |
# File 'lib/peddler/service.rb', line 51 def self.inherited(base) base.params(params) end |
.path(path = nil) ⇒ Object
Gets/Sets the path of the MWS endpoint.
path - A String path (optional).
15 16 17 18 |
# File 'lib/peddler/service.rb', line 15 def path(path = nil) @path = path if path @path end |
Instance Method Details
#configure(credentials) ⇒ Object
Configure the MWS endpoint.
credentials - The Hash credentials.
:key - The String Amazon Web Services (AWS) key.
:secret - The String AWS secret.
:seller - The String MWS Seller Id.
Returns nothing.
72 73 74 |
# File 'lib/peddler/service.rb', line 72 def configure(credentials) credentials.each { |key, val| self.send("#{key}=", val) } end |
#endpoint ⇒ Object
Returns the String MWS endpoint.
77 78 79 |
# File 'lib/peddler/service.rb', line 77 def endpoint "https://#{@host}/#{self.class.path}" end |
#marketplace(locale = nil) ⇒ Object
Returns a String Marketplace id.
locale - The String MWS API locale (default: the locale of the service
endpoint).
85 86 87 |
# File 'lib/peddler/service.rb', line 85 def marketplace(locale = nil) MARKETPLACES[locale || @locale] or raise BadLocale end |
#status ⇒ Object
Gets the String service status.
100 101 102 103 104 |
# File 'lib/peddler/service.rb', line 100 def status get(query: { 'Action' => 'GetServiceStatus' }) .body .match(/GREEN_?I?|YELLOW|RED/)[0] end |