dota 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.sample +2 -0
- data/.gitignore +2 -0
- data/.travis.yml +3 -1
- data/README.md +26 -7
- data/dota.gemspec +1 -0
- data/lib/dota.rb +4 -0
- data/lib/dota/api/client.rb +7 -0
- data/lib/dota/api/live_match.rb +73 -0
- data/lib/dota/api/live_match/player.rb +40 -0
- data/lib/dota/api/live_match/scoreboard.rb +31 -0
- data/lib/dota/api/live_match/side.rb +31 -0
- data/lib/dota/version.rb +1 -1
- data/spec/dota/api/live_match/player_spec.rb +26 -0
- data/spec/dota/api/live_match/scoreboard_spec.rb +25 -0
- data/spec/dota/api/live_match/side_spec.rb +25 -0
- data/spec/dota/api/live_match_spec.rb +62 -0
- data/spec/dota_spec.rb +7 -1
- data/spec/fixtures/vcr_cassettes/GetFriendList.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetLeagueListing.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetLiveLeagueGames.yml +1336 -0
- data/spec/fixtures/vcr_cassettes/GetMatchDetails.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetMatchHistory.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetRarities.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetTeamInfoByTeamID.yml +1 -1
- data/spec/fixtures/vcr_cassettes/GetTeamInfoByTeamID_many.yml +1 -1
- data/spec/spec_helper.rb +4 -1
- data/spec/support/vcr.rb +1 -0
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23fc49df23488bce2c5a7ba87cddf20ba521ef67
|
4
|
+
data.tar.gz: 67a569a29f97b37fbfd1b79a12c5ed14ad15e406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23036186cdc6dc69a544c48d8c1470c286dc939a8b77911230d4cd683a6c9b6aff245d7fb93b8f950ae159ab7439ab2862d0bde2339a5a1e3677be933f929c80
|
7
|
+
data.tar.gz: c4dbd4ea60a50c1e49c1f4a6e9d5f98f41861a302780a1a0cf216090df4565a367cbcda81c8bcb8822877ea743a72d52600a8c0cfdb75b13ba2dd89773b85105
|
data/.env.sample
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,7 @@ Currently supported endpoints:
|
|
12
12
|
- GetGameItems
|
13
13
|
- [GetRarities](https://wiki.teamfortress.com/wiki/WebAPI/GetRarities)
|
14
14
|
- [GetTeamInfoByTeamID](https://wiki.teamfortress.com/wiki/WebAPI/GetTeamInfoByTeamID)
|
15
|
+
- [GetLiveLeagueGames](https://wiki.teamfortress.com/wiki/WebAPI/GetLiveLeagueGames)
|
15
16
|
|
16
17
|
Unsupported endpoints can still be queried via [custom requests](#custom-requests).
|
17
18
|
|
@@ -20,7 +21,6 @@ This gem is in alpha, keep that in mind when upgrading.
|
|
20
21
|
## TODO
|
21
22
|
|
22
23
|
- Support for more endpoints
|
23
|
-
- [GetLiveLeagueGames](https://wiki.teamfortress.com/wiki/WebAPI/GetLiveLeagueGames)
|
24
24
|
- [GetMatchHistoryBySequenceNum](https://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistoryBySequenceNum)
|
25
25
|
- [GetPlayerSummaries](https://wiki.teamfortress.com/wiki/WebAPI/GetPlayerSummaries)
|
26
26
|
- [GetScheduledLeagueGames](https://wiki.teamfortress.com/wiki/WebAPI/GetScheduledLeagueGames)
|
@@ -52,7 +52,7 @@ Or install it yourself as:
|
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
Dota.configure do |config|
|
55
|
-
config.api_key = "
|
55
|
+
config.api_key = ENV.fetch("STEAM_API_KEY")
|
56
56
|
end
|
57
57
|
```
|
58
58
|
|
@@ -94,6 +94,8 @@ api.matches(hero_id: 43) # Allowed options:
|
|
94
94
|
# :league_only - Boolean, Only league matches
|
95
95
|
# :limit - Integer, Amount of matches to return (default is 100)
|
96
96
|
|
97
|
+
api.live_matches # => A list of live matches
|
98
|
+
|
97
99
|
api.friends(76561198052976237) # => All friends of user
|
98
100
|
```
|
99
101
|
|
@@ -175,18 +177,18 @@ match.positive_votes # Integer, Number of thumbs-up the game has receiv
|
|
175
177
|
match.negative_votes # Integer, Number of thumbs-down the game has received
|
176
178
|
|
177
179
|
match.radiant_id # Integer, Radiant team's ID
|
178
|
-
match.radiant_captain_id # Integer, Radiant captain's ID
|
180
|
+
match.radiant_captain_id # Integer, Radiant captain's 32-bit Steam ID
|
179
181
|
match.radiant_logo_id # Integer, Radiant logo's UGC ID
|
180
182
|
match.radiant_name # String, Radiant team's name
|
181
|
-
match.radiant_complete? # Boolean, true if the Radiant team's roster is
|
183
|
+
match.radiant_complete? # Boolean, true if the Radiant team's roster is complete
|
182
184
|
match.radiant_tower_status # Integer, See https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails # Tower_Status
|
183
185
|
match.radiant_barracks_status # Integer, See https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails # Barracks_Status
|
184
186
|
|
185
187
|
match.dire_id # Integer, Dire team's ID
|
186
|
-
match.dire_captain_id # Integer, Dire captain's ID
|
188
|
+
match.dire_captain_id # Integer, Dire captain's 32-bit Steam ID
|
187
189
|
match.dire_logo_id # Integer, Dire logo's UGC ID
|
188
190
|
match.dire_name # String, Dire team's name
|
189
|
-
match.dire_complete? # Boolean, true if the Dire team's roster is
|
191
|
+
match.dire_complete? # Boolean, true if the Dire team's roster is complete
|
190
192
|
match.dire_tower_status # Integer, See https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails # Tower_Status
|
191
193
|
match.dire_barracks_status # Integer, See https://wiki.teamfortress.com/wiki/WebAPI/GetMatchDetails # Barracks_Status
|
192
194
|
```
|
@@ -226,7 +228,7 @@ draft.hero # Dota::API::Hero, Picked or banned hero
|
|
226
228
|
#### Cosmetic Rarities
|
227
229
|
|
228
230
|
```ruby
|
229
|
-
rarity.id # Integer, ID of rarity, used for indexing
|
231
|
+
rarity.id # Integer, ID of the rarity, used for indexing
|
230
232
|
rarity.order # Integer, Sorting and logical order, from most distributed to least
|
231
233
|
rarity.name # String, Localized display name
|
232
234
|
rarity.color # String, The hexadecimal RGB tuple
|
@@ -240,6 +242,23 @@ friend.relationship # String, Relation to the player
|
|
240
242
|
friend.made_at # Time, When the friend was added to the player's friend list
|
241
243
|
```
|
242
244
|
|
245
|
+
#### Live Matches
|
246
|
+
```ruby
|
247
|
+
live_matches.id # Integer, ID of the match
|
248
|
+
live_matches.lobby_id # Integer, ID of the lobby
|
249
|
+
live_matches.spectators_count # Integer, Number of spectators watching on DotaTV
|
250
|
+
live_matches.league_id # Integer, ID of the league
|
251
|
+
live_matches.stream_delay # Integer, Number of seconds the stream is behind actual game time
|
252
|
+
live_matches.radiant_series_wins # Integer, Number of wins the Radiant team has in the series
|
253
|
+
live_matches.dire_series_wins # Integer, Number of wins the Dire team has in the series
|
254
|
+
live_matches.radiant # Dota::API::LiveMatch::Side, Info about the team on the Radiant side
|
255
|
+
live_matches.dire # Dota::API::LiveMatch::Side, Info about the team on the Dire side
|
256
|
+
live_matches.series_type # Integer, Best of X series
|
257
|
+
live_matches.league_tier # String, What tier the match's league is
|
258
|
+
live_matches.players # Array[Dota::API::LiveMatch::Players], High level info about the players in the match (some redundant info in scoreboard)
|
259
|
+
live_matches.scoreboard # Hash, Details of the scoreboard (to be converted soon to an object and/or integrated with our players class)
|
260
|
+
```
|
261
|
+
|
243
262
|
## Contributing
|
244
263
|
|
245
264
|
1. [Fork it!](https://github.com/vinnicc/dota/fork)
|
data/dota.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rspec"
|
26
26
|
spec.add_development_dependency "guard-rspec"
|
27
27
|
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "dotenv"
|
28
29
|
spec.add_development_dependency "vcr"
|
29
30
|
spec.add_development_dependency "webmock"
|
30
31
|
end
|
data/lib/dota.rb
CHANGED
@@ -9,6 +9,10 @@ require 'dota/api/friend'
|
|
9
9
|
require 'dota/api/hero'
|
10
10
|
require 'dota/api/item'
|
11
11
|
require 'dota/api/league'
|
12
|
+
require 'dota/api/live_match'
|
13
|
+
require 'dota/api/live_match/player'
|
14
|
+
require 'dota/api/live_match/side'
|
15
|
+
require 'dota/api/live_match/scoreboard'
|
12
16
|
require 'dota/api/match'
|
13
17
|
require 'dota/api/match/draft'
|
14
18
|
require 'dota/api/match/player'
|
data/lib/dota/api/client.rb
CHANGED
@@ -65,6 +65,13 @@ module Dota
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def live_matches
|
69
|
+
response = get("IDOTA2Match_570", "GetLiveLeagueGames")["result"]
|
70
|
+
if response && (live_matches = response["games"])
|
71
|
+
live_matches.map { |game| LiveMatch.new(game) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
68
75
|
def cosmetic_rarities
|
69
76
|
response = get("IEconDOTA2_570", "GetRarities", language: "en")["result"]
|
70
77
|
if response && (rarities = response["rarities"])
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class LiveMatch
|
4
|
+
LEAGUE_TIERS = {
|
5
|
+
1 => "Amateur",
|
6
|
+
2 => "Professional",
|
7
|
+
3 => "Premier"
|
8
|
+
}
|
9
|
+
|
10
|
+
include Utilities::Inspectable
|
11
|
+
|
12
|
+
attr_reader :raw
|
13
|
+
|
14
|
+
def initialize(raw)
|
15
|
+
@raw = raw
|
16
|
+
end
|
17
|
+
|
18
|
+
def lobby_id
|
19
|
+
raw["lobby_id"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def id
|
23
|
+
raw["match_id"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def spectators_count
|
27
|
+
raw["spectators"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def league_id
|
31
|
+
raw["league_id"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def stream_delay
|
35
|
+
raw["stream_delay_s"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def radiant_wins
|
39
|
+
raw["radiant_series_wins"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def dire_wins
|
43
|
+
raw["dire_series_wins"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def radiant
|
47
|
+
Side.new(raw["radiant_team"])
|
48
|
+
end
|
49
|
+
|
50
|
+
def dire
|
51
|
+
Side.new(raw["dire_team"])
|
52
|
+
end
|
53
|
+
|
54
|
+
def series_type
|
55
|
+
raw["series_type"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def league_tier
|
59
|
+
LEAGUE_TIERS[raw["league_tier"]]
|
60
|
+
end
|
61
|
+
|
62
|
+
def players
|
63
|
+
raw["players"].map do |raw_player|
|
64
|
+
Player.new(raw_player)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def scoreboard
|
69
|
+
Scoreboard.new(raw["scoreboard"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class LiveMatch
|
4
|
+
class Player
|
5
|
+
include Utilities::Inspectable
|
6
|
+
|
7
|
+
attr_reader :raw
|
8
|
+
|
9
|
+
def initialize(raw)
|
10
|
+
@raw = raw
|
11
|
+
end
|
12
|
+
|
13
|
+
def id
|
14
|
+
raw["account_id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
raw["name"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def hero
|
22
|
+
Hero.new(raw["hero_id"])
|
23
|
+
end
|
24
|
+
|
25
|
+
def team
|
26
|
+
case raw["team"]
|
27
|
+
when 0
|
28
|
+
:radiant
|
29
|
+
when 1
|
30
|
+
:dire
|
31
|
+
when 2
|
32
|
+
:broadcaster
|
33
|
+
when 4
|
34
|
+
:unassigned
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class LiveMatch
|
4
|
+
class Scoreboard
|
5
|
+
include Utilities::Inspectable
|
6
|
+
|
7
|
+
attr_reader :raw
|
8
|
+
|
9
|
+
def initialize(raw)
|
10
|
+
@raw = raw
|
11
|
+
end
|
12
|
+
|
13
|
+
def duration
|
14
|
+
raw["duration"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def roshan_timer
|
18
|
+
raw["roshan_respawn_timer"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def radiant
|
22
|
+
raw["radiant"] # this maps out much further. for now it'll act as a hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def dire
|
26
|
+
raw["dire"] # this maps out much further. for now it'll act as a hash
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class LiveMatch
|
4
|
+
class Side
|
5
|
+
include Utilities::Inspectable
|
6
|
+
|
7
|
+
attr_reader :raw
|
8
|
+
|
9
|
+
def initialize(raw)
|
10
|
+
@raw = raw
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
raw["team_name"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def id
|
18
|
+
raw["team_id"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def logo_id
|
22
|
+
raw["team_logo"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete?
|
26
|
+
raw["complete"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/dota/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
describe Dota::API::LiveMatch::Player do
|
2
|
+
let(:player) do
|
3
|
+
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
+
matches = test_client.live_matches
|
5
|
+
first_match = matches.first
|
6
|
+
players = first_match.players
|
7
|
+
players.first
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
specify "#id" do
|
12
|
+
expect(player.id).to eq 34145091
|
13
|
+
end
|
14
|
+
|
15
|
+
specify "#name" do
|
16
|
+
expect(player.name).to eq "Lunar Gato @ CSPL.ru"
|
17
|
+
end
|
18
|
+
|
19
|
+
specify "#hero" do
|
20
|
+
expect(player.hero).to be_a Dota::API::Hero
|
21
|
+
end
|
22
|
+
|
23
|
+
specify "#team" do
|
24
|
+
expect(player.team).to eq :radiant
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Dota::API::LiveMatch::Scoreboard do
|
2
|
+
let(:scoreboard) do
|
3
|
+
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
+
matches = test_client.live_matches
|
5
|
+
first_match = matches.first
|
6
|
+
first_match.scoreboard
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
specify "#duration" do
|
11
|
+
expect(scoreboard.duration).to eq 2840.2998046875
|
12
|
+
end
|
13
|
+
|
14
|
+
specify "#roshan_timer" do
|
15
|
+
expect(scoreboard.roshan_timer).to eq 278
|
16
|
+
end
|
17
|
+
|
18
|
+
xspecify "#radiant" do
|
19
|
+
expect(scoreboard.radiant).to eq
|
20
|
+
end
|
21
|
+
|
22
|
+
xspecify "#dire" do
|
23
|
+
expect(scoreboard.dire).to eq
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Dota::API::LiveMatch::Side do
|
2
|
+
let(:side) do
|
3
|
+
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
+
matches = test_client.live_matches
|
5
|
+
first_match = matches.first
|
6
|
+
first_match.dire
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
specify "#id" do
|
11
|
+
expect(side.id).to eq 1846074
|
12
|
+
end
|
13
|
+
|
14
|
+
specify "#name" do
|
15
|
+
expect(side.name).to eq "Haunti Gaming"
|
16
|
+
end
|
17
|
+
|
18
|
+
specify "#logo_id" do
|
19
|
+
expect(side.logo_id).to eq 547513665869798854
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "#complete?" do
|
23
|
+
expect(side.complete?).to eq false
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
describe Dota::API::LiveMatch do
|
2
|
+
let(:live_match) do
|
3
|
+
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
+
matches = test_client.live_matches
|
5
|
+
matches.first
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
specify "#id" do
|
10
|
+
expect(live_match.id).to eq 1080324763
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "#lobby_id" do
|
14
|
+
expect(live_match.lobby_id).to eq 23791470898109516
|
15
|
+
end
|
16
|
+
|
17
|
+
specify "#spectators_count" do
|
18
|
+
expect(live_match.spectators_count).to eq 58
|
19
|
+
end
|
20
|
+
|
21
|
+
specify "#league_id" do
|
22
|
+
expect(live_match.league_id).to eq 2091
|
23
|
+
end
|
24
|
+
|
25
|
+
specify "#stream_delay" do
|
26
|
+
expect(live_match.stream_delay).to eq 120
|
27
|
+
end
|
28
|
+
|
29
|
+
specify "#radiant_wins" do
|
30
|
+
expect(live_match.radiant_wins).to eq 0
|
31
|
+
end
|
32
|
+
|
33
|
+
specify "#dire_wins" do
|
34
|
+
expect(live_match.dire_wins).to eq 0
|
35
|
+
end
|
36
|
+
|
37
|
+
specify "#radiant" do
|
38
|
+
expect(live_match.radiant).to be_a Dota::API::LiveMatch::Side
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "#dire" do
|
42
|
+
expect(live_match.dire).to be_a Dota::API::LiveMatch::Side
|
43
|
+
end
|
44
|
+
|
45
|
+
specify "#series_type" do
|
46
|
+
expect(live_match.series_type).to eq 0
|
47
|
+
end
|
48
|
+
|
49
|
+
specify "#league_tier" do
|
50
|
+
expect(live_match.league_tier).to eq "Amateur"
|
51
|
+
end
|
52
|
+
|
53
|
+
specify "#players" do
|
54
|
+
players = live_match.players
|
55
|
+
expect(players.count).to eq 11
|
56
|
+
expect(players.first).to be_a Dota::API::LiveMatch::Player
|
57
|
+
end
|
58
|
+
|
59
|
+
specify "#scoreboard" do
|
60
|
+
expect(live_match.scoreboard).to be_a Dota::API::LiveMatch::Scoreboard
|
61
|
+
end
|
62
|
+
end
|