Class: TCGPlayerSDK::ProductPrice

Inherits:
ResponseStruct show all
Defined in:
lib/tcg-player-sdk/product_price_list.rb

Overview

A wrapper around the ResponseStruct for an individual product subtype's price.

{
         "productId" => 85737,
          "lowPrice" => nil,
          "midPrice" => nil,
         "highPrice" => nil,
       "marketPrice" => nil,
    "directLowPrice" => nil,
       "subTypeName" => "Unlimited Holofoil"
},

Instance Method Summary collapse

Methods inherited from ResponseStruct

#each, #keys, #method_missing, #respond_to_missing?, #to_h, #to_s, #try

Constructor Details

#initialize(hash = nil) ⇒ ProductPrice

Returns a new instance of ProductPrice.



71
72
73
# File 'lib/tcg-player-sdk/product_price_list.rb', line 71

def initialize(hash = nil)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TCGPlayerSDK::ResponseStruct

Instance Method Details

#has_valid_prices?Boolean

Returns false if there are no non-nil prices

Returns:

  • (Boolean)

    Returns false if there are no non-nil prices



77
78
79
# File 'lib/tcg-player-sdk/product_price_list.rb', line 77

def has_valid_prices?
  return !(lowPrice.nil? && midPrice.nil? && highPrice.nil? && directLowPrice.nil? && marketPrice.nil?)
end

#pointsObject

Returns “price points” described by this price object. i.e. “midPrice” and “highPrice”. These are also accessors, so access away

price.points.each{|pp| puts price.send(pp)}


87
88
89
# File 'lib/tcg-player-sdk/product_price_list.rb', line 87

def points
  self.keys.select{|k| k.to_s =~ /Price/i}
end