battlenet-api 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -24
- data/lib/battlenet/api/d3_client.rb +11 -2
- data/lib/battlenet/api/sc2_client.rb +12 -0
- data/lib/battlenet/api/version.rb +1 -1
- data/lib/battlenet/modules/d3/data.rb +14 -14
- data/lib/battlenet/modules/d3/profile.rb +11 -10
- data/lib/battlenet/modules/sc2/data.rb +13 -6
- data/lib/battlenet/modules/sc2/ladder.rb +12 -4
- data/lib/battlenet/modules/sc2/profile.rb +18 -18
- data/lib/battlenet/modules/wow/achievement.rb +1 -2
- data/lib/battlenet/modules/wow/auction.rb +0 -1
- data/spec/d3/data_spec.rb +20 -0
- data/spec/d3/profile_spec.rb +19 -0
- data/spec/d3client_spec.rb +2 -6
- data/spec/sc2/data_spec.rb +19 -0
- data/spec/sc2/ladder_spec.rb +18 -0
- data/spec/sc2/profile_spec.rb +20 -0
- data/spec/sc2client_spec.rb +1 -6
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ae9075e2ca3a2e42b93143d7c97f3676250def
|
4
|
+
data.tar.gz: 16f7e1fdf7f6eaac2e0d3dda5ad7529a793c7fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5466d77ea061d7b5ddc5a9a2b0de7f7d3614e1cf1178cf7d28a8de73928554e5fd19084364e2bf719307a0cd7f93506097885f9dda678049377e0dbbfd6eec00
|
7
|
+
data.tar.gz: e5348c9e830d6173c460569e4bace47d8ae30c855758b28ce30a8d44aba803cf68c360706a970da1d56c419d8c295cf31b1b7c8b500bf40163413f709c3528d1
|
data/README.md
CHANGED
@@ -21,13 +21,13 @@ end
|
|
21
21
|
````ruby
|
22
22
|
client = Battlenet.WOWClient
|
23
23
|
|
24
|
-
achievement = client.achievement({:
|
25
|
-
auction_data = client.auction({:
|
26
|
-
character = client.character({:
|
24
|
+
achievement = client.achievement({achievement: 'achievement_id'})
|
25
|
+
auction_data = client.auction({realm: 'realm_id'})
|
26
|
+
character = client.character({realm: 'realm_id', character_name: 'character_name'})
|
27
27
|
|
28
28
|
# TODO: character methods
|
29
29
|
|
30
|
-
guild = client.guild({:
|
30
|
+
guild = client.guild({realm: 'realm', guild_name: 'guild_name'})
|
31
31
|
|
32
32
|
# TODO: guild methods
|
33
33
|
|
@@ -35,22 +35,22 @@ data = client.data
|
|
35
35
|
|
36
36
|
# TODO: data methods
|
37
37
|
|
38
|
-
item =
|
38
|
+
item = data.item({item: 'item_id'})
|
39
39
|
puts item.details
|
40
40
|
|
41
|
-
item =
|
41
|
+
item = data.item_set({item_set: 'item_set_id'})
|
42
42
|
puts item.details
|
43
43
|
|
44
|
-
pvp_leaderboards =
|
44
|
+
pvp_leaderboards = data.pvp_leaderboards({bracket: 'bracket'})
|
45
45
|
puts pvp_leaderboards.details
|
46
46
|
|
47
|
-
quest =
|
47
|
+
quest = data.quest({quest: 'quest_id'})
|
48
48
|
puts quest.details
|
49
49
|
|
50
|
-
recipe =
|
50
|
+
recipe = data.recipe({recipe: 'recipe_id'})
|
51
51
|
puts recipe.details
|
52
52
|
|
53
|
-
spell =
|
53
|
+
spell = data.spell({spell: 'spell_id'})
|
54
54
|
puts spell.details
|
55
55
|
|
56
56
|
````
|
@@ -61,13 +61,15 @@ puts spell.details
|
|
61
61
|
client = Battlenet.D3Client
|
62
62
|
|
63
63
|
#Available Methods
|
64
|
+
data = client.data
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
item = data.item({item: 'item_id'})
|
67
|
+
follower = data.follower({follower: 'follower_id'})
|
68
|
+
artisan = data.artisan({artisan: 'artisan_id'})
|
68
69
|
|
69
|
-
client.
|
70
|
-
|
70
|
+
profile = client.profile({battletag: 'battletag'})
|
71
|
+
puts profile.career
|
72
|
+
puts profile.hero(hero_id)
|
71
73
|
````
|
72
74
|
|
73
75
|
### Starcraft 2 Client
|
@@ -76,15 +78,18 @@ client.hero_profile(battletag,hero_id)
|
|
76
78
|
client = Battlenet.S2Client
|
77
79
|
|
78
80
|
#Available Methods
|
81
|
+
data = client.data
|
79
82
|
|
80
|
-
|
81
|
-
|
83
|
+
achievements = data.achievements
|
84
|
+
rewards = data.rewards
|
82
85
|
|
83
|
-
client.ladder(ladder_id)
|
86
|
+
ladder = client.ladder({ladder_id: 'ladder_id'})
|
87
|
+
puts ladder.details
|
84
88
|
|
85
|
-
client.profile(id, region, name)
|
86
|
-
|
87
|
-
|
89
|
+
profile = client.profile({id: 'id', region: 'region', name: 'name'})
|
90
|
+
puts profile.details
|
91
|
+
puts profile.ladders
|
92
|
+
puts profile.match_history
|
88
93
|
````
|
89
94
|
|
90
95
|
|
@@ -92,6 +97,3 @@ client.profile_match_history(id, region, name)
|
|
92
97
|
|
93
98
|
- Community OAuth Profile APIs
|
94
99
|
- Account APIs
|
95
|
-
- Unit Tests for All APIs
|
96
|
-
|
97
|
-
- Refactor Client Code to Utilize OpenStruct on JSON Responses
|
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'battlenet/api/client'
|
2
2
|
|
3
|
-
|
3
|
+
require 'battlenet/modules/d3/profile'
|
4
|
+
require 'battlenet/modules/d3/data'
|
4
5
|
|
5
6
|
module Battlenet
|
6
7
|
|
@@ -15,6 +16,14 @@ module Battlenet
|
|
15
16
|
super(client_settings)
|
16
17
|
end
|
17
18
|
|
19
|
+
def profile(options = {})
|
20
|
+
merge_options_and_return_obj(options, Battlenet::D3::Profile)
|
21
|
+
end
|
22
|
+
|
23
|
+
def data(options = {})
|
24
|
+
merge_options_and_return_obj(options, Battlenet::D3::Data)
|
25
|
+
end
|
26
|
+
|
18
27
|
end
|
19
28
|
|
20
29
|
end
|
@@ -17,6 +17,18 @@ module Battlenet
|
|
17
17
|
super(client_settings)
|
18
18
|
end
|
19
19
|
|
20
|
+
def data(options = {})
|
21
|
+
merge_options_and_return_obj(options, Battlenet::SC2::Data)
|
22
|
+
end
|
23
|
+
|
24
|
+
def ladder(options = {})
|
25
|
+
merge_options_and_return_obj(options, Battlenet::SC2::Ladder)
|
26
|
+
end
|
27
|
+
|
28
|
+
def profile(options = {})
|
29
|
+
merge_options_and_return_obj(options, Battlenet::SC2::Profile)
|
30
|
+
end
|
31
|
+
|
20
32
|
end
|
21
33
|
|
22
34
|
end
|
@@ -2,22 +2,22 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Battlenet
|
4
4
|
module D3
|
5
|
-
|
6
|
-
|
5
|
+
class Data < Battlenet::APIResponse
|
6
|
+
def initialize(options={})
|
7
|
+
super(options)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def data_follower(follower, options = {})
|
12
|
-
follower = URI.escape follower
|
13
|
-
|
14
|
-
get "/data/follower/#{follower}", options
|
15
|
-
end
|
10
|
+
def item(item, options = {})
|
11
|
+
get_data("/data/item/#{item}", options)
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
def follower(follower, options = {})
|
15
|
+
get_data("/data/follower/#{follower}", options)
|
16
|
+
end
|
19
17
|
|
20
|
-
|
18
|
+
def artisan(artisan, options = {})
|
19
|
+
get_data("/data/artiasn/#{artisan}", options)
|
20
|
+
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -2,17 +2,18 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Battlenet
|
4
4
|
module D3
|
5
|
-
|
6
|
-
|
5
|
+
class Profile < Battlenet::APIResponse
|
6
|
+
def initialize(options={})
|
7
|
+
super(options)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def hero_profile(battletag, id, options = {})
|
12
|
-
battletag = URI.escape battletag
|
13
|
-
id = URI.escape id
|
10
|
+
def career(battletag, options = {})
|
11
|
+
get_data("/profile/#{battletag}", options)
|
12
|
+
end
|
14
13
|
|
15
|
-
|
14
|
+
def hero(battletag, hero_id, options = {})
|
15
|
+
get_data("/profile/#{battletag}/hero/#{hero_id}", options)
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
|
-
end
|
19
|
+
end
|
@@ -2,12 +2,19 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Battlenet
|
4
4
|
module SC2
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class Data < Battlenet::APIResponse
|
6
|
+
def initialize(options={})
|
7
|
+
super(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def achievements(options = {})
|
11
|
+
get_data("/data/achievements", options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def rewards(options = {})
|
15
|
+
get_data("/data/rewards", options)
|
16
|
+
end
|
8
17
|
|
9
|
-
def rewards(options = {})
|
10
|
-
get "/data/rewards", options
|
11
18
|
end
|
12
19
|
end
|
13
|
-
end
|
20
|
+
end
|
@@ -2,10 +2,18 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Battlenet
|
4
4
|
module SC2
|
5
|
-
|
6
|
-
|
5
|
+
class Ladder < Battlenet::APIResponse
|
6
|
+
def initialize(options={})
|
7
|
+
@ladder_id = options.delete(:ladder_id)
|
8
|
+
@endpoint = "/ladder/#{@ladder_id}"
|
9
|
+
|
10
|
+
super(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def details(options = {})
|
14
|
+
get_data(@endpoint, options)
|
15
|
+
end
|
7
16
|
|
8
|
-
get "/ladder/#{id}", options
|
9
17
|
end
|
10
18
|
end
|
11
|
-
end
|
19
|
+
end
|
@@ -2,28 +2,28 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Battlenet
|
4
4
|
module SC2
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
class Profile < Battlenet::APIResponse
|
6
|
+
def initialize(options={})
|
7
|
+
@profile_id = options.delete(:id)
|
8
|
+
@region = options.delete(:region)
|
9
|
+
@name = options.delete(:name)
|
9
10
|
|
10
|
-
|
11
|
-
end
|
11
|
+
@endpoint = "/profile/#{@profile_id}/#{@region}/#{@name}"
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
region = URI.escape region
|
16
|
-
name = URI.escape name
|
13
|
+
super(options)
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
def details(options = {})
|
17
|
+
get_data(@endpoint, options)
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
name = URI.escape name
|
20
|
+
def ladders(options = {})
|
21
|
+
get_data("#{@endpoint}/ladders", options)
|
22
|
+
end
|
25
23
|
|
26
|
-
|
24
|
+
def match_history(options = {})
|
25
|
+
get_data("#{@endpoint}/matches", options)
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::D3::Data do
|
4
|
+
|
5
|
+
context "when looking up data" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@d3_client = Battlenet.D3Client
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:item) }
|
17
|
+
it { should respond_to(:follower) }
|
18
|
+
it { should respond_to(:artisan) }
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::D3::Profile do
|
4
|
+
|
5
|
+
context "when looking up profile" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@d3_client = Battlenet.D3Client
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:career) }
|
17
|
+
it { should respond_to(:hero) }
|
18
|
+
|
19
|
+
end
|
data/spec/d3client_spec.rb
CHANGED
@@ -13,11 +13,7 @@ describe Battlenet::D3Client do
|
|
13
13
|
expect(c.api_key).to eq(ENV['BATTLENET_API_KEY'])
|
14
14
|
end
|
15
15
|
|
16
|
-
it { should respond_to(:
|
17
|
-
it { should respond_to(:
|
18
|
-
it { should respond_to(:data_artisan) }
|
19
|
-
|
20
|
-
it { should respond_to(:career_profile) }
|
21
|
-
it { should respond_to(:hero_profile) }
|
16
|
+
it { should respond_to(:data) }
|
17
|
+
it { should respond_to(:profile) }
|
22
18
|
|
23
19
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::SC2::Data do
|
4
|
+
|
5
|
+
context "when looking up data" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@sc2_client = Battlenet.SC2Client
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:achievements) }
|
17
|
+
it { should respond_to(:rewards) }
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::SC2::Ladder do
|
4
|
+
|
5
|
+
context "when looking up ladder" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@sc2_client = Battlenet.SC2Client
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:details) }
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::SC2::Profile do
|
4
|
+
|
5
|
+
context "when looking up profile" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@sc2_client = Battlenet.SC2Client
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:details) }
|
17
|
+
it { should respond_to(:ladders) }
|
18
|
+
it { should respond_to(:match_history) }
|
19
|
+
|
20
|
+
end
|
data/spec/sc2client_spec.rb
CHANGED
@@ -13,13 +13,8 @@ describe Battlenet::SC2Client do
|
|
13
13
|
expect(c.api_key).to eq(ENV['BATTLENET_API_KEY'])
|
14
14
|
end
|
15
15
|
|
16
|
-
it { should respond_to(:
|
17
|
-
it { should respond_to(:rewards) }
|
18
|
-
|
16
|
+
it { should respond_to(:data) }
|
19
17
|
it { should respond_to(:ladder) }
|
20
|
-
|
21
18
|
it { should respond_to(:profile) }
|
22
|
-
it { should respond_to(:profile_ladders) }
|
23
|
-
it { should respond_to(:profile_match_history) }
|
24
19
|
|
25
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battlenet-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- goodcodeguy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -177,7 +177,12 @@ files:
|
|
177
177
|
- lib/battlenet/modules/wow/recipe.rb
|
178
178
|
- lib/battlenet/modules/wow/spell.rb
|
179
179
|
- spec/battlenetapi_spec.rb
|
180
|
+
- spec/d3/data_spec.rb
|
181
|
+
- spec/d3/profile_spec.rb
|
180
182
|
- spec/d3client_spec.rb
|
183
|
+
- spec/sc2/data_spec.rb
|
184
|
+
- spec/sc2/ladder_spec.rb
|
185
|
+
- spec/sc2/profile_spec.rb
|
181
186
|
- spec/sc2client_spec.rb
|
182
187
|
- spec/spec_helper.rb
|
183
188
|
- spec/wow/character_spec.rb
|
@@ -203,13 +208,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
208
|
version: '0'
|
204
209
|
requirements: []
|
205
210
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.4.5
|
211
|
+
rubygems_version: 2.4.5.1
|
207
212
|
signing_key:
|
208
213
|
specification_version: 4
|
209
214
|
summary: Battlenet Client API
|
210
215
|
test_files:
|
211
216
|
- spec/battlenetapi_spec.rb
|
217
|
+
- spec/d3/data_spec.rb
|
218
|
+
- spec/d3/profile_spec.rb
|
212
219
|
- spec/d3client_spec.rb
|
220
|
+
- spec/sc2/data_spec.rb
|
221
|
+
- spec/sc2/ladder_spec.rb
|
222
|
+
- spec/sc2/profile_spec.rb
|
213
223
|
- spec/sc2client_spec.rb
|
214
224
|
- spec/spec_helper.rb
|
215
225
|
- spec/wow/character_spec.rb
|