sportradar-api 0.19.3 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ab01ced5f53daf0d2c078827a4810a4a844713f48efd7cb0f4b7301a760e7a5
4
- data.tar.gz: 60ee22bcf8fdc96b1ed1083c9cddf1eb904a4e8a985840c36fd105083cc9b7d7
3
+ metadata.gz: cd632c76f639fcdd6627dbc2323fc85ee6b8fe20d3eb37b3f4ee1855590e2d54
4
+ data.tar.gz: acaf3b496f64a18051969bd18a84de9dc8c717535c371cbd297329b5be804b6f
5
5
  SHA512:
6
- metadata.gz: f35b85cc02002e09dbb367b5e5bf39ec272a8633c4d2736dbef5f2657ffcd91a3d01d68bce59f052302c8d346a8e75076960db3dd88ae6ba1c64758378fcb69d
7
- data.tar.gz: 9898e8d1934b86f03e416c90c84f122c3017a1e6e23bc1a87f3c46375774ad4b7eb8dd86a6910be40e6a328385da3a091dac48221ca76b8bb79475892fde3948
6
+ metadata.gz: a3d9a2d3b120f76804a9287ff0f5d734dccc674451bcaf48b71542849c62ac9e97480c43de38d886a564a3e30ee86075ce57152f68cf70524b508d6856dc7f9b
7
+ data.tar.gz: ce834768c971a60c379029efa678a687c3465e0a4d2d75af51158068cc10e9436eca4014ddd2757cb018c0c3a611a10b107ada473b351391fde73b2512da1cea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.19.3)
4
+ sportradar-api (0.19.4)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -2,7 +2,7 @@ module Sportradar
2
2
  module Api
3
3
  module Football
4
4
  class Player < Data
5
- attr_accessor :response, :id, :preferred_name, :number, :name_full, :name_first, :name_last, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :depth, :api, :stats
5
+ attr_accessor :response, :id, :preferred_name, :number, :name_full, :name_first, :name_last, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :depth, :api, :stats, :team
6
6
 
7
7
  def initialize(data, **opts)
8
8
  @response = data
@@ -124,4 +124,4 @@ t = ncaafb.teams.sample
124
124
  data = t.get_season_stats(2016);
125
125
  t.get_roster;
126
126
  t.players.sample
127
- t.players.sample.totals
127
+ t.players.sample.totals
@@ -52,10 +52,27 @@ module Sportradar
52
52
  end
53
53
  end
54
54
 
55
+ def hierarchy
56
+ self.get_seasons
57
+ season = self.latest_season
58
+ season.get_competitors
59
+ season.competitors
60
+ end
61
+
62
+ def teams
63
+ season = self.latest_season
64
+ season.get_competitors if season.competitors.empty?
65
+ season.competitors
66
+ end
67
+
55
68
  def current_season
56
69
  seasons.detect(&:current?)
57
70
  end
58
71
 
72
+ def latest_season
73
+ seasons.max_by(&:end_date)
74
+ end
75
+
59
76
  def standings(type = nil)
60
77
  if type
61
78
  @standings_hash[type]
@@ -3,7 +3,7 @@ module Sportradar
3
3
  module Soccer
4
4
  class Player < Data
5
5
 
6
- attr_reader :id, :league_group, :name, :type, :nationality, :country_code, :height, :weight, :jersey_number, :preferred_foot, :stats, :game_stats, :date_of_birth, :matches_played, :starter
6
+ attr_reader :id, :league_group, :name, :type, :nationality, :country_code, :height, :weight, :jersey_number, :preferred_foot, :stats, :game_stats, :date_of_birth, :matches_played, :starter, :team
7
7
  alias :position :type
8
8
 
9
9
  def initialize(data = {}, league_group: nil, **opts)
@@ -116,6 +116,10 @@ module Sportradar
116
116
  @name.split()[0].delete(',')
117
117
  end
118
118
 
119
+ def injured?
120
+ false
121
+ end
122
+
119
123
  def api
120
124
  @api || Sportradar::Api::Soccer::Api.new(league_group: @league_group)
121
125
  end
@@ -10,6 +10,7 @@ module Sportradar
10
10
  @api = opts[:api]
11
11
  @competition = competition
12
12
  @matches_hash = {}
13
+ @competitors_hash = {}
13
14
 
14
15
  update(data, **opts)
15
16
  end
@@ -31,6 +32,7 @@ module Sportradar
31
32
  @min_coverage_level = data['min_coverage_level'] || @min_coverage_level
32
33
 
33
34
  parse_schedule(data)
35
+ parse_competitors(data)
34
36
  end
35
37
 
36
38
  # def get_tournament_id(data, **opts)
@@ -51,12 +53,22 @@ module Sportradar
51
53
  @matches_hash.values
52
54
  end
53
55
 
56
+ def competitors
57
+ @competitors_hash.values
58
+ end
59
+
54
60
  def parse_schedule(data)
55
61
  if data['schedules']
56
62
  create_data(@matches_hash, data['schedules'], klass: Match, api: api, competition: @competition, season: self)
57
63
  end
58
64
  end
59
65
 
66
+ def parse_competitors(data)
67
+ if data['season_competitors']
68
+ create_data(@competitors_hash, data['season_competitors'], klass: Team, api: api, competition: @competition, season: self)
69
+ end
70
+ end
71
+
60
72
  def api
61
73
  @api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group)
62
74
  end
@@ -78,6 +90,20 @@ module Sportradar
78
90
  # TODO parse the rest of the data. keys: ["tournament", "sport_events"]
79
91
  data
80
92
  end
93
+
94
+ def path_competitors
95
+ "#{ path_base }/competitors"
96
+ end
97
+ def get_competitors
98
+ data = api.get_data(path_competitors).to_h
99
+ ingest_competitors(data)
100
+ end
101
+ def ingest_competitors(data)
102
+ @competitors_retrieved = true
103
+ update(data)
104
+ # TODO parse the rest of the data. keys: ["tournament", "sport_events"]
105
+ data
106
+ end
81
107
  def queue_schedule
82
108
  url, headers, options, timeout = api.get_request_info(path_schedule)
83
109
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_schedule)}
@@ -15,6 +15,7 @@ module Sportradar
15
15
  @response = data
16
16
  @id = data['id']
17
17
  @api = opts[:api]
18
+ @season = opts[:season]
18
19
  @league_group = league_group || data['league_group'] || @api&.league_group
19
20
 
20
21
  @players_hash = {}
@@ -27,7 +28,7 @@ module Sportradar
27
28
  def update(data, **opts)
28
29
  @id = data['id'] if data['id']
29
30
  @league_group = opts[:league_group] || data['league_group'] || @league_group
30
- get_tournament_id(data, **opts)
31
+ # get_tournament_id(data, **opts)
31
32
 
32
33
  if data["team"]
33
34
  update(data["team"])
@@ -92,7 +93,7 @@ module Sportradar
92
93
  end
93
94
 
94
95
  def path_base
95
- "teams/#{ id }"
96
+ "competitors/#{ id }"
96
97
  end
97
98
 
98
99
  def path_roster
@@ -143,11 +144,16 @@ module Sportradar
143
144
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_schedule)}
144
145
  end
145
146
 
146
- def path_statistics(tourn_id = self.tournament_id)
147
- "tournaments/#{ tourn_id }/#{ path_base }/statistics"
147
+ def season_id
148
+ @season&.id
148
149
  end
149
- def get_statistics(tourn_id = self.tournament_id)
150
- data = api.get_data(path_statistics(tourn_id)).to_h
150
+
151
+ def path_statistics(season_id = self.season_id)
152
+ "seasons/#{ season_id }/#{ path_base }/statistics"
153
+ end
154
+ def get_statistics(season_id = self.season_id)
155
+ return unless season_id
156
+ data = api.get_data(path_statistics(season_id)).to_h
151
157
  ingest_statistics(data)
152
158
  end
153
159
  def get_season_stats(*args)
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.19.3"
3
+ VERSION = "0.19.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.3
4
+ version: 0.19.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler