battlenet-api 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/README.md +2 -2
- data/battlenet-api.gemspec +3 -0
- data/examples/sandbox.rb +1 -1
- data/lib/battlenet/api/api_response.rb +2 -1
- data/lib/battlenet/api/client.rb +2 -4
- data/lib/battlenet/api/version.rb +1 -1
- data/lib/battlenet/api/wow_client.rb +6 -6
- data/lib/battlenet/modules/wow/{character_profile.rb → character.rb} +1 -1
- data/lib/battlenet/modules/wow/{guild_profile.rb → guild.rb} +1 -1
- data/spec/battlenetapi_spec.rb +2 -7
- data/spec/d3client_spec.rb +3 -3
- data/spec/sc2client_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -0
- data/spec/wow/character_spec.rb +63 -0
- data/spec/wow/guild_spec.rb +22 -0
- data/spec/wowclient_spec.rb +5 -5
- metadata +53 -9
- data/spec/wow/characterprofile_spec.rb +0 -24
- data/spec/wow/guildprofile_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abf4010781883ec5d265c7c5afc9800b6d9687c
|
4
|
+
data.tar.gz: 774f81c62b4c50d3604553ab75ea8587d5a1d348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23d179f18eee8a09c681c9adb6a0293d52ef111ef0922306522013f3a9f0f225238376cb5523020c6286e29f8af924b3f026469d2bc215241859727f8e79cf0
|
7
|
+
data.tar.gz: 8bd5eaca8a678377abfbc4034b0c8f364c0fc1bb2a5bf4ec41130533b41998e8c9d00805d1a521e8990135b5118dcd8985ad63930494d3fe5df219a11e34e76a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -23,11 +23,11 @@ client = Battlenet.WOWClient
|
|
23
23
|
|
24
24
|
achievement = client.achievement({:achievement => 'achievement_id'})
|
25
25
|
auction_data = client.auction({:realm => 'realm'})
|
26
|
-
character = client.
|
26
|
+
character = client.character({:realm => 'realm', :character_name => 'character_name'})
|
27
27
|
|
28
28
|
# TODO: character methods
|
29
29
|
|
30
|
-
guild = client.
|
30
|
+
guild = client.guild({:realm => 'realm', :guild_name => 'guild_name'})
|
31
31
|
|
32
32
|
# TODO: guild methods
|
33
33
|
|
data/battlenet-api.gemspec
CHANGED
@@ -25,4 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.1"
|
28
|
+
spec.add_development_dependency "dotenv"
|
29
|
+
spec.add_development_dependency "vcr"
|
30
|
+
spec.add_development_dependency "webmock"
|
28
31
|
end
|
data/examples/sandbox.rb
CHANGED
data/lib/battlenet/api/client.rb
CHANGED
@@ -16,9 +16,7 @@ module Battlenet
|
|
16
16
|
Configuration::OPTIONS_KEYS.each do |key|
|
17
17
|
send("#{key}=", options[key])
|
18
18
|
end
|
19
|
-
|
20
19
|
self.class.base_uri "https://#{domain}#{endpoint}"
|
21
|
-
|
22
20
|
end
|
23
21
|
|
24
22
|
def domain
|
@@ -40,7 +38,7 @@ module Battlenet
|
|
40
38
|
|
41
39
|
def endpoint
|
42
40
|
raise "Invalid Game Endpoint" if @endpoint == nil
|
43
|
-
|
41
|
+
@endpoint
|
44
42
|
end
|
45
43
|
|
46
44
|
def get(path, params = {})
|
@@ -59,7 +57,7 @@ module Battlenet
|
|
59
57
|
options[:query].merge!({ :apikey => @api_key })
|
60
58
|
end
|
61
59
|
|
62
|
-
response = self.class.send(verb, path, options)
|
60
|
+
response = self.class.send(verb, Addressable::URI.encode(path), options)
|
63
61
|
end
|
64
62
|
|
65
63
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'battlenet/api/client'
|
2
2
|
|
3
|
-
require 'battlenet/modules/wow/
|
4
|
-
require 'battlenet/modules/wow/
|
3
|
+
require 'battlenet/modules/wow/character'
|
4
|
+
require 'battlenet/modules/wow/guild'
|
5
5
|
require 'battlenet/modules/wow/item'
|
6
6
|
require 'battlenet/modules/wow/item_set'
|
7
7
|
require 'battlenet/modules/wow/achievement'
|
@@ -24,12 +24,12 @@ module Battlenet
|
|
24
24
|
super(client_settings)
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
merge_options_and_return_obj(options, Battlenet::WOW::
|
27
|
+
def character(options = {})
|
28
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Character)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
merge_options_and_return_obj(options, Battlenet::WOW::
|
31
|
+
def guild(options = {})
|
32
|
+
merge_options_and_return_obj(options, Battlenet::WOW::Guild)
|
33
33
|
end
|
34
34
|
|
35
35
|
def item(options = {})
|
data/spec/battlenetapi_spec.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Battlenet::Client do
|
4
4
|
context "when special characters are in realm names" do
|
5
5
|
before do
|
6
6
|
Battlenet.configure do |config|
|
7
|
-
config.api_key = '
|
7
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
8
8
|
config.region = :eu
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
12
|
-
it "should escape spaces in realm names" do
|
13
|
-
c = Battlenet::Client.new({domain: 'http://www.test.com', endpoint: "/emerald dream/mal'ganis"})
|
14
|
-
expect(c.endpoint).to eq('/emerald%20dream/mal\'ganis')
|
15
|
-
end
|
16
11
|
end
|
17
12
|
end
|
data/spec/d3client_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Battlenet::D3Client do
|
4
4
|
before(:all) do
|
5
5
|
Battlenet.configure do |config|
|
6
|
-
config.api_key = '
|
6
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
7
7
|
config.region = :us
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should pass the api key to the d3 client" do
|
12
12
|
c = Battlenet.D3Client
|
13
|
-
expect(c.api_key).to eq('
|
13
|
+
expect(c.api_key).to eq(ENV['BATTLENET_API_KEY'])
|
14
14
|
end
|
15
15
|
|
16
16
|
it { should respond_to(:data_item) }
|
data/spec/sc2client_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Battlenet::SC2Client do
|
4
4
|
before(:all) do
|
5
5
|
Battlenet.configure do |config|
|
6
|
-
config.api_key = '
|
6
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
7
7
|
config.region = :us
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should pass the api key to the SC2 client" do
|
12
12
|
c = Battlenet.SC2Client
|
13
|
-
expect(c.api_key).to eq('
|
13
|
+
expect(c.api_key).to eq(ENV['BATTLENET_API_KEY'])
|
14
14
|
end
|
15
15
|
|
16
16
|
it { should respond_to(:achievements) }
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::WOW::Character do
|
4
|
+
|
5
|
+
context "when looking up a character" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@wow_client = Battlenet.WOWClient
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to find 'Silverwinter' on 'Sargeras'" do
|
15
|
+
character = @wow_client.character({:realm => 'sargeras', :character_name => 'Silverwinter'})
|
16
|
+
VCR.use_cassette('character/profile') do
|
17
|
+
expect(character.profile['name']).to eq('Silverwinter')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be able to find 'whispä' on 'frostmourne' (handle foreign characters)" do
|
22
|
+
character = @wow_client.character({:realm => 'frostmourne', :character_name => 'whispä'})
|
23
|
+
VCR.use_cassette('character/profile_whispä') do
|
24
|
+
expect(character.profile['name']).to eq('Whispä')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to find 'pftpft' on 'emerald dream' (handle spaces)" do
|
29
|
+
character = @wow_client.character({:realm => 'emerald dream', :character_name => 'pftpft'})
|
30
|
+
VCR.use_cassette('character/profile_pft') do
|
31
|
+
expect(character.profile['name']).to eq('Pftpft')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not be able to find 'ThisCharacterShouldntExist' on 'Sargeras'" do
|
36
|
+
character = @wow_client.character({realm: 'sargeras', character_name: 'ThisCharacterShouldntExist'})
|
37
|
+
VCR.use_cassette('character/invalid_character') do
|
38
|
+
expect(character.profile['reason']).to eq('Character not found.')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
it { should respond_to(:profile) }
|
45
|
+
it { should respond_to(:achievements) }
|
46
|
+
it { should respond_to(:feed) }
|
47
|
+
it { should respond_to(:appearance) }
|
48
|
+
it { should respond_to(:guild) }
|
49
|
+
it { should respond_to(:hunter_pets) }
|
50
|
+
it { should respond_to(:pets) }
|
51
|
+
it { should respond_to(:items) }
|
52
|
+
it { should respond_to(:mounts) }
|
53
|
+
it { should respond_to(:pet_slots) }
|
54
|
+
it { should respond_to(:progression) }
|
55
|
+
it { should respond_to(:pvp) }
|
56
|
+
it { should respond_to(:quests) }
|
57
|
+
it { should respond_to(:reputation) }
|
58
|
+
it { should respond_to(:stats) }
|
59
|
+
it { should respond_to(:talents) }
|
60
|
+
it { should respond_to(:titles) }
|
61
|
+
it { should respond_to(:audit) }
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Battlenet::WOW::Guild do
|
4
|
+
|
5
|
+
context "when looking up a guild" do
|
6
|
+
before do
|
7
|
+
Battlenet.configure do |config|
|
8
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
9
|
+
config.region = :us
|
10
|
+
end
|
11
|
+
@wow_client = Battlenet.WOWClient
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
it { should respond_to(:profile) }
|
17
|
+
it { should respond_to(:achievements) }
|
18
|
+
it { should respond_to(:members) }
|
19
|
+
it { should respond_to(:news) }
|
20
|
+
it { should respond_to(:challenge) }
|
21
|
+
|
22
|
+
end
|
data/spec/wowclient_spec.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Battlenet::WOWClient do
|
4
4
|
before(:all) do
|
5
5
|
Battlenet.configure do |config|
|
6
|
-
config.api_key = '
|
6
|
+
config.api_key = ENV['BATTLENET_API_KEY']
|
7
7
|
config.region = :us
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should pass the api key to the wow client" do
|
12
12
|
c = Battlenet.WOWClient
|
13
|
-
expect(c.api_key).to eq('
|
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(:
|
16
|
+
it { should respond_to(:character) }
|
17
|
+
it { should respond_to(:guild) }
|
18
18
|
it { should respond_to(:item) }
|
19
19
|
it { should respond_to(:item_set) }
|
20
20
|
it { should respond_to(:achievement) }
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- goodcodeguy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -94,6 +94,48 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: dotenv
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
97
139
|
description: API Wrapper for the Battlenet API
|
98
140
|
email:
|
99
141
|
- goodcodeguy@gmail.com
|
@@ -124,9 +166,9 @@ files:
|
|
124
166
|
- lib/battlenet/modules/sc2/profile.rb
|
125
167
|
- lib/battlenet/modules/wow/achievement.rb
|
126
168
|
- lib/battlenet/modules/wow/auction.rb
|
127
|
-
- lib/battlenet/modules/wow/
|
169
|
+
- lib/battlenet/modules/wow/character.rb
|
128
170
|
- lib/battlenet/modules/wow/data.rb
|
129
|
-
- lib/battlenet/modules/wow/
|
171
|
+
- lib/battlenet/modules/wow/guild.rb
|
130
172
|
- lib/battlenet/modules/wow/item.rb
|
131
173
|
- lib/battlenet/modules/wow/item_set.rb
|
132
174
|
- lib/battlenet/modules/wow/pvp_leaderboard.rb
|
@@ -137,8 +179,9 @@ files:
|
|
137
179
|
- spec/battlenetapi_spec.rb
|
138
180
|
- spec/d3client_spec.rb
|
139
181
|
- spec/sc2client_spec.rb
|
140
|
-
- spec/
|
141
|
-
- spec/wow/
|
182
|
+
- spec/spec_helper.rb
|
183
|
+
- spec/wow/character_spec.rb
|
184
|
+
- spec/wow/guild_spec.rb
|
142
185
|
- spec/wowclient_spec.rb
|
143
186
|
homepage: https://github.com/goodcodeguy/battlenet-api
|
144
187
|
licenses:
|
@@ -160,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
203
|
version: '0'
|
161
204
|
requirements: []
|
162
205
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.4.5
|
206
|
+
rubygems_version: 2.4.5
|
164
207
|
signing_key:
|
165
208
|
specification_version: 4
|
166
209
|
summary: Battlenet Client API
|
@@ -168,6 +211,7 @@ test_files:
|
|
168
211
|
- spec/battlenetapi_spec.rb
|
169
212
|
- spec/d3client_spec.rb
|
170
213
|
- spec/sc2client_spec.rb
|
171
|
-
- spec/
|
172
|
-
- spec/wow/
|
214
|
+
- spec/spec_helper.rb
|
215
|
+
- spec/wow/character_spec.rb
|
216
|
+
- spec/wow/guild_spec.rb
|
173
217
|
- spec/wowclient_spec.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'battlenet/api'
|
2
|
-
|
3
|
-
describe Battlenet::WOW::CharacterProfile do
|
4
|
-
|
5
|
-
it { should respond_to(:profile) }
|
6
|
-
it { should respond_to(:achievements) }
|
7
|
-
it { should respond_to(:feed) }
|
8
|
-
it { should respond_to(:appearance) }
|
9
|
-
it { should respond_to(:guild) }
|
10
|
-
it { should respond_to(:hunter_pets) }
|
11
|
-
it { should respond_to(:pets) }
|
12
|
-
it { should respond_to(:items) }
|
13
|
-
it { should respond_to(:mounts) }
|
14
|
-
it { should respond_to(:pet_slots) }
|
15
|
-
it { should respond_to(:progression) }
|
16
|
-
it { should respond_to(:pvp) }
|
17
|
-
it { should respond_to(:quests) }
|
18
|
-
it { should respond_to(:reputation) }
|
19
|
-
it { should respond_to(:stats) }
|
20
|
-
it { should respond_to(:talents) }
|
21
|
-
it { should respond_to(:titles) }
|
22
|
-
it { should respond_to(:audit) }
|
23
|
-
|
24
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'battlenet/api'
|
2
|
-
|
3
|
-
describe Battlenet::WOW::GuildProfile do
|
4
|
-
|
5
|
-
it { should respond_to(:profile) }
|
6
|
-
it { should respond_to(:achievements) }
|
7
|
-
it { should respond_to(:members) }
|
8
|
-
it { should respond_to(:news) }
|
9
|
-
it { should respond_to(:challenge) }
|
10
|
-
|
11
|
-
end
|