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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/football/nfl/team.rb +0 -4
- data/lib/sportradar/api/football/player.rb +2 -2
- data/lib/sportradar/api/football/stats_shim.rb +1 -1
- data/lib/sportradar/api/football/team.rb +3 -3
- data/lib/sportradar/api/soccer/competition.rb +17 -0
- data/lib/sportradar/api/soccer/player.rb +5 -1
- data/lib/sportradar/api/soccer/season.rb +26 -0
- data/lib/sportradar/api/soccer/team.rb +12 -6
- data/lib/sportradar/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63ccb22baef51d07aa56fe5a22d11d07cd389038882795f073fa435993d65ca8
|
4
|
+
data.tar.gz: f147f71634d36ae1d3ed9b012bec020a8189d16a1f8a42b191fe61e29e58d9f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302321bce6eb8fbe408247b8ad4a24492843f0fa1572883977c61636cfb5f6b19e573ffc67f654b01d54e136bb1284502156ea61068b1cdbeda5dc6379ee80f8
|
7
|
+
data.tar.gz: 4a6a2b5867e7e5e68e396d3632d1e00e71f641d785d8d2b1a2375de63c49face44d255ed60f0313c3018bf44e4fe34962915286093ecebe1c59d75b47bbdb700
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -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
|
-
"
|
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
|
-
"
|
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
|
147
|
-
|
147
|
+
def season_id
|
148
|
+
@season&.id
|
148
149
|
end
|
149
|
-
|
150
|
-
|
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)
|
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.
|
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-
|
11
|
+
date: 2022-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|