dota_api_wrapper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f788517f93d09fac1b53caf832e09c5deccda09e
4
- data.tar.gz: 55d1ae53567bf03693d912e44e7c61122bc17d5d
3
+ metadata.gz: 4f5b3571fc32ce22d011e8822aa52318e5204ec5
4
+ data.tar.gz: 26825239df53069c99b5004270666f93aed04497
5
5
  SHA512:
6
- metadata.gz: a6a10073798c17e9be4445b3f8a2eb212b1869eb2150efd81a7c7c271df9510cd1fda0db0537e8d50150601213cd104b28c31af954064d38c2aa72512f3261a8
7
- data.tar.gz: 92d2f65b6dd277d32eb86310c5946902d5a7574d9720a780a89f89fb487060d1df9930afa19db942cabb32fe2705d17eedd17e3d05e84697d2cd1d0d46ffa783
6
+ metadata.gz: 00e287952b9f15cba499a43b5d969cb2d9f868810aaed1298d67da9280d19dfe5c920d2695dd24d35ab0d1b0b1f7093fb0282ceffae5812b7fdf74bd26cd4934
7
+ data.tar.gz: 588f8098d0bdc5985afd939ce9d84ea46136dbe4137e1db6c41d9ad09dbd9d5551710a458720a073854b5fe5affe4bc54d55968836541da2d1967b8c521c0201
data/README.md CHANGED
@@ -36,6 +36,68 @@ This gem will read your key from an environment variable, so once you have it yo
36
36
 
37
37
  `heroes.find_by_id(25) => {"name"=>"npc_dota_hero_lina", "id"=>25, "localized_name"=>"Lina"}`
38
38
 
39
+ ### Items
40
+
41
+ `items = DotaApiWrapper::Item.new`
42
+
43
+ `items.find_by_id(25) => {"id"=>25, "name"=>"item_gloves", "cost"=>500, "secret_shop"=>0, "side_shop"=>1, "recipe"=>0, "localized_name"=>"Gloves of Haste"}`
44
+
45
+ ### Steam User's Summary
46
+
47
+ To get all the information of a player you need its 64bits account ID.
48
+
49
+ `player = DotaApiWrapper::Player.new(76561197997499174)`
50
+
51
+ Then the first time you access one of its attributes, all the information of the player will be fetched from the API.
52
+
53
+ Player object has the following information available:
54
+
55
+ {
56
+ "steamid"=>"76561197997499174",
57
+ "communityvisibilitystate"=>3,
58
+ "profilestate"=>1,
59
+ "personaname"=>"Kazooie",
60
+ "lastlogoff"=>1458409407,
61
+ "commentpermission"=>1,
62
+ "profileurl"=>"http://steamcommunity.com/id/fdzatone/",
63
+ "avatar"=>"https://steamcdn-a.akamaihd.net/steamcommunity/public/ima ges/avatars/fa/fa3c7d96ba6f8dc9d7b0820befcd83d53bb3208a.jpg",
64
+ "avatarmedium"=>"https://steamcdn-a.akamaihd.net/steamcommunity/publ ic/images/avatars/fa/fa3c7d96ba6f8dc9d7b0820befcd83d53bb3208a_medium .jpg",
65
+ "avatarfull"=>"https://steamcdn-a.akamaihd.net/steamcommunity/public /images/avatars/fa/fa3c7d96ba6f8dc9d7b0820befcd83d53bb3208a_full.jpg ",
66
+ "personastate"=>0,
67
+ "primaryclanid"=>"103582791431066484",
68
+ "timecreated"=>1206223343,
69
+ "personastateflags"=>0,
70
+ "loccountrycode"=>"ES",
71
+ "locstatecode"=>"51"
72
+ }
73
+
74
+ You can access every attribute method-like, for example:
75
+
76
+ player.personaname => 'Kazooie'
77
+
78
+ ### Matches
79
+
80
+ You can query the API in search of the collection of matches you need. For that purpose you can use the method `get_matches` of `DotaApiWrapper::Match` class.
81
+
82
+ api_result = DotaApiWrapper::Match.get_matches
83
+
84
+ `get_matches` Accepts the following options:
85
+
86
+ hero_id=<id> # Matches with a specific hero
87
+ game_mode=<mode> # Matches of a given mode
88
+ skill=<skill> # 0 for any, 1 for normal, 2 for high, 3 for very high skill (default is 0)
89
+ min_players=<count> # Minimum number of player
90
+ account_id=<id> # Search matches of the given ID (32-bit or 64-bit steam ID)
91
+ league_id=<id> # Matches of a league
92
+ start_at_match_id=<id> # Start the search at the indicated match id, descending
93
+ matches_requested=<n> # Maximum is 25 matches (default is 100)
94
+ tournament_games_only=<string> # Set to only show tournament games
95
+
96
+ Once you have your collection of matches you can instantiate a `Match` object to work with it.
97
+
98
+ match = DotaApiWrapper::Match.new(api_result['matches'].first)
99
+ match.radiant_win => true
100
+
39
101
  ## Development
40
102
 
41
103
  After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests. You can also run `rake console` for an interactive prompt that will allow you to experiment.
@@ -8,5 +8,10 @@ module DotaApiWrapper
8
8
  def get(uri, options)
9
9
  self.class.get(uri, options)
10
10
  end
11
+
12
+ def self.retrieve_info(action, options = {})
13
+ query_params = { 'key' => API_KEY }.merge(options)
14
+ get(action, query: query_params, headers: {})
15
+ end
11
16
  end
12
17
  end
@@ -0,0 +1,43 @@
1
+ require_relative 'base'
2
+
3
+ module DotaApiWrapper
4
+ class Match < Base
5
+ base_uri(BASE_URI + '/IDOTA2Match_570')
6
+
7
+ attr_accessor :match_info
8
+ attr_accessor :match_details
9
+
10
+ def initialize(match_info)
11
+ match_info.delete('players')
12
+ @match_info = match_info
13
+ end
14
+
15
+ # If the parameter name exists in the hash, it will be returned
16
+ # In other case in will raise an exception 'NoMethodError'
17
+ def method_missing(name, *args, &block)
18
+ if match_info.key?(name.to_s)
19
+ match_info[name.to_s]
20
+ elsif match_details.key?(name.to_s)
21
+ match_details[name.to_s]
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def match_details
28
+ @match_details ||= retrieve_details
29
+ end
30
+
31
+ def self.get_matches(options = {})
32
+ api_result = retrieve_info('/GetMatchHistory/V001', options)
33
+ return api_result['result'] unless api_result.empty?
34
+ end
35
+
36
+ private
37
+
38
+ def retrieve_details
39
+ api_result = self.class.retrieve_info('/GetMatchDetails/V001', match_id: match_id)
40
+ return api_result['result'] unless api_result.empty?
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module DotaApiWrapper
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dota_api_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -144,6 +144,7 @@ files:
144
144
  - lib/dota_api_wrapper/econ.rb
145
145
  - lib/dota_api_wrapper/hero.rb
146
146
  - lib/dota_api_wrapper/item.rb
147
+ - lib/dota_api_wrapper/match.rb
147
148
  - lib/dota_api_wrapper/player.rb
148
149
  - lib/dota_api_wrapper/version.rb
149
150
  homepage: ''
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  version: '0'
167
168
  requirements: []
168
169
  rubyforge_project:
169
- rubygems_version: 2.5.1
170
+ rubygems_version: 2.6.2
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Wrapper for Valve's DOTA 2 API.