mlb_stats_api 0.2.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +30 -0
- data/.rubocop.yml +69 -4
- data/.vscode/settings.json +12 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +56 -34
- data/bin/console +2 -2
- data/lib/mlb_stats_api/base.rb +2 -6
- data/lib/mlb_stats_api/client.rb +3 -8
- data/lib/mlb_stats_api/color_feed.rb +2 -1
- data/lib/mlb_stats_api/conferences.rb +3 -10
- data/lib/mlb_stats_api/config.rb +14 -57
- data/lib/mlb_stats_api/divisions.rb +1 -5
- data/lib/mlb_stats_api/drafts.rb +4 -15
- data/lib/mlb_stats_api/errors.rb +7 -7
- data/lib/mlb_stats_api/games.rb +23 -51
- data/lib/mlb_stats_api/home_run_derby.rb +3 -13
- data/lib/mlb_stats_api/leagues.rb +9 -16
- data/lib/mlb_stats_api/live_feed.rb +12 -29
- data/lib/mlb_stats_api/people.rb +4 -7
- data/lib/mlb_stats_api/schedules.rb +4 -7
- data/lib/mlb_stats_api/seasons.rb +2 -9
- data/lib/mlb_stats_api/sports.rb +6 -18
- data/lib/mlb_stats_api/standings.rb +2 -4
- data/lib/mlb_stats_api/stats.rb +5 -10
- data/lib/mlb_stats_api/team.rb +10 -30
- data/lib/mlb_stats_api/teams.rb +8 -20
- data/lib/mlb_stats_api/venues.rb +2 -6
- data/lib/mlb_stats_api/version.rb +1 -1
- data/mlb_stats_api.gemspec +13 -10
- metadata +38 -22
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e9bba45d360b519bccd1b22745067ffda8245672a11ec43a1320e11da22fb71
|
4
|
+
data.tar.gz: a4dabc6bccc1a4ed6751c7e6e29a0444814196abfc7208cf61e0109e9d542f61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95614ebb018b8fa5c747cf68c250775a0daa87047505e36b8acb1f0f9347c942f71c33901edd2cd960e9c63845d24b77e8afc8378e849d8f4167f69b43ea6d5a
|
7
|
+
data.tar.gz: 8481c2e4fc37c84db1a25f7708e14be896a66c1f6507165e9869d52d89d9cf2528590c46c89ba9f089963503559de6f28bf2449ad3b94627be35255244ec30fe
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master]
|
6
|
+
pull_request:
|
7
|
+
branches: [master]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu]
|
15
|
+
ruby: [3.1]
|
16
|
+
|
17
|
+
runs-on: ${{ matrix.os }}-latest
|
18
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically:
|
27
|
+
- name: Install dependencies
|
28
|
+
run: bundle install
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,74 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
EnabledByDefault: true
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
|
6
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
7
|
+
# Coding Style
|
8
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
3
9
|
|
4
10
|
Layout/MultilineMethodCallIndentation:
|
5
11
|
EnforcedStyle: indented
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
|
13
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
14
|
+
# Cops that should not be run
|
15
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
16
|
+
|
17
|
+
# Recommends each array item be on its own line.
|
18
|
+
Layout/MultilineArrayLineBreaks:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# Recommends right hand side of multi-line assignment be on a new line
|
22
|
+
Layout/MultilineAssignmentLayout:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# Wants every argument in a multi-line method call to be on its own line
|
26
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# Recommends squishing a multi-line hash into one line. I don't like that. It's not readable.
|
30
|
+
Layout/RedundantLineBreak:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Recommends `::File` instead of `File`
|
34
|
+
Lint/ConstantResolution:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Converts if-elsif to case-when.
|
38
|
+
Style/CaseLikeIf:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# Wants every constant to be listed in #public_constant or #private_constant
|
42
|
+
Style/ConstantVisibility:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/Copyright:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Every class and module *should* be documented, but I don't have the time
|
49
|
+
Style/Documentation:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Every method *should* be documented, but I don't have the time
|
53
|
+
Style/DocumentationMethod:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Converts [1, 2, three: 3] to [1, 2, { three: 3 }]
|
57
|
+
Style/HashAsLastArrayItem:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Converts `a_method 1` to `a_method(1)`
|
61
|
+
Style/MethodCallWithArgsParentheses:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
# Not every `if` needs an `else`
|
65
|
+
Style/MissingElse:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
# HTTP headers need to use string keys
|
69
|
+
Style/StringHashKeys:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
# I consider myself capable of understanding logical operators in an unless
|
73
|
+
Style/UnlessLogicalOperators:
|
74
|
+
Enabled: false
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,47 +1,68 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mlb_stats_api (0.
|
4
|
+
mlb_stats_api (0.4.0)
|
5
5
|
hana (~> 1.3)
|
6
|
-
httparty (~> 0.
|
7
|
-
moneta (~> 1.
|
6
|
+
httparty (~> 0.20)
|
7
|
+
moneta (~> 1.5)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.
|
13
|
-
public_suffix (>= 2.0.2, <
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
addressable (2.8.1)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
crack (0.4.5)
|
16
|
+
rexml
|
17
|
+
diff-lcs (1.5.0)
|
18
|
+
hana (1.3.7)
|
18
19
|
hashdiff (1.0.1)
|
19
|
-
httparty (0.
|
20
|
+
httparty (0.20.0)
|
20
21
|
mime-types (~> 3.0)
|
21
22
|
multi_xml (>= 0.5.2)
|
22
|
-
|
23
|
+
json (2.6.2)
|
24
|
+
mime-types (3.4.1)
|
23
25
|
mime-types-data (~> 3.2015)
|
24
|
-
mime-types-data (3.
|
25
|
-
moneta (1.
|
26
|
+
mime-types-data (3.2022.0105)
|
27
|
+
moneta (1.5.1)
|
26
28
|
multi_xml (0.6.0)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rspec
|
29
|
+
parallel (1.22.1)
|
30
|
+
parser (3.1.2.1)
|
31
|
+
ast (~> 2.4.1)
|
32
|
+
public_suffix (5.0.0)
|
33
|
+
rainbow (3.1.1)
|
34
|
+
rake (13.0.6)
|
35
|
+
regexp_parser (2.6.0)
|
36
|
+
rexml (3.2.5)
|
37
|
+
rspec (3.11.0)
|
38
|
+
rspec-core (~> 3.11.0)
|
39
|
+
rspec-expectations (~> 3.11.0)
|
40
|
+
rspec-mocks (~> 3.11.0)
|
41
|
+
rspec-core (3.11.0)
|
42
|
+
rspec-support (~> 3.11.0)
|
43
|
+
rspec-expectations (3.11.1)
|
36
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-mocks (3.
|
45
|
+
rspec-support (~> 3.11.0)
|
46
|
+
rspec-mocks (3.11.1)
|
39
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-support (3.
|
42
|
-
|
43
|
-
|
44
|
-
|
48
|
+
rspec-support (~> 3.11.0)
|
49
|
+
rspec-support (3.11.1)
|
50
|
+
rubocop (1.37.0)
|
51
|
+
json (~> 2.3)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 3.1.2.1)
|
54
|
+
rainbow (>= 2.2.2, < 4.0)
|
55
|
+
regexp_parser (>= 1.8, < 3.0)
|
56
|
+
rexml (>= 3.2.5, < 4.0)
|
57
|
+
rubocop-ast (>= 1.22.0, < 2.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
60
|
+
rubocop-ast (1.23.0)
|
61
|
+
parser (>= 3.1.1.0)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
unicode-display_width (2.3.0)
|
64
|
+
webmock (3.18.1)
|
65
|
+
addressable (>= 2.8.0)
|
45
66
|
crack (>= 0.3.2)
|
46
67
|
hashdiff (>= 0.4.0, < 2.0.0)
|
47
68
|
|
@@ -49,11 +70,12 @@ PLATFORMS
|
|
49
70
|
ruby
|
50
71
|
|
51
72
|
DEPENDENCIES
|
52
|
-
bundler (>
|
73
|
+
bundler (> 2.3)
|
53
74
|
mlb_stats_api!
|
54
|
-
rake (>
|
55
|
-
rspec (~> 3.
|
56
|
-
|
75
|
+
rake (> 13.0)
|
76
|
+
rspec (~> 3.11)
|
77
|
+
rubocop (~> 1.37)
|
78
|
+
webmock (~> 3.18)
|
57
79
|
|
58
80
|
BUNDLED WITH
|
59
|
-
|
81
|
+
2.3.22
|
data/bin/console
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
require 'bundler/setup'
|
5
5
|
require 'mlb_stats_api'
|
6
6
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
#
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting with your gem easier. You can also use a
|
8
|
+
# different console, if you like.
|
9
9
|
|
10
10
|
@client = MLBStatsAPI::Client.new
|
11
11
|
|
data/lib/mlb_stats_api/base.rb
CHANGED
data/lib/mlb_stats_api/client.rb
CHANGED
@@ -46,7 +46,7 @@ module MLBStatsAPI
|
|
46
46
|
@logger = logger.is_a?(::Logger) ? logger : ::Logger.new(logger)
|
47
47
|
end
|
48
48
|
|
49
|
-
def get(endpoint, query
|
49
|
+
def get(endpoint, **query)
|
50
50
|
url = "/api/v#{query.delete(:version) || DEFAULT_VERSION}#{endpoint}"
|
51
51
|
|
52
52
|
args = normalize_query_args(query)
|
@@ -60,14 +60,9 @@ module MLBStatsAPI
|
|
60
60
|
response.parsed_response
|
61
61
|
end
|
62
62
|
|
63
|
-
def normalize_query_args(query)
|
64
|
-
query
|
65
|
-
.reject { |_, v| v.nil? }
|
66
|
-
.map { |key, val| [key, val.is_a?(Array) ? val.join(',') : val] }
|
67
|
-
.to_h
|
68
|
-
end
|
63
|
+
def normalize_query_args(query) = query.compact.transform_values { _1.is_a?(Array) ? _1.join(',') : _1 }
|
69
64
|
|
70
|
-
def load(key, options
|
65
|
+
def load(key, **options)
|
71
66
|
value = @cache.load(key)
|
72
67
|
|
73
68
|
return value if value
|
@@ -2,18 +2,11 @@
|
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
4
|
# Only the Pacific Coast League uses conferences
|
5
|
-
# @see https://statsapi.mlb.com/docs/#tag/conference
|
6
5
|
module Conferences
|
7
6
|
# View all PCL conferences.
|
8
|
-
|
9
|
-
def conferences(options = {})
|
10
|
-
get '/conferences', options
|
11
|
-
end
|
7
|
+
def conferences(**options) = get('/conferences', **options)
|
12
8
|
|
13
|
-
# View PCL conferences by
|
14
|
-
|
15
|
-
def conference(conference_id, options = {})
|
16
|
-
get "/conferences/#{conference_id}", options
|
17
|
-
end
|
9
|
+
# View PCL conferences by conference ID.
|
10
|
+
def conference(conference_id, **options) = get("/conferences/#{conference_id}", **options)
|
18
11
|
end
|
19
12
|
end
|
data/lib/mlb_stats_api/config.rb
CHANGED
@@ -2,76 +2,33 @@
|
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
4
|
# These methods all return lists of possible values
|
5
|
-
# @see https://statsapi.mlb.com/docs/#tag/config
|
6
5
|
module Config
|
7
|
-
|
8
|
-
def game_status
|
9
|
-
get '/gameStatus'
|
10
|
-
end
|
6
|
+
def game_status = get('/gameStatus')
|
11
7
|
|
12
|
-
|
13
|
-
def baseball_stats
|
14
|
-
get '/baseballStats'
|
15
|
-
end
|
8
|
+
def baseball_stats = get('/baseballStats')
|
16
9
|
|
17
|
-
|
18
|
-
def game_types
|
19
|
-
get '/gameTypes'
|
20
|
-
end
|
10
|
+
def game_types = get('/gameTypes')
|
21
11
|
|
22
|
-
|
23
|
-
def languages
|
24
|
-
get '/languages'
|
25
|
-
end
|
12
|
+
def languages = get('/languages')
|
26
13
|
|
27
|
-
|
28
|
-
def league_leader_types
|
29
|
-
get '/leagueLeaderTypes'
|
30
|
-
end
|
14
|
+
def league_leader_types = get('/leagueLeaderTypes')
|
31
15
|
|
32
|
-
|
33
|
-
def metrics
|
34
|
-
get '/metrics'
|
35
|
-
end
|
16
|
+
def metrics = get('/metrics')
|
36
17
|
|
37
|
-
|
38
|
-
def platforms
|
39
|
-
get '/platforms'
|
40
|
-
end
|
18
|
+
def platforms = get('/platforms')
|
41
19
|
|
42
|
-
|
43
|
-
def positions
|
44
|
-
get '/positions'
|
45
|
-
end
|
20
|
+
def positions = get('/positions')
|
46
21
|
|
47
|
-
|
48
|
-
def roster_types
|
49
|
-
get '/rosterTypes'
|
50
|
-
end
|
22
|
+
def roster_types = get('/rosterTypes')
|
51
23
|
|
52
|
-
|
53
|
-
def schedule_event_types
|
54
|
-
get '/scheduleEventTypes'
|
55
|
-
end
|
24
|
+
def schedule_event_types = get('/scheduleEventTypes')
|
56
25
|
|
57
|
-
|
58
|
-
def situation_codes
|
59
|
-
get '/situationCodes'
|
60
|
-
end
|
26
|
+
def situation_codes = get('/situationCodes')
|
61
27
|
|
62
|
-
|
63
|
-
def standings_types
|
64
|
-
get '/standingsTypes'
|
65
|
-
end
|
28
|
+
def standings_types = get('/standingsTypes')
|
66
29
|
|
67
|
-
|
68
|
-
def stat_groups
|
69
|
-
get '/statGroups'
|
70
|
-
end
|
30
|
+
def stat_groups = get('/statGroups')
|
71
31
|
|
72
|
-
|
73
|
-
def stat_types
|
74
|
-
get '/statTypes'
|
75
|
-
end
|
32
|
+
def stat_types = get('/statTypes')
|
76
33
|
end
|
77
34
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
|
-
# @see https://statsapi.mlb.com/docs/#tag/division
|
5
4
|
module Divisions
|
6
5
|
# There are actually far more divisions from other leagues in the API.
|
7
6
|
# I don't think I'll add them until necessary.
|
@@ -15,9 +14,6 @@ module MLBStatsAPI
|
|
15
14
|
}.freeze
|
16
15
|
|
17
16
|
# View league division directorial information.
|
18
|
-
|
19
|
-
def divisions(options = {})
|
20
|
-
get '/divisions', options
|
21
|
-
end
|
17
|
+
def divisions(**options) = get('/divisions', **options)
|
22
18
|
end
|
23
19
|
end
|
data/lib/mlb_stats_api/drafts.rb
CHANGED
@@ -2,25 +2,14 @@
|
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
4
|
# Operations pertaining to MLB Rule 4 Draft (First-Year Player Draft)
|
5
|
-
# @see https://statsapi.mlb.com/docs/#tag/draft
|
6
5
|
module Drafts
|
7
6
|
# View drafted players by year.
|
8
|
-
|
9
|
-
def draft(year, options = {})
|
10
|
-
get "/draft/#{year}", options
|
11
|
-
end
|
7
|
+
def draft(year, **options) = get("/draft/#{year}", **options)
|
12
8
|
|
13
9
|
# View draft eligible prospects by year.
|
14
|
-
|
15
|
-
def draft_prospects(year, options = {})
|
16
|
-
get "/draft/#{year}/prospects", options
|
17
|
-
end
|
10
|
+
def draft_prospects(year, **options) = get("/draft/#{year}/prospects", **options)
|
18
11
|
|
19
|
-
# View latest player drafted, endpoint best used when draft is currently
|
20
|
-
|
21
|
-
# @see https://statsapi.mlb.com/docs/#operation/latestDraftPicks
|
22
|
-
def draft_latest(year, options = {})
|
23
|
-
get "/draft/#{year}/latest", options
|
24
|
-
end
|
12
|
+
# View latest player drafted, endpoint best used when draft is currently open.
|
13
|
+
def draft_latest(year, **options) = get("/draft/#{year}/latest", **options)
|
25
14
|
end
|
26
15
|
end
|
data/lib/mlb_stats_api/errors.rb
CHANGED
@@ -3,25 +3,25 @@
|
|
3
3
|
module MLBStatsAPI
|
4
4
|
class Error < ::RuntimeError
|
5
5
|
def initialize(response)
|
6
|
+
super()
|
7
|
+
|
6
8
|
@response = response
|
7
9
|
end
|
8
10
|
|
9
11
|
def to_s
|
12
|
+
# @response.response
|
10
13
|
format(
|
11
14
|
'%<code>s: %<message>s (%<uri>s)',
|
12
15
|
code: @response.code,
|
13
|
-
message: '',
|
16
|
+
message: '',
|
14
17
|
uri: @response.request.last_uri.to_s
|
15
18
|
)
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
class ForbiddenError < Error
|
20
|
-
end
|
22
|
+
class ForbiddenError < Error; end
|
21
23
|
|
22
|
-
class NotFoundError < Error
|
23
|
-
end
|
24
|
+
class NotFoundError < Error; end
|
24
25
|
|
25
|
-
class UnauthorizedError < Error
|
26
|
-
end
|
26
|
+
class UnauthorizedError < Error; end
|
27
27
|
end
|
data/lib/mlb_stats_api/games.rb
CHANGED
@@ -2,42 +2,26 @@
|
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
4
|
module Games
|
5
|
-
PREGAME_STATUSES = /
|
6
|
-
|
7
|
-
/x.freeze
|
5
|
+
PREGAME_STATUSES = /Preview|Warmup|Pre-Game|Delayed Start|Scheduled/
|
6
|
+
POSTGAME_STATUSES = /Final|Game Over|Postponed|Completed Early/
|
8
7
|
|
9
|
-
|
8
|
+
def self.pregame_status?(status) = PREGAME_STATUSES.match?(status)
|
10
9
|
|
11
|
-
def self.
|
12
|
-
PREGAME_STATUSES.match?(status)
|
13
|
-
end
|
10
|
+
def self.postgame_status?(status) = POSTGAME_STATUSES.match?(status)
|
14
11
|
|
15
|
-
def
|
16
|
-
POSTGAME_STATUSES.match?(status)
|
17
|
-
end
|
12
|
+
def boxscore(game_pk) = get("/game/#{game_pk}/boxscore")
|
18
13
|
|
19
|
-
def
|
20
|
-
get "/game/#{game_id}/boxscore"
|
21
|
-
end
|
22
|
-
|
23
|
-
def content(game_id, limit: nil)
|
24
|
-
get "/game/#{game_id}/content", highlightLimit: limit
|
25
|
-
end
|
14
|
+
def content(game_pk, limit: nil) = get("/game/#{game_pk}/content", highlightLimit: limit)
|
26
15
|
|
27
|
-
def context_metrics(
|
28
|
-
get "/game/#{game_id}/contextMetrics", timecode: timecode
|
29
|
-
end
|
16
|
+
def context_metrics(game_pk, timecode: nil) = get("/game/#{game_pk}/contextMetrics", timecode:)
|
30
17
|
|
31
|
-
# This endpoint can return very large payloads. It is STRONGLY recommended
|
32
|
-
#
|
33
|
-
def live_feed(
|
34
|
-
MLBStatsAPI::LiveFeed.new(
|
35
|
-
self,
|
36
|
-
get("/game/#{game_id}/feed/live", version: '1.1', timecode: timecode)
|
37
|
-
)
|
18
|
+
# This endpoint can return very large payloads. It is STRONGLY recommended that clients ask for diffs and use
|
19
|
+
# "Accept-Encoding: gzip" header.
|
20
|
+
def live_feed(game_pk, timecode: nil)
|
21
|
+
MLBStatsAPI::LiveFeed.new self, get("/game/#{game_pk}/feed/live", version: '1.1', timecode:)
|
38
22
|
end
|
39
23
|
|
40
|
-
def live_feed_diff(
|
24
|
+
def live_feed_diff(game_pk, timecode: nil, snapshot_at: nil)
|
41
25
|
query = { version: '1.1' }
|
42
26
|
|
43
27
|
if timecode
|
@@ -48,22 +32,16 @@ module MLBStatsAPI
|
|
48
32
|
raise ArgumentError, 'Please pass either a timecode or a snapshot.'
|
49
33
|
end
|
50
34
|
|
51
|
-
get "/game/#{
|
35
|
+
get "/game/#{game_pk}/feed/live/diffPatch", query
|
52
36
|
end
|
53
37
|
|
54
|
-
def live_feed_timestamps(
|
55
|
-
get "/game/#{game_id}/feed/live/timestamps", version: '1.1'
|
56
|
-
end
|
38
|
+
def live_feed_timestamps(game_pk) = get("/game/#{game_pk}/feed/live/timestamps", version: '1.1')
|
57
39
|
|
58
|
-
def color_feed(
|
59
|
-
MLBStatsAPI::ColorFeed.new(
|
60
|
-
self,
|
61
|
-
game_id,
|
62
|
-
get("/game/#{game_id}/feed/color", timecode: timecode)
|
63
|
-
)
|
40
|
+
def color_feed(game_pk, timecode: nil)
|
41
|
+
MLBStatsAPI::ColorFeed.new self, game_pk, get("/game/#{game_pk}/feed/color", timecode:)
|
64
42
|
end
|
65
43
|
|
66
|
-
# def color_feed_diff(
|
44
|
+
# def color_feed_diff(game_pk, timecode: nil, snapshot_at: nil)
|
67
45
|
# query = {}
|
68
46
|
|
69
47
|
# if timecode
|
@@ -74,23 +52,17 @@ module MLBStatsAPI
|
|
74
52
|
# raise ArgumentError, 'Please pass either a timecode or a snapshot.'
|
75
53
|
# end
|
76
54
|
|
77
|
-
# get "/game/#{
|
55
|
+
# get "/game/#{game_pk}/feed/color/diffPatch", query
|
78
56
|
# end
|
79
57
|
|
80
|
-
# def color_feed_timestamps(
|
81
|
-
# get "/game/#{
|
58
|
+
# def color_feed_timestamps(game_pk)
|
59
|
+
# get "/game/#{game_pk}/feed/color/timestamps"
|
82
60
|
# end
|
83
61
|
|
84
|
-
def linescore(
|
85
|
-
get "/game/#{game_id}/linescore"
|
86
|
-
end
|
62
|
+
def linescore(game_pk) = get("/game/#{game_pk}/linescore")
|
87
63
|
|
88
|
-
def play_by_play(
|
89
|
-
get "/game/#{game_id}/playByPlay", timecode: timecode
|
90
|
-
end
|
64
|
+
def play_by_play(game_pk, timecode: nil) = get("/game/#{game_pk}/playByPlay", timecode:)
|
91
65
|
|
92
|
-
def win_probability(
|
93
|
-
get "/game/#{game_id}/winProbability", timecode: timecode
|
94
|
-
end
|
66
|
+
def win_probability(game_pk, timecode: nil) = get("/game/#{game_pk}/winProbability", timecode:)
|
95
67
|
end
|
96
68
|
end
|
@@ -1,24 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MLBStatsAPI
|
4
|
-
# @see https://statsapi.mlb.com/docs/#tag/homerunderby
|
5
4
|
module HomeRunDerby
|
6
5
|
# View a home run derby object based on gamePk.
|
7
|
-
|
8
|
-
def home_run_derby(game_pk, options = {})
|
9
|
-
get "/homeRunDerby/#{game_pk}", options
|
10
|
-
end
|
6
|
+
def home_run_derby(game_pk, **options) = get("/homeRunDerby/#{game_pk}", **options)
|
11
7
|
|
12
8
|
# View a home run derby object based on bracket.
|
13
|
-
|
14
|
-
def home_run_derby_bracket(game_pk, options = {})
|
15
|
-
get "/homeRunDerby/#{game_pk}/bracket", options
|
16
|
-
end
|
9
|
+
def home_run_derby_bracket(game_pk, **options) = get("/homeRunDerby/#{game_pk}/bracket", **options)
|
17
10
|
|
18
11
|
# View a home run derby object based on pool.
|
19
|
-
|
20
|
-
def home_run_derby_pool(game_pk, options = {})
|
21
|
-
get "/homeRunDerby/#{game_pk}/pool", options
|
22
|
-
end
|
12
|
+
def home_run_derby_pool(game_pk, **options) = get("/homeRunDerby/#{game_pk}/pool", **options)
|
23
13
|
end
|
24
14
|
end
|