Class: Peddler::Marketplace

Inherits:
Data
  • Object
show all
Defined in:
lib/peddler/marketplace.rb,
lib/peddler/marketplace.rb

Overview

Wraps an Amazon marketplace

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#country_codeObject (readonly)

Wraps an Amazon marketplace



9
# File 'lib/peddler/marketplace.rb', line 9

class Peddler::Marketplace < Data; end

#country_nameObject (readonly)

Wraps an Amazon marketplace



9
# File 'lib/peddler/marketplace.rb', line 9

class Peddler::Marketplace < Data; end

#idObject (readonly)

Wraps an Amazon marketplace



9
# File 'lib/peddler/marketplace.rb', line 9

class Peddler::Marketplace < Data; end

#selling_regionObject (readonly)

Returns the value of attribute selling_region

Returns:

  • (Object)

    the current value of selling_region



9
# File 'lib/peddler/marketplace.rb', line 9

class Peddler::Marketplace < Data; end

Class Method Details

.allArray<Peddler::Marketplace>

Returns all marketplaces

Returns:



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

Parameters:

  • country_code (String)


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

Parameters:

  • country_code (String)

Returns:

  • (String)


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

Parameters:

  • country_codes (Array<String>)

Returns:

  • (Array<String>)


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

#endpointPeddler::Endpoint

steep:ignore:start

Returns:



96
97
98
# File 'lib/peddler/marketplace.rb', line 96

def endpoint
  Endpoint.find_by_selling_region(selling_region)
end

#to_strString

Note:

So HTTP can encode

steep:ignore:start

Returns:

  • (String)


104
105
106
# File 'lib/peddler/marketplace.rb', line 104

def to_str
  id
end