dota_api_wrapper 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/dota_api_wrapper/resource.rb +35 -0
- data/lib/dota_api_wrapper/version.rb +1 -1
- metadata +3 -5
- data/lib/dota_api_wrapper/econ.rb +0 -13
- data/lib/dota_api_wrapper/hero.rb +0 -28
- data/lib/dota_api_wrapper/item.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fecc47c82194f8463fc05272fb7a313ccb866ae9
|
4
|
+
data.tar.gz: e81fb8f619ac86e0614114f014aad024303c55e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 014817570948143b31089182cc33ca9aa15bbdbd22f5c5a9c06a61be4cd48e85bc87d45dc9fb5153e171a74cf331f6689d0f751b8a14e8cb2100d8608fc0f296
|
7
|
+
data.tar.gz: 04f522074fd4ccd9a3375e38ff2a410930c29e23016388f8396e9891e3c46a8655c33497421c63db1e8c6129c79e372bce0747aa4eadc9dad1fdabf33a2b36d2
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
[![Build Status](https://travis-ci.org/epergo/dota_api_wrapper.svg?branch=master)](https://travis-ci.org/epergo/dota_api_wrapper)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/epergo/dota_api_wrapper/badges/gpa.svg)](https://codeclimate.com/github/epergo/dota_api_wrapper)
|
4
4
|
[![Test Coverage](https://codeclimate.com/github/epergo/dota_api_wrapper/badges/coverage.svg)](https://codeclimate.com/github/epergo/dota_api_wrapper/coverage)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/dota_api_wrapper.svg)](https://badge.fury.io/rb/dota_api_wrapper)
|
5
6
|
|
6
7
|
|
7
8
|
## Installation
|
@@ -32,15 +33,15 @@ This gem will read your key from an environment variable, so once you have it yo
|
|
32
33
|
|
33
34
|
### Heroes
|
34
35
|
|
35
|
-
`heroes = DotaApiWrapper::
|
36
|
+
`heroes = DotaApiWrapper::Resource.retrieve_heroes`
|
36
37
|
|
37
|
-
`heroes
|
38
|
+
`heroes[56] => {"name"=>"npc_dota_hero_clinkz", "id"=>56, "localized_name"=>"Clinkz"}`
|
38
39
|
|
39
40
|
### Items
|
40
41
|
|
41
|
-
`items = DotaApiWrapper::
|
42
|
+
`items = DotaApiWrapper::Resource.retrieve_items
|
42
43
|
|
43
|
-
`items
|
44
|
+
`items[25] => {"id"=>25, "name"=>"item_gloves", "cost"=>500, "secret_shop"=>0, "side_shop"=>1, "recipe"=>0, "localized_name"=>"Gloves of Haste"}`
|
44
45
|
|
45
46
|
### Steam User's Summary
|
46
47
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module DotaApiWrapper
|
4
|
+
class Resource < Base
|
5
|
+
base_uri(BASE_URI + '/IEconDOTA2_570')
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def retrieve_heroes(language = 'en_us')
|
9
|
+
retrieve_resource('heroes', language)
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve_items(language = 'en_us')
|
13
|
+
retrieve_resource('items', language)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def retrieve_resource(resource, language = 'en_us')
|
19
|
+
return { error: 'specify a resource: "heroes" "items"' } unless resource
|
20
|
+
|
21
|
+
query_params = { 'key' => self::API_KEY, 'language' => language }
|
22
|
+
action = resource == 'items' ? '/GetGameItems/v0001' : '/GetHeroes/v0001'
|
23
|
+
|
24
|
+
api_result = get(action, query: query_params, headers: {})
|
25
|
+
|
26
|
+
return if api_result.empty?
|
27
|
+
|
28
|
+
res = {}
|
29
|
+
api_result['result'][resource].each { |i| res[i['id']] = i }
|
30
|
+
|
31
|
+
res
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -141,11 +141,9 @@ files:
|
|
141
141
|
- dota_api_wrapper.gemspec
|
142
142
|
- lib/dota_api_wrapper.rb
|
143
143
|
- lib/dota_api_wrapper/base.rb
|
144
|
-
- lib/dota_api_wrapper/econ.rb
|
145
|
-
- lib/dota_api_wrapper/hero.rb
|
146
|
-
- lib/dota_api_wrapper/item.rb
|
147
144
|
- lib/dota_api_wrapper/match.rb
|
148
145
|
- lib/dota_api_wrapper/player.rb
|
146
|
+
- lib/dota_api_wrapper/resource.rb
|
149
147
|
- lib/dota_api_wrapper/version.rb
|
150
148
|
homepage: ''
|
151
149
|
licenses: []
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative 'econ'
|
2
|
-
|
3
|
-
module DotaApiWrapper
|
4
|
-
class Hero < Econ
|
5
|
-
attr_accessor :heroes
|
6
|
-
|
7
|
-
def initialize(lang = 'en_us')
|
8
|
-
super(lang)
|
9
|
-
@heroes = retrieve_heroes
|
10
|
-
end
|
11
|
-
|
12
|
-
def retrieve_heroes
|
13
|
-
query_params = { 'key' => API_KEY, 'language' => language }
|
14
|
-
api_result = get('/GetHeroes/v0001', query: query_params, headers: {})
|
15
|
-
|
16
|
-
return if api_result.empty?
|
17
|
-
|
18
|
-
res = {}
|
19
|
-
api_result['result']['heroes'].each { |a| res[a['id']] = a }
|
20
|
-
|
21
|
-
res
|
22
|
-
end
|
23
|
-
|
24
|
-
def find_by_id(id)
|
25
|
-
heroes[id]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require_relative 'econ'
|
2
|
-
|
3
|
-
module DotaApiWrapper
|
4
|
-
class Item < Econ
|
5
|
-
attr_accessor :items
|
6
|
-
|
7
|
-
def initialize(lang = 'en_us')
|
8
|
-
super(lang)
|
9
|
-
@items = retrieve_items
|
10
|
-
end
|
11
|
-
|
12
|
-
def retrieve_items
|
13
|
-
query_params = { 'key' => API_KEY, 'language' => language }
|
14
|
-
api_result = get('/GetGameItems/v0001', query: query_params, headers: {})
|
15
|
-
|
16
|
-
return if api_result.empty?
|
17
|
-
|
18
|
-
res = {}
|
19
|
-
api_result['result']['items'].each { |i| res[i['id']] = i }
|
20
|
-
|
21
|
-
res
|
22
|
-
end
|
23
|
-
|
24
|
-
def find_by_id(id)
|
25
|
-
items[id]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|