Class: Peddler::Marketplace Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

IDS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  'CA' => 'A2EUQ1WTGCTBG2',
  'MX' => 'A1AM78C64UM0Y8',
  'US' => 'ATVPDKIKX0DER',
  'BR' => 'A2Q3Y263D00KWC',
  'DE' => 'A1PA6795UKMFR9',
  'ES' => 'A1RKKUPIHCS9HS',
  'FR' => 'A13V1IB3VIYZZH',
  'IT' => 'APJ6JRA9NG5V4',
  'UK' => 'A1F83G8C2ARO7P',
  'IN' => 'A21TJRUUN4KGV',
  'AU' => 'A39IBJ37TRP1C6',
  'JP' => 'A1VC38T7YXB528',
  'CN' => 'AAHKV2X7AFYLW'
}.freeze
HOSTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  'CA' => 'mws.amazonservices.com',
  'MX' => 'mws.amazonservices.com',
  'US' => 'mws.amazonservices.com',
  'BR' => 'mws.amazonservices.com',
  'DE' => 'mws-eu.amazonservices.com',
  'ES' => 'mws-eu.amazonservices.com',
  'FR' => 'mws-eu.amazonservices.com',
  'IT' => 'mws-eu.amazonservices.com',
  'UK' => 'mws-eu.amazonservices.com',
  'IN' => 'mws.amazonservices.in',
  'AU' => 'mws.amazonservices.com.au',
  'JP' => 'mws.amazonservices.jp',
  'CN' => 'mws.amazonservices.com.cn'
}.freeze
BadId =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Marketplace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Marketplace.



43
44
45
# File 'lib/peddler/marketplace.rb', line 43

def initialize(id)
  @id = id || raise(BadId, 'missing MarketplaceId')
end

Instance Attribute Details

#idObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/peddler/marketplace.rb', line 41

def id
  @id
end

Instance Method Details

#country_codeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/peddler/marketplace.rb', line 47

def country_code
  @country_code ||= find_country_code
end

#encodingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Caveat: We use the supersets Windows-31J and CP1252 in place of Shift_JIS and ISO 8859-1 respectively to handle edge cases where latter will not support some characters. The supersets should be safe to use as drop-in replacements.



59
60
61
62
63
64
65
66
67
68
# File 'lib/peddler/marketplace.rb', line 59

def encoding
  case country_code
  when 'JP'
    'Windows-31J'
  when 'CN'
    'UTF-16'
  else
    'CP1252'
  end
end

#hostObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/peddler/marketplace.rb', line 51

def host
  @host ||= find_host
end