Sha256: cfbb6dc7880cde3effd20e1df833db023836250cd6ac3ebf66900c417290732c

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

module Sportradar
  module Api
    module Odds
      class SportEvent < Data
        attr_accessor :response, :api, :id


        def initialize(data, **opts)
          @response = data
          @api      = opts[:api]
          @id       = data['id'] || data.dig('sport_event', 'id')

          @player_props_hash     = {}
          @player_markets_hash   = {}

          update(data)
          # update(data['sport_event'])       if data['sport_event']
          # update(data['players_props'])     if data['players_props']
          # update(data['players_markets'])   if data['players_markets']
        end

        def player_props
          @player_props_hash.values
        end

        def player_markets
          @player_markets_hash.values
        end

        def update(data, **opts)
          create_data(@player_props_hash,   data['players_props'],    klass: PlayerProp,  api: api)  if data['players_props']
          create_data(@player_markets_hash, data['players_markets'],  klass: Market,      api: api)  if data['players_markets']
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sportradar-api-0.20.2 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.20.1 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.20.0 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.20.0.pre2 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.20.0.pre lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.6 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.5 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.4 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.3 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.2 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.1 lib/sportradar/api/odds/sport_event.rb
sportradar-api-0.19.0 lib/sportradar/api/odds/sport_event.rb