Sha256: 39df5e2e3a0f3aba8c170d0d8aabeefe4893c859c64c6a9f19b871a3205f25b2

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

module Pokemon
  class Tcgplayer
    attr_accessor :url, :prices, :updated_at

    def self.from_json(json)
      tcgplayer = Tcgplayer.new
      tcgplayer.url = json['url']
      tcgplayer.updated_at = json['updatedAt']
      tcgplayer.prices = TcgPlayerPrices.from_json(json['prices']) if !json['prices'].nil?

      tcgplayer
    end
  end

  class TcgPlayerPrices
    attr_accessor :normal, :holofoil, :reverse_holofoil, :first_edition_holofoil, :first_edition_normal
    
    def self.from_json(json)
      price = TcgPlayerPrices.new
      price.normal = TcgPlayerPriceValues.from_json(json['normal']) if json.key? 'normal'
      price.holofoil = TcgPlayerPriceValues.from_json(json['holofoil']) if !json['holofoil'].nil?
      price.reverse_holofoil = TcgPlayerPriceValues.from_json(json['reverseHolofoil']) if !json['reverseHolofoil'].nil?
      price.first_edition_holofoil = TcgPlayerPriceValues.from_json(json['1stEditionHolofoil']) if !json['1stEditionHolofoil'].nil?
      price.first_edition_normal = TcgPlayerPriceValues.from_json(json['1stEditionNormal']) if !json['1stEditionNormal'].nil?

      price
    end
  end

  class TcgPlayerPriceValues
    attr_accessor :low, :mid, :high, :market, :direct

    def self.from_json(json)
      values = TcgPlayerPriceValues.new
      values.low = json['low']
      values.mid = json['mid']
      values.high = json['high']
      values.market = json['market']
      values.direct = json['direct']

      values
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pokemon_tcg_sdk-4.4.0 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.3.0 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.2.1 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.2.0 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.1.1 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.1.0 lib/pokemon_tcg_sdk/tcgplayer.rb
pokemon_tcg_sdk-4.0.0 lib/pokemon_tcg_sdk/tcgplayer.rb