Class: Peddler::Marketplace
- Inherits:
-
Data
- Object
- Data
- Peddler::Marketplace
- Defined in:
- lib/peddler/marketplace.rb,
lib/peddler/marketplace.rb
Overview
Wraps an Amazon marketplace
Instance Attribute Summary collapse
-
#country_code ⇒ Object
readonly
Wraps an Amazon marketplace.
-
#country_name ⇒ Object
readonly
Wraps an Amazon marketplace.
-
#id ⇒ Object
readonly
Wraps an Amazon marketplace.
-
#selling_region ⇒ Object
readonly
Returns the value of attribute selling_region.
Class Method Summary collapse
-
.all ⇒ Array<Peddler::Marketplace>
Returns all marketplaces.
-
.find(country_code) ⇒ Object
Finds the marketplace for the given country code.
-
.id(country_code) ⇒ String
Returns the marketplace ID for the given country code.
-
.ids(*country_codes) ⇒ Array<String>
Returns the marketplace IDs for the given country codes.
Instance Method Summary collapse
-
#endpoint ⇒ Peddler::Endpoint
steep:ignore:start.
-
#to_str ⇒ String
steep:ignore:start.
Instance Attribute Details
#country_code ⇒ Object (readonly)
Wraps an Amazon marketplace
9 |
# File 'lib/peddler/marketplace.rb', line 9 class Peddler::Marketplace < Data; end |
#country_name ⇒ Object (readonly)
Wraps an Amazon marketplace
9 |
# File 'lib/peddler/marketplace.rb', line 9 class Peddler::Marketplace < Data; end |
#id ⇒ Object (readonly)
Wraps an Amazon marketplace
9 |
# File 'lib/peddler/marketplace.rb', line 9 class Peddler::Marketplace < Data; end |
#selling_region ⇒ Object (readonly)
Returns the value of attribute selling_region
9 |
# File 'lib/peddler/marketplace.rb', line 9 class Peddler::Marketplace < Data; end |
Class Method Details
.all ⇒ Array<Peddler::Marketplace>
Returns all marketplaces
73 74 75 76 77 |
# File 'lib/peddler/marketplace.rb', line 73 def all MARKETPLACE_IDS.map do |country_code, values| new(**values, country_code: country_code) end end |
.find(country_code) ⇒ Object
Finds the marketplace for the given country code
46 47 48 49 50 51 52 |
# File 'lib/peddler/marketplace.rb', line 46 def find(country_code) values = MARKETPLACE_IDS.fetch(country_code == "GB" ? "UK" : country_code) do raise ArgumentError, "#{country_code} not found" end new(**values, country_code: country_code) end |
.id(country_code) ⇒ String
Returns the marketplace ID for the given country code
58 59 60 |
# File 'lib/peddler/marketplace.rb', line 58 def id(country_code) find(country_code).id end |
.ids(*country_codes) ⇒ Array<String>
Returns the marketplace IDs for the given country codes
66 67 68 |
# File 'lib/peddler/marketplace.rb', line 66 def ids(*country_codes) country_codes.map { |country_code| id(country_code) } end |
Instance Method Details
#endpoint ⇒ Peddler::Endpoint
steep:ignore:start
96 97 98 |
# File 'lib/peddler/marketplace.rb', line 96 def endpoint Endpoint.find_by_selling_region(selling_region) end |
#to_str ⇒ String
Note:
So HTTP can encode
steep:ignore:start
104 105 106 |
# File 'lib/peddler/marketplace.rb', line 104 def to_str id end |