dotka 1.0.1

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 +7 -0
  2. data/lib/dotka.rb +39 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: abb5b2bdcba7877102dbf764ae789edaa8f7b61e
4
+ data.tar.gz: 254045feb91738337af980b81167c9b9f1c95c0f
5
+ SHA512:
6
+ metadata.gz: c9dbef1e0536a0b10d567426fe03530e1175baff4a46005dd58a3447577294e02094e84edfbef95695110f9a4a98beb510ae71735ffc5bb175174718b668e3c1
7
+ data.tar.gz: 6df151b40a521ee39d08c6a2967b1f88e6218b74ef39a1dc8c76d04a9374726b8de65dbbe47f144fe1cb47e046886a48e121cb7abe088b176ff78ea7d424b663
data/lib/dotka.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "rest-client"
2
+ require_relative "dotka/match"
3
+ require "json"
4
+
5
+ class Dotka
6
+ def initialize
7
+ @key = nil
8
+ end
9
+ def set_api_key key
10
+ @key = key
11
+ end
12
+ def get_api_key
13
+ @key
14
+ end
15
+ def match id
16
+ raise "Please set up the API key!" unless not @key.nil?
17
+ response = RestClient.get(
18
+ "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001",
19
+ {"params" => {"key" => @key, "match_id" => id}}
20
+ )
21
+ raise "Can not load a match with ID #{id}." unless response.code == 200
22
+ DotkaM::Match.new(JSON.parse(response.to_str)["result"])
23
+ end
24
+ def matches account_id, conditions = {}
25
+ raise "Please set up the API key!" unless not @key.nil?
26
+ response = RestClient.get(
27
+ "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001",
28
+ {
29
+ "params" => {"key" => @key, "account_id" => account_id}.merge(conditions)
30
+ }
31
+ )
32
+ raise "Can not load matches for account ID #{account_id}." unless response.code == 200
33
+ matches = Array.new
34
+ JSON.parse(response.to_str)["result"]["matches"].each { |match|
35
+ matches.push DotkaM::Match.new(match)
36
+ }
37
+ matches
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dotka
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - bound1ess
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Makes interaction with Dota 2 WebAPI easy
14
+ email: bound1ess.dev@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/dotka.rb
20
+ homepage: https://github.com/bound1ess/dotka
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.4
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Dota 2 WebAPI Wrapper
44
+ test_files: []