Class: Peddler::Service
- Inherits:
-
Struct
- Object
- Struct
- Peddler::Service
- Includes:
- Jeff
- Defined in:
- lib/peddler/service.rb
Overview
Service is an abstract wrapper around a Marketplace Web Services (MWS) endpoint.
The initializer takes four arguments:
country - The String ISO 3166-1 two-letter country code of
the base marketplace of the seller.
aws_access_key_id - The String AWS access key id. aws_secret_access_key - The String AWS secret access key. seller_id - The String MWS merchant id.
These arguments are optional and can be set individually later.
Direct Known Subclasses
Feeds, FulfillmentInboundShipment, FulfillmentInventory, FulfillmentOutboundShipment, OffAmazonPayments, Orders, Products, Recommendations, Reports, Sellers, Subscriptions
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', 'GB' => 'mws-eu.amazonservices.com', 'IN' => 'mws.amazonservices.in', 'IT' => 'mws-eu.amazonservices.com', 'JP' => 'mws.amazonservices.jp', 'US' => 'mws.amazonservices.com' }
- MARKETPLACE_IDS =
A list of marketplace ids.
{ 'CA' => 'A2EUQ1WTGCTBG2', 'CN' => 'AAHKV2X7AFYLW', 'DE' => 'A1PA6795UKMFR9', 'ES' => 'A1RKKUPIHCS9HS', 'FR' => 'A13V1IB3VIYZZH', 'GB' => 'A1F83G8C2ARO7P', 'IN' => 'A21TJRUUN4KGV', 'IT' => 'APJ6JRA9NG5V4', 'JP' => 'A1VC38T7YXB528', 'US' => 'ATVPDKIKX0DER' }
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
-
#country ⇒ Object
Returns the value of attribute country.
-
#seller_id ⇒ Object
Returns the value of attribute 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
-
#endpoint ⇒ Object
Returns the String MWS endpoint.
-
#marketplace_id(country) ⇒ Object
Get the marketplace id for a given country.
Instance Attribute Details
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id
16 17 18 |
# File 'lib/peddler/service.rb', line 16 def aws_access_key_id @aws_access_key_id end |
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key
16 17 18 |
# File 'lib/peddler/service.rb', line 16 def aws_secret_access_key @aws_secret_access_key end |
#country ⇒ Object
Returns the value of attribute country
16 17 18 |
# File 'lib/peddler/service.rb', line 16 def country @country end |
#seller_id ⇒ Object
Returns the value of attribute seller_id
16 17 18 |
# File 'lib/peddler/service.rb', line 16 def seller_id @seller_id end |
Class Method Details
.inherited(base) ⇒ Object
54 55 56 57 |
# File 'lib/peddler/service.rb', line 54 def self.inherited(base) base.params(params) base.path(path) end |
.path(path = nil) ⇒ Object
Gets/Sets the path of the MWS endpoint.
path - A String path (default: nil).
50 51 52 |
# File 'lib/peddler/service.rb', line 50 def self.path(path = nil) path ? @path = path : @path end |
Instance Method Details
#endpoint ⇒ Object
Returns the String MWS endpoint.
62 63 64 |
# File 'lib/peddler/service.rb', line 62 def endpoint "https://#{HOSTS.fetch(country)}/#{self.class.path}" end |
#marketplace_id(country) ⇒ Object
Get the marketplace id for a given country.
country - A String ISO 3166-1 two-letter country code.
Returns a String marketplace id.
71 72 73 |
# File 'lib/peddler/service.rb', line 71 def marketplace_id(country) MARKETPLACE_IDS.fetch(country) end |