shift_stats 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/shift_stats.rb +110 -0
  3. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9d54b73bde10fcdede215185ab5fcde3539c45b9
4
- data.tar.gz: a87adf80f880b5fecb71984484f991851f7263c8
2
+ SHA256:
3
+ metadata.gz: df23cd594caf3bfc1dd8fef8eb8b948ffba38bf8f2137687f80db8d3cfb7de9f
4
+ data.tar.gz: f1b2a0cebbdbfd0a64645f3760dbe69b7b0d0666169ca184630875c16db74282
5
5
  SHA512:
6
- metadata.gz: 33034a682b21a06910a5fe7f8fc3e5b4d09576d31ebd6dbb69a89709a1ba3aee9e07d6261aecdbae6cb0c97a034d6bafc4700fec87a1364240dcbaf5f44c760e
7
- data.tar.gz: ed945d743212bd125dba623691fbbbd5054c109aa028979a3a626cdca2b7c55adb62cd2e7dc7309891340dd3c0f0266adb0065dc0f0545ef58c14a2a8729843c
6
+ metadata.gz: b0e9a911b7091680235b4b59affb34d2c4dcb725ca92d8999d099edb96ab18e5fc318c0f6eb8be1be43de98991951162cf9d5645742f3ed8fa3398491a6d38e4
7
+ data.tar.gz: 9d09088ea6bf932630f237d4959fc248ff4aa0022e373420e3889e3eb22e1e5207c2eb3e338f7713b3b8ffcbf5dbd04b48bd5b1a19a6ce7e5d2f5ae97b1e0ecc
@@ -39,6 +39,26 @@ class ShiftStats
39
39
  end
40
40
  end
41
41
 
42
+ def leagues()
43
+ JSON.parse(@client.get(url('leagues'), header: headers).body)
44
+ end
45
+
46
+ def league(league_id)
47
+ JSON.parse(@client.get(url("league/#{league_id}"), header: headers).body)
48
+ end
49
+
50
+ def league_seasons(league_id)
51
+ JSON.parse(@client.get(url("league/#{league_id}/seasons"), header: headers).body)
52
+ end
53
+
54
+ def league_suspensions(league_id, only_active: true)
55
+ query = {}
56
+ if only_active
57
+ query[:status] = 'active'
58
+ end
59
+ JSON.parse(@client.get(url("league/#{league_id}/suspensions"), query: query, header: headers).body)
60
+ end
61
+
42
62
  def team_search(sport, name)
43
63
  JSON.parse(@client.get(url('teams'), query: {name: name, not_ended: true, sport: sport.downcase}, header: headers).body)
44
64
  end
@@ -51,19 +71,109 @@ class ShiftStats
51
71
  JSON.parse(@client.get(url("team/#{team_id}/players"), query: {status: 'active'}, header: headers).body)
52
72
  end
53
73
 
74
+ def teams_in_division(division_name, league_id, current_season: true)
75
+ JSON.parse(@client.get(url('teams'), query: {division: division_name, league_id: league_id, not_ended: !!current_season}, header: headers).body)
76
+ end
77
+
78
+ def team_games(team_id, include_future: true, include_today: true)
79
+ JSON.parse(@client.get(url("team/#{team_id}/games"), query: {future: include_future, today: include_today}, header: headers).body)
80
+ end
81
+
82
+ def team_games_for_status(team_id, status: 'Final,In Progress,Forfeit')
83
+ JSON.parse(@client.get(url("team/#{team_id}/games"), query: {status: status}, header: headers).body)
84
+ end
85
+
86
+ def team_practices(team_id, include_future: true, include_today: true)
87
+ JSON.parse(@client.get(url("team/#{team_id}/practices"), query: {future: include_future, today: include_today}, header: headers).body)
88
+ end
89
+
90
+ def team_suspensions(team_id, only_active: true)
91
+ query = {}
92
+ if only_active
93
+ query[:status] = 'active'
94
+ end
95
+ JSON.parse(@client.get(url("team/#{team_id}/suspensions"), query: query, header: headers).body)
96
+ end
97
+
98
+ def game(game_id)
99
+ JSON.parse(@client.get(url("game/#{game_id}"), header: headers).body)
100
+ end
101
+
102
+ # only is :home or :away, optional
103
+ def game_goals(game_id, only: nil)
104
+ game_subpath(game_id, 'goals', only)
105
+ end
106
+
107
+ # only is :home or :away, optional
108
+ def game_goalies(game_id, only: nil)
109
+ game_subpath(game_id, 'goalies', only)
110
+ end
111
+
112
+ # only is :home or :away, optional
113
+ def game_penalties(game_id, only: nil)
114
+ game_subpath(game_id, 'penalties', only)
115
+ end
116
+
117
+ # only is :home or :away, optional
118
+ def game_roster(game_id, only: nil)
119
+ game_subpath(game_id, 'roster', only)
120
+ end
121
+
54
122
  def division_games_list(division_id)
55
123
  JSON.parse(@client.get(url("division/#{division_id}/games"), header: headers).body)
56
124
  end
57
125
 
126
+ # type is 'Regular Season', 'Playoffs', or 'Exhibition', required
127
+ def division_standings(division_id, type: 'Regular Season')
128
+ JSON.parse(@client.get(url("division/#{division_id}/standings"), query: {type: type}, header: headers).body)
129
+ end
130
+
131
+ def division_teams(division_id)
132
+ JSON.parse(@client.get(url("division/#{division_id}/teams"), header: headers).body)
133
+ end
134
+
135
+ # type is 'Regular Season', 'Playoffs', or 'Exhibition', required
136
+ # limit, required
137
+ # metrics, required
138
+ def division_leaders(division_id, type: 'Regular Season', limit: 20, metrics: [:points, :goals, :assists, :goals_against_average, :save_percentage, :wins, :shutouts, :number_first_stars, :number_stars])
139
+ JSON.parse(@client.get(url("division/#{division_id}/leaders"), query: {limit: limit, metrics: metrics.join(','), type: type}, header: headers).body)
140
+ end
141
+
142
+ def division_suspensions(division_id, only_active: true)
143
+ query = {}
144
+ if only_active
145
+ query[:status] = 'active'
146
+ end
147
+ JSON.parse(@client.get(url("division/#{division_id}/suspensions"), query: query, header: headers).body)
148
+ end
149
+
150
+ def season(season_id)
151
+ JSON.parse(@client.get(url("season/#{season_id}"), header: headers).body)
152
+ end
153
+
58
154
  def season_divisions_list(season_id)
59
155
  JSON.parse(@client.get(url("season/#{season_id}/divisions"), header: headers).body)
60
156
  end
61
157
 
158
+ def season_suspensions(season_id, only_active: true)
159
+ query = {}
160
+ if only_active
161
+ query[:status] = 'active'
162
+ end
163
+ JSON.parse(@client.get(url("season/#{season_id}/suspensions"), query: query, header: headers).body)
164
+ end
165
+
62
166
  private
63
167
  def url(sub)
64
168
  return "#{@url_base}#{sub}"
65
169
  end
66
170
 
171
+ def game_subpath(game_id, path, only)
172
+ path = "home_#{path}" if only == :home
173
+ path = "away_#{path}" if only == :away
174
+ JSON.parse(@client.get(url("game/#{game_id}/#{path}"), header: headers).body)
175
+ end
176
+
67
177
  def login_query
68
178
  {key: self.class.configuration.api_key}
69
179
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shift_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Pickett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2018-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '12'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3'
55
55
  description: Interfaces with Digital Shift APIs (HockeyShift, BasketballShift, etc.)
56
56
  email: chris@parnic.com
57
57
  executables: []
@@ -60,7 +60,7 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - lib/shift_stats.rb
62
62
  - lib/shift_stats/configuration.rb
63
- homepage: http://rubygems.org/gems/shift_stats
63
+ homepage: https://github.com/parnic/shift_stats
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.6.11
83
+ rubygems_version: 2.7.6
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Shift stats API