sportradar-api 0.18.1 → 0.20.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/football/game.rb +5 -1
- data/lib/sportradar/api/football/game_stats.rb +4 -0
- data/lib/sportradar/api/football/nfl/api.rb +5 -5
- data/lib/sportradar/api/football/nfl/team.rb +0 -4
- data/lib/sportradar/api/football/nfl.rb +14 -4
- data/lib/sportradar/api/football/player.rb +2 -2
- data/lib/sportradar/api/football/stat_pack.rb +4 -0
- data/lib/sportradar/api/football/stats_shim.rb +24 -0
- data/lib/sportradar/api/football/team.rb +3 -3
- data/lib/sportradar/api/football.rb +1 -0
- data/lib/sportradar/api/mma/api.rb +59 -0
- data/lib/sportradar/api/mma/competition.rb +62 -0
- data/lib/sportradar/api/mma/event.rb +1 -1
- data/lib/sportradar/api/mma/fight.rb +84 -45
- data/lib/sportradar/api/mma/fighter.rb +18 -18
- data/lib/sportradar/api/mma/judge.rb +2 -2
- data/lib/sportradar/api/mma/league.rb +1 -1
- data/lib/sportradar/api/mma/referee.rb +2 -2
- data/lib/sportradar/api/mma/result.rb +2 -2
- data/lib/sportradar/api/mma/roster.rb +1 -1
- data/lib/sportradar/api/mma/schedule.rb +1 -1
- data/lib/sportradar/api/mma/score.rb +2 -2
- data/lib/sportradar/api/mma/season.rb +102 -0
- data/lib/sportradar/api/mma/venue.rb +1 -1
- data/lib/sportradar/api/mma.rb +52 -167
- data/lib/sportradar/api/odds/README.md +1 -1
- data/lib/sportradar/api/odds/api.rb +1 -1
- data/lib/sportradar/api/odds/base.rb +18 -2
- data/lib/sportradar/api/odds/competition.rb +12 -4
- data/lib/sportradar/api/odds/sport_event.rb +0 -2
- data/lib/sportradar/api/request.rb +3 -2
- 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
- data/lib/sportradar/api.rb +2 -13
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 842d41517346b22c3cb540f9132a514dff1baa8c256d04f013df6e560faf06f6
|
|
4
|
+
data.tar.gz: b815a45030f676ba70be4fce250b5e0a08aaa37c2e3f44b3324d9faeaef709df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5e73668cb8586e14ef06ee7b4844f1e134dead13d4258f76c3ed911c8f562ca6b05c809a91633fde56b85a4b4d3d1752ed13e354ec8564014d13b12d9c0a585
|
|
7
|
+
data.tar.gz: 0d56e21705c97697741d8ca42d1c58b0310b720b44710d11bc5f3639db638c018e790471c52cbdeab77601f59b27a36aee93bdd5fc2becd4663ed3234c68a146
|
data/Gemfile.lock
CHANGED
|
@@ -20,7 +20,7 @@ module Sportradar
|
|
|
20
20
|
|
|
21
21
|
@teams_hash = {}
|
|
22
22
|
@team_stats = {}
|
|
23
|
-
@player_stats =
|
|
23
|
+
@player_stats = StatsShim.new(self)
|
|
24
24
|
|
|
25
25
|
@quarters_hash = {}
|
|
26
26
|
@drives_hash = {}
|
|
@@ -394,6 +394,10 @@ module Sportradar
|
|
|
394
394
|
ingest_statistics(data)
|
|
395
395
|
end
|
|
396
396
|
|
|
397
|
+
def get_summary
|
|
398
|
+
get_statistics
|
|
399
|
+
end
|
|
400
|
+
|
|
397
401
|
def queue_statistics
|
|
398
402
|
url, headers, options, timeout = api.get_request_info(path_statistics)
|
|
399
403
|
{url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_statistics)}
|
|
@@ -29,6 +29,10 @@ module Sportradar
|
|
|
29
29
|
@return_yards = data.dig('summary', "return_yards")
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def dig(*args)
|
|
33
|
+
args.inject(self) { |memo, arg| memo.public_send(arg) }
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
def turnovers
|
|
33
37
|
@turnovers || passing.interceptions + fumbles&.lost_fumbles.to_i
|
|
34
38
|
end
|
|
@@ -22,9 +22,9 @@ module Sportradar
|
|
|
22
22
|
end
|
|
23
23
|
def default_access_level
|
|
24
24
|
if (ENV['SPORTRADAR_ENV'] || ENV['SPORTRADAR_ENV_NFL'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
25
|
-
'
|
|
25
|
+
'production'
|
|
26
26
|
else
|
|
27
|
-
'
|
|
27
|
+
'trial'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -35,11 +35,11 @@ module Sportradar
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def request_url(path)
|
|
38
|
-
"/nfl
|
|
38
|
+
"/nfl/official/#{access_level}/v#{version}/en/#{path}"
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def api_key
|
|
42
|
-
if !['
|
|
42
|
+
if !['trial', 'sim'].include?(access_level) || (access_level == 'sim' && default_access_level == 'production')
|
|
43
43
|
::Sportradar::Api.api_key_params('nfl', 'production')
|
|
44
44
|
else
|
|
45
45
|
::Sportradar::Api.api_key_params('nfl')
|
|
@@ -51,7 +51,7 @@ module Sportradar
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def allowed_access_levels
|
|
54
|
-
%w[
|
|
54
|
+
%w[production trial sim]
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def allowed_seasons
|
|
@@ -159,13 +159,13 @@ module Sportradar
|
|
|
159
159
|
"games/#{season_year}/#{nfl_season}/#{nfl_season_week}/schedule"
|
|
160
160
|
end
|
|
161
161
|
def path_weekly_depth_charts(nfl_season_week)
|
|
162
|
-
"
|
|
162
|
+
"seasons/#{season_year}/#{nfl_season}/#{nfl_season_week}/depth_charts"
|
|
163
163
|
end
|
|
164
164
|
def path_weekly_depth_injuries(nfl_season_week)
|
|
165
|
-
"
|
|
165
|
+
"seasons/#{season_year}/#{nfl_season}/#{nfl_season_week}/injuries"
|
|
166
166
|
end
|
|
167
167
|
def path_standings
|
|
168
|
-
"
|
|
168
|
+
"seasons/#{season_year}/standings"
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
# data retrieval
|
|
@@ -320,4 +320,14 @@ File.binwrite('nfl.bin', Marshal.dump(nfl))
|
|
|
320
320
|
nfl = Sportradar::Api::Football::Nfl.new
|
|
321
321
|
nfl.season = 2016
|
|
322
322
|
res = nfl.get_weekly_depth_charts
|
|
323
|
-
dc = nfl.instance_variable_get(:@depth_charts_hash)
|
|
323
|
+
dc = nfl.instance_variable_get(:@depth_charts_hash)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
nfl = Sportradar::Api::Football::Nfl.new
|
|
327
|
+
nfl.season = 2021
|
|
328
|
+
nfl.get_schedule
|
|
329
|
+
g = nfl.games.sample
|
|
330
|
+
data = g.get_statistics
|
|
331
|
+
g.team_stats
|
|
332
|
+
g.team_stats.values.first.dig('rushing', 'yards')
|
|
333
|
+
|
|
@@ -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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Football
|
|
4
|
+
class StatsShim
|
|
5
|
+
attr_reader :game
|
|
6
|
+
|
|
7
|
+
def initialize(game)
|
|
8
|
+
@game = game
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def dig(player_id, category, stat)
|
|
12
|
+
game.team_stats.each_value do |stats|
|
|
13
|
+
player = stats.public_send(category).for_player(player_id)
|
|
14
|
+
if player
|
|
15
|
+
return player.send(stat)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
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
|
-
"
|
|
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
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Mma
|
|
4
|
+
class Api < Request
|
|
5
|
+
attr_accessor :league_group, :access_level, :language_code, :error
|
|
6
|
+
|
|
7
|
+
def initialize(access_level: default_access_level, language_code: 'en', **args)
|
|
8
|
+
@league_group = league_group
|
|
9
|
+
@language_code = language_code
|
|
10
|
+
@access_level = access_level
|
|
11
|
+
# raise Sportradar::Api::Error::InvalidLeague unless allowed_leagues.include? @league_group
|
|
12
|
+
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? @access_level
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def default_year
|
|
16
|
+
Date.today.year
|
|
17
|
+
end
|
|
18
|
+
# def default_season
|
|
19
|
+
# 'reg'
|
|
20
|
+
# end
|
|
21
|
+
def default_access_level
|
|
22
|
+
if (ENV['SPORTRADAR_ENV_MMA'] || ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
23
|
+
'production'
|
|
24
|
+
else
|
|
25
|
+
'trial'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def content_format
|
|
30
|
+
'json'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def request_url(path)
|
|
36
|
+
"/mma/#{access_level}/v#{version}/#{language_code}/#{path}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def api_key
|
|
40
|
+
if !['trial', 'sim'].include?(access_level) || (access_level == 'sim' && default_access_level == 'production')
|
|
41
|
+
Sportradar::Api.api_key_params("mma", 'production')
|
|
42
|
+
else
|
|
43
|
+
Sportradar::Api.api_key_params("mma")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def version
|
|
48
|
+
Sportradar::Api.version('mma')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def allowed_access_levels
|
|
52
|
+
%w[production trial]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Mma
|
|
4
|
+
class Competition < Data
|
|
5
|
+
attr_reader :id, :name, :parent_id, :category
|
|
6
|
+
|
|
7
|
+
def initialize(data = {}, league_group: nil, **opts)
|
|
8
|
+
@response = data
|
|
9
|
+
@id = data["id"]
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
|
|
12
|
+
@name = data['name'] if data['name']
|
|
13
|
+
@parent_id = data['parent_id'] if data['parent_id']
|
|
14
|
+
@category = data['category'] if data['category']
|
|
15
|
+
|
|
16
|
+
@seasons_hash = {}
|
|
17
|
+
|
|
18
|
+
update(data, **opts)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def update(data, **opts)
|
|
22
|
+
parse_season(data)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def parse_season(data)
|
|
26
|
+
if data['seasons']
|
|
27
|
+
create_data(@seasons_hash, data['seasons'], klass: Season, api: api, competition: self)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def seasons
|
|
32
|
+
@seasons_hash.values
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def api
|
|
36
|
+
@api ||= Sportradar::Api::Mma::Api.new
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# url path helpers
|
|
40
|
+
def path_base
|
|
41
|
+
"competitions/#{ id }"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def path_seasons
|
|
45
|
+
"#{ path_base }/seasons"
|
|
46
|
+
end
|
|
47
|
+
def get_seasons
|
|
48
|
+
data = api.get_data(path_seasons).to_h
|
|
49
|
+
ingest_seasons(data)
|
|
50
|
+
end
|
|
51
|
+
def ingest_seasons(data)
|
|
52
|
+
update(data)
|
|
53
|
+
# TODO parse the rest of the data. keys: ["tournament", "seasons"]
|
|
54
|
+
data
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
__END__
|
|
@@ -1,80 +1,119 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Fight < Data
|
|
5
|
-
attr_accessor :response, :id, :
|
|
6
|
-
@all_hash = {}
|
|
7
|
-
def self.new(data, **opts)
|
|
8
|
-
existing = @all_hash[data['id']]
|
|
9
|
-
if existing
|
|
10
|
-
existing.update(data)
|
|
11
|
-
# existing.add_event(opts[:event])
|
|
12
|
-
# existing
|
|
13
|
-
else
|
|
14
|
-
@all_hash[data['id']] = super
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
def self.all
|
|
18
|
-
@all_hash.values
|
|
19
|
-
end
|
|
5
|
+
attr_accessor :response, :id, :season, :start_time, :start_time_confirmed, :sport_event_context, :coverage, :venue, :status, :match_status, :winner_id, :final_round, :final_round_length, :end_method, :winner, :scheduled_length, :weight_class, :title_fight, :statistics
|
|
20
6
|
|
|
21
7
|
def initialize(data, **opts)
|
|
22
8
|
@response = data
|
|
23
9
|
@api = opts[:api]
|
|
24
|
-
@
|
|
10
|
+
@season = opts[:season]
|
|
25
11
|
@fighters_hash = {}
|
|
26
12
|
|
|
27
13
|
@id = data['id']
|
|
14
|
+
@statistics = {}
|
|
28
15
|
|
|
29
16
|
update(data)
|
|
30
17
|
end
|
|
31
18
|
|
|
32
19
|
def fighters
|
|
33
|
-
@fighters_hash ||= update_fighters(response)
|
|
34
20
|
@fighters_hash.values
|
|
35
21
|
end
|
|
36
22
|
|
|
37
|
-
def score
|
|
38
|
-
result.scores
|
|
39
|
-
end
|
|
40
|
-
|
|
41
23
|
def update(data, **opts)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
if data["summaries"]
|
|
25
|
+
update(data["summaries"][0])
|
|
26
|
+
end
|
|
27
|
+
if data["sport_event"]
|
|
28
|
+
update(data["sport_event"])
|
|
29
|
+
end
|
|
30
|
+
if data["sport_event_status"]
|
|
31
|
+
update(data["sport_event_status"])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
@id = data['id'] if data['id'] && !@id
|
|
35
|
+
@start_time = Time.parse(data['start_time']) if data['start_time']
|
|
36
|
+
@start_time_confirmed = data['start_time_confirmed'] if data['start_time_confirmed']
|
|
37
|
+
@sport_event_context = data['sport_event_context'] if data['sport_event_context']
|
|
38
|
+
@coverage = data['coverage'] if data['coverage']
|
|
39
|
+
@venue = data['venue'] if data['venue']
|
|
40
|
+
|
|
41
|
+
@status = data['status'] if data['status']
|
|
42
|
+
@match_status = data['match_status'] if data['match_status']
|
|
43
|
+
@winner_id = data['winner_id'] if data['winner_id']
|
|
44
|
+
@final_round = data['final_round'] if data['final_round']
|
|
45
|
+
@final_round_length = data['final_round_length'] if data['final_round_length']
|
|
46
|
+
@end_method = data['method'] if data['method']
|
|
47
|
+
@winner = data['winner'] if data['winner']
|
|
48
|
+
@scheduled_length = data['scheduled_length'] if data['scheduled_length']
|
|
49
|
+
@weight_class = data['weight_class'] if data['weight_class']
|
|
50
|
+
@title_fight = data['title_fight'] if data['title_fight']
|
|
45
51
|
|
|
46
|
-
@referee = Referee.new(data['referee'], fight: self, api: api) if data['referee']
|
|
47
|
-
@result = Result.new(data['result'], fight: self, api: api) if data['result']
|
|
48
52
|
|
|
49
|
-
update_fighters(data) if data['
|
|
53
|
+
update_fighters(data) if data['competitors']
|
|
54
|
+
update_statistics(data['statistics']) if data["statistics"]
|
|
50
55
|
|
|
51
56
|
self
|
|
52
57
|
end
|
|
53
58
|
|
|
59
|
+
def season_id
|
|
60
|
+
@season&.id || @sport_event_context&.dig('season', 'id')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def starts_at
|
|
64
|
+
@start_time
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def coverage_level
|
|
68
|
+
'live' if @coverage&.dig('live')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def title
|
|
72
|
+
fighters.map(&:display_name).join(' vs ')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def scheduled
|
|
76
|
+
@start_time
|
|
77
|
+
end
|
|
78
|
+
|
|
54
79
|
def update_fighters(data)
|
|
55
|
-
|
|
80
|
+
if data['competitors']
|
|
81
|
+
create_data(@fighters_hash, data['competitors'], klass: Fighter, api: api, fight: self)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def update_statistics(data)
|
|
86
|
+
@statistics['totals'] = structure_stats(data["totals"]) if data["totals"]
|
|
87
|
+
if data['periods']
|
|
88
|
+
data['periods'].each do |round|
|
|
89
|
+
@statistics[round['number']] = structure_stats(round)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
56
92
|
end
|
|
93
|
+
|
|
94
|
+
def structure_stats(data)
|
|
95
|
+
data['competitors'].map { |comp_data| [comp_data['id'], comp_data.merge(comp_data.delete('statistics'))] }.to_h
|
|
96
|
+
end
|
|
97
|
+
|
|
57
98
|
def api
|
|
58
|
-
@api ||= Sportradar::Api::Mma.new
|
|
99
|
+
@api ||= Sportradar::Api::Mma::Api.new
|
|
59
100
|
end
|
|
60
101
|
|
|
61
102
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# def path_box
|
|
66
|
-
# "#{ path_base }/boxscore"
|
|
67
|
-
# end
|
|
68
|
-
# def path_pbp
|
|
69
|
-
# "#{ path_base }/pbp"
|
|
70
|
-
# end
|
|
103
|
+
def path_base
|
|
104
|
+
"sport_events/#{ id }"
|
|
105
|
+
end
|
|
71
106
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
107
|
+
def path_summary
|
|
108
|
+
"#{ path_base }/summary"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def get_summary
|
|
112
|
+
data = api.get_data(path_summary)
|
|
113
|
+
update(data)
|
|
114
|
+
|
|
115
|
+
data
|
|
116
|
+
end
|
|
78
117
|
|
|
79
118
|
# def get_pbp
|
|
80
119
|
# data = api.get_data(path_pbp)['game']
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Fighter < Data
|
|
5
|
-
attr_accessor :response, :id, :height, :weight, :reach, :stance, :first_name, :nick_name, :last_name, :record, :born, :out_of
|
|
6
|
-
@all_hash = {}
|
|
7
|
-
def self.new(data, **opts)
|
|
8
|
-
existing = @all_hash[data['id']]
|
|
9
|
-
if existing
|
|
10
|
-
existing.update(data, **opts)
|
|
11
|
-
existing.add_fight(opts[:fight])
|
|
12
|
-
existing
|
|
13
|
-
else
|
|
14
|
-
@all_hash[data['id']] = super
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
def self.all
|
|
18
|
-
@all_hash.values
|
|
19
|
-
end
|
|
5
|
+
attr_accessor :response, :id, :height, :weight, :reach, :stance, :name, :first_name, :nick_name, :last_name, :record, :born, :out_of, :qualifier, :abbreviation
|
|
20
6
|
|
|
21
7
|
def initialize(data, **opts)
|
|
22
8
|
@response = data
|
|
@@ -36,8 +22,21 @@ module Sportradar
|
|
|
36
22
|
@fights_hash[fight.id] = fight if fight
|
|
37
23
|
end
|
|
38
24
|
|
|
25
|
+
def display_name
|
|
26
|
+
if first_name && last_name
|
|
27
|
+
"#{first_name} #{last_name}"
|
|
28
|
+
else
|
|
29
|
+
@name || @short_name
|
|
30
|
+
end
|
|
31
|
+
end
|
|
39
32
|
|
|
40
33
|
def update(data, **opts)
|
|
34
|
+
@name = data['name'] if data['name']
|
|
35
|
+
@abbreviation = data['abbreviation'] if data['abbreviation']
|
|
36
|
+
@short_name = data['short_name'] if data['short_name']
|
|
37
|
+
|
|
38
|
+
@qualifier = data['qualifier'] if data['qualifier'] # "72",
|
|
39
|
+
@abbreviation = data['abbreviation'] if data['abbreviation'] # "72",
|
|
41
40
|
@height = data['height'] if data['height'] # "72",
|
|
42
41
|
@weight = data['weight'] if data['weight'] # "170",
|
|
43
42
|
@reach = data['reach'] if data['reach'] # "",
|
|
@@ -45,6 +44,7 @@ module Sportradar
|
|
|
45
44
|
@first_name = data['first_name'] if data['first_name'] # "Sai",
|
|
46
45
|
@nick_name = data['nick_name'] if data['nick_name'] # "The Boss",
|
|
47
46
|
@last_name = data['last_name'] if data['last_name'] # "Wang",
|
|
47
|
+
@name = data['name'] if data['name'] # "Wang, Sai",
|
|
48
48
|
@record = data['record'] if data['record'] # {"wins"=>"6", "losses"=>"4", "draws"=>"1", "no_contests"=>"0"},
|
|
49
49
|
@born = data['born'] if data['born'] # {"date"=>"1988-01-16", "country_code"=>"UNK", "country"=>"Unknown", "state"=>"", "city"=>""},
|
|
50
50
|
@out_of = data['out_of'] if data['out_of'] # {"country_code"=>"UNK", "country"=>"Unknown", "state"=>"", "city"=>""}}
|
|
@@ -65,7 +65,7 @@ module Sportradar
|
|
|
65
65
|
self
|
|
66
66
|
end
|
|
67
67
|
def api
|
|
68
|
-
@api ||= Sportradar::Api::Mma.new
|
|
68
|
+
@api ||= Sportradar::Api::Mma::Api.new
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
|
|
@@ -92,4 +92,4 @@ e = sc.events.sample;
|
|
|
92
92
|
e.fights.first.fighters.first.born
|
|
93
93
|
|
|
94
94
|
fighter_hash = {'id' => "259117dc-c443-4086-8c1d-abd082e3d4b9" } # => Conor McGregor
|
|
95
|
-
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
95
|
+
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Judge < Data
|
|
5
5
|
attr_accessor :response, :id, :first_name, :last_name
|
|
6
6
|
@all_hash = {}
|
|
@@ -67,4 +67,4 @@ e = sc.events.sample;
|
|
|
67
67
|
e.fights.first.fighters.first.born
|
|
68
68
|
|
|
69
69
|
fighter_hash = {'id' => "259117dc-c443-4086-8c1d-abd082e3d4b9" } # => Conor McGregor
|
|
70
|
-
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
70
|
+
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Referee < Data
|
|
5
5
|
attr_accessor :response, :id, :first_name, :last_name
|
|
6
6
|
@all_hash = {}
|
|
@@ -67,4 +67,4 @@ e = sc.events.sample;
|
|
|
67
67
|
e.fights.first.fighters.first.born
|
|
68
68
|
|
|
69
69
|
fighter_hash = {'id' => "259117dc-c443-4086-8c1d-abd082e3d4b9" } # => Conor McGregor
|
|
70
|
-
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
70
|
+
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Result < Data
|
|
5
5
|
attr_accessor :response, :id, :round, :time, :outcome, :submission, :endstrike, :endtarget, :endposition, :winner, :draw
|
|
6
6
|
|
|
@@ -65,4 +65,4 @@ e = sc.events.sample;
|
|
|
65
65
|
e.fights.first.fighters.first.born
|
|
66
66
|
|
|
67
67
|
fighter_hash = {'id' => "259117dc-c443-4086-8c1d-abd082e3d4b9" } # => Conor McGregor
|
|
68
|
-
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
68
|
+
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
3
|
+
module Mma
|
|
4
4
|
class Score < Data
|
|
5
5
|
attr_accessor :response, :id, :first_name, :last_name, :winner_score, :loser_score
|
|
6
6
|
# @all_hash = {}
|
|
@@ -80,4 +80,4 @@ e = sc.events.sample;
|
|
|
80
80
|
e.fights.first.fighters.first.born
|
|
81
81
|
|
|
82
82
|
fighter_hash = {'id' => "259117dc-c443-4086-8c1d-abd082e3d4b9" } # => Conor McGregor
|
|
83
|
-
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|
|
83
|
+
f = Sportradar::Api::Mma::Fighter.new(fighter_hash)
|