Class: Paapi::Listing

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/paapi/listing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Listing

Returns a new instance of Listing.



11
12
13
# File 'lib/paapi/listing.rb', line 11

def initialize(data)
  @hash = data
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



10
11
12
# File 'lib/paapi/listing.rb', line 10

def hash
  @hash
end

Instance Method Details

#amazon_fulfilled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/paapi/listing.rb', line 19

def amazon_fulfilled?
  get(%w{DeliveryInfo IsAmazonFulfilled})
end

#availabilityObject



15
16
17
# File 'lib/paapi/listing.rb', line 15

def availability
  get(%w{Availability Message})
end

#conditionObject



39
40
41
# File 'lib/paapi/listing.rb', line 39

def condition
  get(%w{Condition Value})
end

#free_shipping_eligible?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/paapi/listing.rb', line 23

def free_shipping_eligible?
  get(%w{DeliveryInfo IsFreeShippingEligible})
end

#get(keys) ⇒ Object



43
44
45
# File 'lib/paapi/listing.rb', line 43

def get(keys)
  @hash.dig(*keys)
end

#merchantObject



35
36
37
# File 'lib/paapi/listing.rb', line 35

def merchant
  get(%w{MerchantInfo Name})
end

#priceObject



31
32
33
# File 'lib/paapi/listing.rb', line 31

def price
  get(%w{Price})
end

#prime_eligible?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/paapi/listing.rb', line 27

def prime_eligible?
  get(%w{DeliveryInfo IsPrimeEligible})
end