sportradar-api 0.19.3 → 0.19.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ab01ced5f53daf0d2c078827a4810a4a844713f48efd7cb0f4b7301a760e7a5
4
- data.tar.gz: 60ee22bcf8fdc96b1ed1083c9cddf1eb904a4e8a985840c36fd105083cc9b7d7
3
+ metadata.gz: 63ccb22baef51d07aa56fe5a22d11d07cd389038882795f073fa435993d65ca8
4
+ data.tar.gz: f147f71634d36ae1d3ed9b012bec020a8189d16a1f8a42b191fe61e29e58d9f4
5
5
  SHA512:
6
- metadata.gz: f35b85cc02002e09dbb367b5e5bf39ec272a8633c4d2736dbef5f2657ffcd91a3d01d68bce59f052302c8d346a8e75076960db3dd88ae6ba1c64758378fcb69d
7
- data.tar.gz: 9898e8d1934b86f03e416c90c84f122c3017a1e6e23bc1a87f3c46375774ad4b7eb8dd86a6910be40e6a328385da3a091dac48221ca76b8bb79475892fde3948
6
+ metadata.gz: 302321bce6eb8fbe408247b8ad4a24492843f0fa1572883977c61636cfb5f6b19e573ffc67f654b01d54e136bb1284502156ea61068b1cdbeda5dc6379ee80f8
7
+ data.tar.gz: 4a6a2b5867e7e5e68e396d3632d1e00e71f641d785d8d2b1a2375de63c49face44d255ed60f0313c3018bf44e4fe34962915286093ecebe1c59d75b47bbdb700
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.6)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -14,10 +14,6 @@ module Sportradar
14
14
  Player
15
15
  end
16
16
 
17
- def path_season_stats(year = season_year, season = nfl_season)
18
- "seasontd/#{year}/#{nfl_season}/teams/#{ id }/statistics"
19
- end
20
-
21
17
  def api
22
18
  @api || Sportradar::Api::Football::Nfl::Api.new
23
19
  end
@@ -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
@@ -15,7 +15,7 @@ module Sportradar
15
15
  return player.send(stat)
16
16
  end
17
17
  end
18
- 0
18
+ nil
19
19
  end
20
20
 
21
21
  end
@@ -139,13 +139,13 @@ module Sportradar
139
139
  "teams/#{ id }"
140
140
  end
141
141
  def path_base_stats(year = season_year, season = default_season)
142
- "seasontd/#{year}/#{season}/teams/#{id}"
142
+ "seasons/#{year}/#{season}/teams/#{id}"
143
143
  end
144
144
  def path_roster
145
145
  "#{ path_base }/profile" # nfl is profile, ncaa is roster
146
146
  end
147
- def path_season_stats
148
- "#{ path_base_stats }/statistics"
147
+ def path_season_stats(year = season_year, season = default_season)
148
+ "#{ path_base_stats(year, season) }/statistics"
149
149
  end
150
150
 
151
151
 
@@ -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.6"
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.6
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-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler