Class: EbayRequest::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/ebay_request/site.rb

Constant Summary collapse

KEYS =
%w(
  globalid id name currency language domain code metric country gtc_available
  free_placement max_insertion_fee free_pictures subtitle_fee quantity_limits
  min_fixed_price
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Site

Returns a new instance of Site.



11
12
13
14
# File 'lib/ebay_request/site.rb', line 11

def initialize(hash)
  @hash = hash
  KEYS.each { |key| instance_variable_set(:"@#{key}", hash[key]) }
end

Instance Method Details

#gtc_available?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/ebay_request/site.rb', line 21

def gtc_available?
  return @gtc_available if [true, false].include? @gtc_available

  raise <<-MESSAGE.gsub(/^ +\|/, "")
    |We haven't checked whether GTC duration is available on the site #{@id}.
    |You should explore if GTC is supported by at least one of its categories (see https://developer.ebay.com/devzone/xml/docs/reference/ebay/GetCategoryFeatures.html)
    |Then you're welcome to make a PR with a resulting value (true|false) added to `config/sites.yml`
  MESSAGE
end

#to_hashObject Also known as: to_h



16
17
18
# File 'lib/ebay_request/site.rb', line 16

def to_hash
  @hash
end