lib/sportradar/api/soccer/match.rb in sportradar-api-0.16.1 vs lib/sportradar/api/soccer/match.rb in sportradar-api-0.17.0.pre

- old
+ new

@@ -8,22 +8,22 @@ attr_reader :home, :away, :tournament_id attr_reader :period, :score, :broadcast, :coverage # these are for consistency with other sports attr_reader :match_time, :stoppage_time attr_reader :team_stats, :player_stats - def initialize(data = {}, league_group: nil, **opts) + def initialize(data = {}, season: nil, **opts) @response = data - @id = data['id'] + @id = data['id'] || data.dig("sport_event", 'id') @api = opts[:api] + @season = season @updates = {} @changes = {} - @league_group = league_group || data['league_group'] || @api&.league_group @timeline_hash = {} @lineups_hash = {} - get_tournament_id(data, **opts) + # get_tournament_id(data, **opts) @scoring_raw = Scoring.new(data, game: self) @home = Team.new(data['home'].to_h, api: api, match: self) @away = Team.new(data['away'].to_h, api: api, match: self) @teams_hash = { away: @away, home: @home } @team_ids = { away: @away.id, home: @home.id } @@ -32,12 +32,10 @@ update(data, **opts) end def update(data, **opts) - @league_group = opts[:league_group] || data['league_group'] || @league_group - get_tournament_id(data, **opts) if data["sport_event"] update(data["sport_event"]) end if data["sport_event_status"] update(data["sport_event_status"]) @@ -50,11 +48,11 @@ @probabilities = data['probabilities'] # tidy this up later end if data['lineups'] create_data(@lineups_hash, data['lineups'], klass: Lineup, identifier: 'team', api: api) end - if (stats = data.dig('statistics', 'teams')) + if (stats = data.dig('statistics', 'totals', 'competitors')) update_teams(stats) end @scheduled = Time.parse(data['scheduled']) if data['scheduled'] @start_time_tbd = data['start_time_tbd'] if data.key?('start_time_tbd') @@ -250,10 +248,10 @@ def api @api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group) end def path_base - "matches/#{ id }" + "sport_events/#{ id }" end def path_summary "#{ path_base }/summary" end