bnet_api 0.1.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTdlMGYxMjczNzZkMjJkYjQ4OGNkOWU0ZWNlMmUxZTBkMWVhMDVkNg==
5
+ data.tar.gz: !binary |-
6
+ Njk1NmI3MmU2NDdhNWM0MTk5NGViMjBmZjAyNTAwMWJhNGY1OTJlOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Mzk4NDBmMDVlZWQzZDgyNDE1YjI1ZDNjZjVlOTdjYzM2N2E4ZDE3YjNmZmJl
10
+ OTg4M2M1ZThkZWNhMTVlOTI0YzZlZDQ5ZjZlNGEyODc3MWI0MWQzNDJjNTcz
11
+ OTFkZjIxNDQzYTYxNTUyNWRjOGNhN2QwMDAxMjc0MjA0YjQ5NWQ=
12
+ data.tar.gz: !binary |-
13
+ ZGY5MWM0YzU2OGExNWFlZGM5ZTkzZmQyMzMxNGM4ZGFjZDE2ZTI4MTA5Zjll
14
+ Mzk1MWYyMTUxNmJlMzMxZDkzMWUyYjU3ZTYxNzQ2YzAxZjZjNDBmMTk3YmMx
15
+ ODY0MWYxYTE1OTlhYjBjOGE4ZjA4N2E0Y2JmYWZhNWIyYTFjNGM=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ rspec_results.html
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --format html
3
+ --out rspec_results.html
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-bnet (0.0.1)
5
+ httparty
6
+ omniauth
7
+ omniauth-bnet
8
+ recursive-open-struct
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ diff-lcs (1.2.5)
14
+ hashie (3.3.2)
15
+ httparty (0.13.3)
16
+ json (~> 1.8)
17
+ multi_xml (>= 0.5.2)
18
+ json (1.8.1)
19
+ multi_xml (0.5.5)
20
+ omniauth (1.2.2)
21
+ hashie (>= 1.2, < 4)
22
+ rack (~> 1.0)
23
+ rack (1.5.2)
24
+ rake (10.4.2)
25
+ recursive-open-struct (0.5.0)
26
+ rspec (3.1.0)
27
+ rspec-core (~> 3.1.0)
28
+ rspec-expectations (~> 3.1.0)
29
+ rspec-mocks (~> 3.1.0)
30
+ rspec-core (3.1.7)
31
+ rspec-support (~> 3.1.0)
32
+ rspec-expectations (3.1.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.1.0)
35
+ rspec-mocks (3.1.3)
36
+ rspec-support (~> 3.1.0)
37
+ rspec-support (3.1.2)
38
+
39
+ PLATFORMS
40
+ x86-mingw32
41
+
42
+ DEPENDENCIES
43
+ bundler
44
+ omniauth-bnet!
45
+ rake
46
+ rspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Tom Connolly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # BnetApi
2
+
3
+ A Ruby wrapper for the Battle.net API
4
+
5
+ ## Installation
6
+
7
+ TODO
8
+
9
+ ## Configuration
10
+
11
+ You need to set at least the Battle.net API key in the configuration, either in the code or in an initializer.
12
+
13
+ You can also change the region of the API to query and the locale of the returned data.
14
+
15
+ ```ruby
16
+ BnetApi.config.api_key = 'YOUR_API_KEY'
17
+ BnetApi.config.api_secret = 'YOUR_API_SECRET'
18
+ ```
19
+
20
+ ```ruby
21
+ # config/initializers/bnet_api.rb
22
+ require 'bnet_api'
23
+
24
+ BnetApi.configure do |config|
25
+ config.region = :eu
26
+ config.locale = :en_GB
27
+
28
+ config.api_key = 'YOUR_API_KEY'
29
+ config.api_secret = 'YOUR_API_SECRET'
30
+ end
31
+ ```
32
+
33
+ ### Regions
34
+
35
+ * us
36
+ * eu
37
+ * kr
38
+ * tw
39
+
40
+ ### Locales
41
+
42
+ Region | Locales
43
+ ---------|----------
44
+ us | en_US, es_MX, pt_BR
45
+ eu | en_GB, es_ES, fr_FR, ru_RU, de_DE, pl_PL, pt_PT, it_IT
46
+ kr | ko_KR
47
+ tw | zh_TW
48
+
49
+
50
+ ## Examples
51
+
52
+ Each API method returns a hash containing the values returned from the API.
53
+
54
+ For more detailed documentation visit the official documentation (https://dev.battle.net).
55
+
56
+ ### Achievement API
57
+
58
+ To get the data for an achievement:
59
+
60
+ ```ruby
61
+ BnetApi::WoW.achievement(2144)
62
+ ```
63
+
64
+ ### Auction Data API
65
+
66
+ The Auction Data API returns the URL of a JSON file containing an auction data dump generated at the time of the `lastModified` return value.
67
+
68
+ #### Sample Request
69
+
70
+ ```ruby
71
+ BnetApi::WoW.auction_data('Thunderhorn')
72
+ ```
73
+
74
+ #### Sample Response
75
+
76
+ ```json
77
+ {
78
+ "files": [
79
+ {
80
+ "url": "http://eu.battle.net/auction-data/7181c5e54bd6d781d46bdadec17e3637/auctions.json",
81
+ "lastModified": 1418050857000
82
+ }
83
+ ]
84
+ }
85
+ ```
86
+
87
+ ### Battlepet API
88
+
89
+ #### Battlepet Abilities
90
+
91
+ To get a battlepet ability from the API:
92
+
93
+ ```ruby
94
+ BnetApi::WoW.battlepet_ability(640)
95
+ ```
96
+
97
+ #### Battlepet Species
98
+
99
+ To get a battlepet species from the API:
100
+
101
+ ```ruby
102
+ BnetApi::WoW.battlepet_species(258)
103
+ ```
104
+
105
+ #### Battlepet Stats
106
+
107
+ To get the default stats for a battlepet:
108
+
109
+ ```ruby
110
+ BnetApi::WoW.battlepet_stats(258)
111
+ ```
112
+
113
+ The Battlepet Stats API also has three optional parameters:
114
+
115
+ * level
116
+ * breedId
117
+ * qualityId
118
+
119
+ Any or all of these can be passed in as named parameters after the species ID:
120
+
121
+ ```ruby
122
+ BnetApi::WoW.battlepet_stats(258, level: 25, breedId: 5, qualityId: 4)
123
+ ```
124
+
125
+ ### Challenge Mode API
126
+
127
+ #### Realm
128
+
129
+ To get the challenge mode leaderboard for a realm:
130
+
131
+ ```ruby
132
+ BnetApi::WoW.challenge_mode_realm('Thunderhorn')
133
+ ```
134
+
135
+ #### Region
136
+
137
+ To get the challenge mode leaderboard for the region:
138
+
139
+ ```ruby
140
+ BnetApi::WoW.challenge_mode_region
141
+ ```
142
+
143
+ ### Character Profile API
144
+
145
+ To get the basic data for a character:
146
+
147
+ ```ruby
148
+ BnetApi::WoW.character('Thunderhorn', 'Ragwolf')
149
+ ```
150
+
151
+ To get any additional data fields, pass them in as extra symbol values:
152
+
153
+ ```ruby
154
+ BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :achievements, :quests)
155
+ ```
156
+
157
+ To get all additional data fields, pass in :all as the extra parameter:
158
+
159
+ ```ruby
160
+ BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :all)
161
+ ```
162
+
163
+ Available optional fields:
164
+
165
+ * achievements
166
+ * appearance
167
+ * feed
168
+ * guild
169
+ * items
170
+ * mounts
171
+ * pets
172
+ * petSlots
173
+ * progression
174
+ * pvp
175
+ * quests
176
+ * reputation
177
+ * stats
178
+ * talents
179
+ * titles
180
+ * audit
181
+
182
+ ### Guild API
183
+
184
+ To get the basic data for a guild:
185
+
186
+ ```ruby
187
+ BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution')
188
+ ```
189
+
190
+ To get any additional data fields, pass them in as extra symbol values:
191
+
192
+ ```ruby
193
+ BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :news, :achievements)
194
+ ```
195
+
196
+ To get all additional data fields, pass in :all as the extra parameter:
197
+
198
+ ```ruby
199
+ BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :all)
200
+ ```
201
+
202
+ Available optional fields:
203
+
204
+ * members
205
+ * achievements
206
+ * news
207
+ * challenge
208
+
209
+ ### Item API
210
+
211
+ To get the data for an item:
212
+
213
+ ```ruby
214
+ BnetApi::WoW.item(18803)
215
+ ```
216
+
217
+ To get the data for an item set:
218
+
219
+ ```ruby
220
+ BnetApi::WoW.item_set(1060)
221
+ ```
222
+
223
+ ### PvP API
224
+
225
+ To get the PvP leaderboard for a bracket:
226
+
227
+ ```ruby
228
+ BnetApi::WoW.pvp('2v2')
229
+ ```
230
+
231
+ Available brackets:
232
+
233
+ * 2v2
234
+ * 3v3
235
+ * 5v5
236
+ * rbg
237
+
238
+ ### Quest API
239
+
240
+ To get the data for a quest:
241
+
242
+ ```ruby
243
+ BnetApi::WoW.quest(13146)
244
+ ```
245
+
246
+ ### Realm Status API
247
+
248
+ To get the status of all realms in the region:
249
+
250
+ ```ruby
251
+ BnetApi::WoW.realm_status
252
+ ```
253
+
254
+ ### Recipe API
255
+
256
+ To get the data for a recipe:
257
+
258
+ ```ruby
259
+ BnetApi::WoW.recipe(33994)
260
+ ```
261
+
262
+ ### Spell API
263
+
264
+ To get the data for a spell:
265
+
266
+ ```ruby
267
+ BnetApi::WoW.spell(8056)
268
+ ```
data/bnet_api.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bnet_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bnet_api"
8
+ spec.version = BnetApi::VERSION
9
+ spec.authors = ["Tom Connolly"]
10
+ spec.email = ["tconnolly1991@gmail.com"]
11
+ spec.summary = %q{Ruby wrapper for the Battle.net web API.}
12
+ spec.description = %q{Ruby wrapper for the Battle.net web API. For more info visit https://dev.battle.net}
13
+ spec.homepage = "https://github.com/tconnolly/bnetapi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'httparty', '0.13.3'
22
+
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ end
@@ -0,0 +1,3 @@
1
+ module BnetApi
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,90 @@
1
+ require 'uri'
2
+
3
+ module BnetApi
4
+ module WoW
5
+ extend self
6
+
7
+ def achievement(id)
8
+ BnetApi.make_request("/wow/achievement/#{id}")
9
+ end
10
+
11
+ def auction_data(realm)
12
+ BnetApi.make_request("/wow/auction/data/#{realm}")
13
+ end
14
+
15
+ def battlepet_ability(id)
16
+ BnetApi.make_request("/wow/battlePet/ability/#{id}")
17
+ end
18
+
19
+ def battlepet_species(id)
20
+ BnetApi.make_request("/wow/battlePet/species/#{id}")
21
+ end
22
+
23
+ def battlepet_stats(species_id, options = {})
24
+ level = options[:level] || 1
25
+ breedId = options[:breedId] || 3
26
+ qualityId = options[:qualityId] || 1
27
+
28
+ BnetApi.make_request_with_params("/wow/battlePet/stats/#{species_id}",
29
+ {
30
+ level: level,
31
+ breedId: breedId,
32
+ qualityId: qualityId }
33
+ )
34
+ end
35
+
36
+ def challenge_mode_realm(realm)
37
+ BnetApi.make_request("/wow/challenge/#{realm}")
38
+ end
39
+
40
+ def challenge_mode_region
41
+ BnetApi.make_request('/wow/challenge/region')
42
+ end
43
+
44
+ def character(realm, name, *optional_fields)
45
+ if optional_fields[0] == :all
46
+ optional_fields = :achievements, :appearance, :feed, :guild, :items, :mounts, :pets, :petSlots, :progression, :pvp, :quests, :reputation, :stats, :talents, :titles, :audit
47
+ end
48
+ BnetApi.make_request("/wow/character/#{URI.escape(realm)}/#{URI.escape(name)}", optional_fields)
49
+ end
50
+
51
+ def item(id)
52
+ BnetApi.make_request("/wow/item/#{id}")
53
+ end
54
+
55
+ def item_set(id)
56
+ BnetApi.make_request("/wow/item/set/#{id}")
57
+ end
58
+
59
+ def guild(realm, name, *optional_fields)
60
+ if optional_fields[0] == :all
61
+ optional_fields = :members, :achievements, :news, :challenge
62
+ end
63
+ BnetApi.make_request("/wow/guild/#{URI.escape(realm)}/#{URI.escape(name)}", optional_fields)
64
+ end
65
+
66
+ def pvp(bracket)
67
+ BnetApi.make_request("/wow/leaderboard/#{bracket}")
68
+ end
69
+
70
+ def quest(id)
71
+ BnetApi.make_request("/wow/quest/#{id}")
72
+ end
73
+
74
+ def realm_status(*realms)
75
+ if realms != nil
76
+ BnetApi.make_request_with_params("/wow/realm/status", { realms: realms.join(',') })
77
+ else
78
+ BnetApi.make_request("/wow/realm/status")
79
+ end
80
+ end
81
+
82
+ def recipe(id)
83
+ BnetApi.make_request("/wow/recipe/#{id}")
84
+ end
85
+
86
+ def spell(id)
87
+ BnetApi.make_request("/wow/spell/#{id}")
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,48 @@
1
+ module BnetApi
2
+ module WoW
3
+ module Data
4
+ extend self
5
+
6
+ def battlegroups
7
+ BnetApi::make_request('/wow/data/battlegroups/')
8
+ end
9
+
10
+ def character_races
11
+ BnetApi::make_request('/wow/data/character/races')
12
+ end
13
+
14
+ def character_classes
15
+ BnetApi::make_request('/wow/data/character/classes')
16
+ end
17
+
18
+ def character_achievements
19
+ BnetApi::make_request('/wow/data/character/achievements')
20
+ end
21
+
22
+ def guild_rewards
23
+ BnetApi::make_request('/wow/data/guild/rewards')
24
+ end
25
+
26
+ def guild_perks
27
+ BnetApi::make_request('/wow/data/guild/perks')
28
+ end
29
+
30
+ def guild_achievements
31
+ BnetApi::make_request('/wow/data/guild/achievements')
32
+ end
33
+
34
+ def item_classes
35
+ BnetApi::make_request('/wow/data/item/classes')
36
+ end
37
+
38
+ def talents
39
+ BnetApi::make_request('/wow/data/talents')
40
+ end
41
+
42
+ def pet_types
43
+ BnetApi::make_request('/wow/data/pet/types')
44
+ end
45
+
46
+ end
47
+ end
48
+ end
data/lib/bnet_api.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'bnet_api/wow'
2
+ require 'bnet_api/wow_data'
3
+ require 'bnet_api/version'
4
+
5
+ require 'httparty'
6
+ require 'ostruct'
7
+
8
+ module BnetApi
9
+ extend self
10
+ include HTTParty
11
+
12
+ def configure
13
+ yield config
14
+ end
15
+
16
+ def config
17
+ @config ||= OpenStruct.new(region: :eu, locale: :en_GB)
18
+ end
19
+
20
+ def make_request(request, *optional_fields)
21
+ response = self.get("https://#{@config.region}.api.battle.net/#{request}#{build_url_params(optional_fields)}")
22
+ if response["class"] != nil
23
+ response["classId"] = response["class"]
24
+ response.delete("class")
25
+ end
26
+
27
+ return response
28
+ end
29
+
30
+ def make_request_with_params(request, params)
31
+ url = "https://#{@config.region}.api.battle.net/#{request}?"
32
+ params.each do |k, v|
33
+ url += "#{k}=#{v}&"
34
+ end
35
+ url += "locale=#{@config.locale}&apikey=#{@config.api_key}"
36
+
37
+ response = self.get(url)
38
+ if response["class"] != nil
39
+ response["classId"] = response["class"]
40
+ response.delete("class")
41
+ end
42
+
43
+ return response
44
+ end
45
+
46
+ private
47
+ def build_url_params(*optional_fields)
48
+ url_params = "?locale=#{@config.locale}&apikey=#{@config.api_key}"
49
+ if optional_fields != nil
50
+ url_params += "&fields=#{optional_fields.join(',')}"
51
+ end
52
+ return url_params
53
+ end
54
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "sets up the configuration" do
13
+ expect(BnetApi.config.region).to eq(:eu)
14
+ expect(BnetApi.config.locale).to eq(:en_GB)
15
+ expect(BnetApi.config.api_key).to eq(ENV['BNET_ID'])
16
+ expect(BnetApi.config.api_secret).to eq(ENV['BNET_SECRET'])
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets an achievement from the API" do
13
+ achievement = BnetApi::WoW.achievement(2144)
14
+
15
+ expect(achievement['id']).to eq 2144
16
+ expect(achievement['title']).to eq 'What a Long, Strange Trip It\'s Been'
17
+ expect(achievement['points']).to eq 50
18
+ expect(achievement['description']).not_to be_nil
19
+ expect(achievement['reward']).to eq 'Rewards: Violet Proto-Drake'
20
+ expect(achievement['rewardItems']).not_to be_nil
21
+ expect(achievement['icon']).to eq 'achievement_bg_masterofallbgs'
22
+ expect(achievement['criteria']).not_to be_nil
23
+ expect(achievement['accountWide']).to eq true
24
+ expect(achievement['factionId']).to eq 2
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets the URL of an auction data dump from the API" do
13
+ auction_data = BnetApi::WoW.auction_data('Thunderhorn')
14
+
15
+ expect(auction_data['files']).not_to be_nil
16
+ expect(auction_data['files'][0]['url']).not_to be_nil
17
+ expect(auction_data['files'][0]['lastModified']).not_to be_nil
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a battlepet ability from the API" do
13
+ ability = BnetApi::WoW.battlepet_ability(640)
14
+
15
+ expect(ability['id']).to eq 640
16
+ expect(ability['name']).to eq 'Toxic Smoke'
17
+ expect(ability['icon']).to eq 'spell_shadow_plaguecloud'
18
+ expect(ability['cooldown']).to eq 0
19
+ expect(ability['rounds']).to eq 1
20
+ expect(ability['petTypeId']).to eq 9
21
+ expect(ability['isPassive']).to eq false
22
+ expect(ability['hideHints']).to eq false
23
+ end
24
+
25
+ it "gets a battlepet species from the API" do
26
+ species = BnetApi::WoW.battlepet_species(258)
27
+
28
+ expect(species['speciesId']).to eq 258
29
+ expect(species['petTypeId']).to eq 9
30
+ expect(species['creatureId']).to eq 42078
31
+ expect(species['name']).to eq 'Mini Thor'
32
+ expect(species['canBattle']).to eq true
33
+ expect(species['icon']).to eq 't_roboticon'
34
+ expect(species['description']).not_to be_nil
35
+ expect(species['source']).not_to be_nil
36
+ expect(species['abilities']).not_to be_nil
37
+ end
38
+
39
+ it "gets battlepet stats data from the API" do
40
+ stats = BnetApi::WoW.battlepet_stats(258, level: 25, breedId: 5, qualityId: 4)
41
+
42
+ expect(stats['speciesId']).to eq 258
43
+ expect(stats['breedId']).to eq 5
44
+ expect(stats['petQualityId']).to eq 4
45
+ expect(stats['level']).to eq 25
46
+ expect(stats['health']).to eq 1587
47
+ expect(stats['power']).to eq 315
48
+ expect(stats['speed']).to eq 297
49
+ end
50
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a challenge mode realm leaderboard from the API" do
13
+ leaderboard = BnetApi::WoW.challenge_mode_realm('Thunderhorn')
14
+
15
+ expect(leaderboard['challenge']).not_to be_nil
16
+ end
17
+
18
+ it "gets a challenge mode region leaderboard from the API" do
19
+ leaderboard = BnetApi::WoW.challenge_mode_region
20
+
21
+ expect(leaderboard['challenge']).not_to be_nil
22
+ end
23
+ end
@@ -0,0 +1,151 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe BnetApi::WoW do
6
+
7
+ before :each do
8
+ BnetApi.configure do |config|
9
+ config.api_key = ENV['BNET_ID']
10
+ config.api_secret = ENV['BNET_SECRET']
11
+ end
12
+ end
13
+
14
+ it "gets a character from the API" do
15
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf')
16
+
17
+ expect(character['lastModified']).not_to be_nil
18
+ expect(character['name']).to eq('Ragwolf')
19
+ expect(character['realm']).to eq('Thunderhorn')
20
+ expect(character['battlegroup']).to eq('Misery')
21
+ expect(character['classId']).to eq(8)
22
+ expect(character['race']).to eq(5)
23
+ expect(character['gender']).to eq(1)
24
+ expect(character['level']).to eq(100)
25
+ expect(character['achievementPoints']).not_to be_nil
26
+ expect(character['thumbnail']).not_to be_nil
27
+ end
28
+
29
+ it "gets a character from the API with achievement data" do
30
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :achievements)
31
+
32
+ expect(character['achievements']).not_to be_nil
33
+ end
34
+
35
+ it "gets a character from the API with appearance data" do
36
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :appearance)
37
+
38
+ expect(character['appearance']).not_to be_nil
39
+ end
40
+
41
+ it "gets a character from the API with feed data" do
42
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :feed)
43
+
44
+ expect(character['feed']).not_to be_nil
45
+ end
46
+
47
+ it "gets a character from the API with guild data" do
48
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :guild)
49
+
50
+ expect(character['guild']).not_to be_nil
51
+ end
52
+
53
+ it "gets a character from the API with hunterPets data" do
54
+ character = BnetApi::WoW.character('Thunderhorn', 'Cruorfang', :hunterPets)
55
+
56
+ expect(character['hunterPets']).not_to be_nil
57
+ end
58
+
59
+ it "gets a character from the API with items data" do
60
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :items)
61
+
62
+ expect(character['items']).not_to be_nil
63
+ end
64
+
65
+ it "gets a character from the API with mounts data" do
66
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :mounts)
67
+
68
+ expect(character['mounts']).not_to be_nil
69
+ end
70
+
71
+ it "gets a character from the API with pets data" do
72
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :pets)
73
+
74
+ expect(character['pets']).not_to be_nil
75
+ end
76
+
77
+ it "gets a character from the API with petSlots data" do
78
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :petSlots)
79
+
80
+ expect(character['petSlots']).not_to be_nil
81
+ end
82
+
83
+ it "gets a character from the API with progression data" do
84
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :progression)
85
+
86
+ expect(character['progression']).not_to be_nil
87
+ end
88
+
89
+ it "gets a character from the API with pvp data" do
90
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :pvp)
91
+
92
+ expect(character['pvp']).not_to be_nil
93
+ end
94
+
95
+ it "gets a character from the API with quests data" do
96
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :quests)
97
+
98
+ expect(character['quests']).not_to be_nil
99
+ end
100
+
101
+ it "gets a character from the API with itemsreputation" do
102
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :reputation)
103
+
104
+ expect(character['reputation']).not_to be_nil
105
+ end
106
+
107
+ it "gets a character from the API with stats data" do
108
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :stats)
109
+
110
+ expect(character['stats']).not_to be_nil
111
+ end
112
+
113
+ it "gets a character from the API with talents data" do
114
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :talents)
115
+
116
+ expect(character['talents']).not_to be_nil
117
+ end
118
+
119
+ it "gets a character from the API with titles data" do
120
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :titles)
121
+
122
+ expect(character['titles']).not_to be_nil
123
+ end
124
+
125
+ it "gets a character from the API with audit data" do
126
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :audit)
127
+
128
+ expect(character['audit']).not_to be_nil
129
+ end
130
+
131
+ it "gets a character from the API with all additional data" do
132
+ character = BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :all)
133
+
134
+ expect(character['achievements']).not_to be_nil
135
+ expect(character['appearance']).not_to be_nil
136
+ expect(character['feed']).not_to be_nil
137
+ expect(character['guild']).not_to be_nil
138
+ expect(character['items']).not_to be_nil
139
+ expect(character['mounts']).not_to be_nil
140
+ expect(character['pets']).not_to be_nil
141
+ expect(character['petSlots']).not_to be_nil
142
+ expect(character['progression']).not_to be_nil
143
+ expect(character['pvp']).not_to be_nil
144
+ expect(character['quests']).not_to be_nil
145
+ expect(character['reputation']).not_to be_nil
146
+ expect(character['stats']).not_to be_nil
147
+ expect(character['talents']).not_to be_nil
148
+ expect(character['titles']).not_to be_nil
149
+ expect(character['audit']).not_to be_nil
150
+ end
151
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a list of battlegroups from the API" do
13
+ battlegroups = BnetApi::WoW::Data.battlegroups
14
+
15
+ expect(battlegroups['battlegroups']).not_to be_nil
16
+ end
17
+
18
+ it "gets a list of character races from the API" do
19
+ races = BnetApi::WoW::Data.character_races
20
+
21
+ expect(races['races']).not_to be_nil
22
+ end
23
+
24
+ it "gets a list of character classes from the API" do
25
+ classes = BnetApi::WoW::Data.character_classes
26
+
27
+ expect(classes['classes']).not_to be_nil
28
+ end
29
+
30
+ it "gets a list of character achievements from the API" do
31
+ achievements = BnetApi::WoW::Data.character_achievements
32
+
33
+ expect(achievements['achievements']).not_to be_nil
34
+ end
35
+
36
+ it "gets a list of guild rewards from the API" do
37
+ rewards = BnetApi::WoW::Data.guild_rewards
38
+
39
+ expect(rewards['rewards']).not_to be_nil
40
+ end
41
+
42
+ it "gets a list of guild perks from the API" do
43
+ perks = BnetApi::WoW::Data.guild_perks
44
+
45
+ expect(perks['perks']).not_to be_nil
46
+ end
47
+
48
+ it "gets a list of guild achievements from the API" do
49
+ achievements = BnetApi::WoW::Data.guild_achievements
50
+
51
+ expect(achievements['achievements']).not_to be_nil
52
+ end
53
+
54
+ it "gets a list of item classes from the API" do
55
+ classes = BnetApi::WoW::Data.item_classes
56
+
57
+ expect(classes['classes']).not_to be_nil
58
+ end
59
+
60
+ it "gets a list of talents from the API" do
61
+ talents = BnetApi::WoW::Data.talents
62
+
63
+ expect(talents['1']).not_to be_nil
64
+ expect(talents['2']).not_to be_nil
65
+ expect(talents['3']).not_to be_nil
66
+ expect(talents['4']).not_to be_nil
67
+ expect(talents['5']).not_to be_nil
68
+ expect(talents['6']).not_to be_nil
69
+ expect(talents['7']).not_to be_nil
70
+ expect(talents['8']).not_to be_nil
71
+ expect(talents['9']).not_to be_nil
72
+ expect(talents['10']).not_to be_nil
73
+ expect(talents['11']).not_to be_nil
74
+ end
75
+
76
+ it "gets a list of pet types from the API" do
77
+ petTypes = BnetApi::WoW::Data.pet_types
78
+
79
+ expect(petTypes['petTypes']).not_to be_nil
80
+ end
81
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a guild from the API" do
13
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution')
14
+
15
+ expect(guild['lastModified']).not_to be_nil
16
+ expect(guild['name']).to eq('Banana Revolution')
17
+ expect(guild['realm']).to eq('Thunderhorn')
18
+ expect(guild['battlegroup']).to eq('Misery')
19
+ expect(guild['level']).to eq(25)
20
+ expect(guild['side']).to eq(1)
21
+ expect(guild['achievementPoints']).not_to be_nil
22
+ expect(guild['emblem']).not_to be_nil
23
+ end
24
+
25
+ it "gets a guild from the API with members data" do
26
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :members)
27
+
28
+ expect(guild['members']).not_to be_nil
29
+ end
30
+
31
+ it "gets a guild from the API with achievements data" do
32
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :achievements)
33
+
34
+ expect(guild['achievements']).not_to be_nil
35
+ end
36
+
37
+ it "gets a guild from the API with news data" do
38
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :news)
39
+
40
+ expect(guild['news']).not_to be_nil
41
+ end
42
+
43
+ it "gets a guild from the API with challenge data" do
44
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :challenge)
45
+
46
+ expect(guild['challenge']).not_to be_nil
47
+ end
48
+
49
+ it "gets a guild from the API with all additional data" do
50
+ guild = BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :all)
51
+
52
+ expect(guild['members']).not_to be_nil
53
+ expect(guild['achievements']).not_to be_nil
54
+ expect(guild['news']).not_to be_nil
55
+ expect(guild['challenge']).not_to be_nil
56
+ end
57
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets an item from the API" do
13
+ item = BnetApi::WoW.item(18803)
14
+
15
+ expect(item['id']).to eq 18803
16
+ expect(item['disenchantingSkillRank']).to eq 225
17
+ expect(item['name']).to eq 'Finkle\'s Lava Dredger'
18
+ expect(item['icon']).to eq 'inv_gizmo_02'
19
+ end
20
+
21
+ it "gets an item set from the API" do
22
+ item_set = BnetApi::WoW.item_set(1060)
23
+
24
+ expect(item_set['id']).to eq 1060
25
+ expect(item_set['name']).to eq 'Deep Earth Vestments'
26
+ expect(item_set['setBonuses']).not_to be_nil
27
+ expect(item_set['items']).not_to be_nil
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a pvp leaderboard from the API" do
13
+ leaderboard = BnetApi::WoW.pvp('2v2')
14
+
15
+ expect(leaderboard['rows']).not_to be_nil
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a quest from the API" do
13
+ quest = BnetApi::WoW.quest(13146)
14
+
15
+ expect(quest['id']).to eq 13146
16
+ expect(quest['title']).to eq 'Generosity Abounds'
17
+ expect(quest['reqLevel']).to eq 77
18
+ expect(quest['suggestedPartyMembers']).to eq 0
19
+ expect(quest['category']).to eq 'Icecrown'
20
+ expect(quest['level']).to eq 80
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets realm status data from the API" do
13
+ realm_status = BnetApi::WoW.realm_status
14
+
15
+ expect(realm_status['realms']).not_to be_nil
16
+ end
17
+
18
+ it "gets realm status data for specified realms from the API" do
19
+ realm_status = BnetApi::WoW.realm_status('Thunderhorn')
20
+
21
+ expect(realm_status['realms']).not_to be_nil
22
+ expect(realm_status['realms'].count).to eq 1
23
+ expect(realm_status['realms'][0]['name']).to eq 'Thunderhorn'
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a recipe from the API" do
13
+ recipe = BnetApi::WoW.recipe(33994)
14
+
15
+ expect(recipe['id']).to eq 33994
16
+ expect(recipe['name']).to eq 'Precise Strikes'
17
+ expect(recipe['profession']).to eq 'Enchanting'
18
+ expect(recipe['icon']).to eq 'spell_holy_greaterheal'
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::WoW do
4
+
5
+ before :each do
6
+ BnetApi.configure do |config|
7
+ config.api_key = ENV['BNET_ID']
8
+ config.api_secret = ENV['BNET_SECRET']
9
+ end
10
+ end
11
+
12
+ it "gets a spell from the API" do
13
+ spell = BnetApi::WoW.spell(8056)
14
+
15
+ expect(spell['id']).to eq 8056
16
+ expect(spell['name']).to eq 'Frost Shock'
17
+ expect(spell['icon']).to eq 'spell_frost_frostshock'
18
+ expect(spell['description']).not_to be_nil
19
+ expect(spell['range']).to eq '25 yd range'
20
+ expect(spell['powerCost']).to eq '1.25% of base mana'
21
+ expect(spell['castTime']).to eq 'Instant'
22
+ expect(spell['cooldown']).to eq '6 sec cooldown'
23
+ end
24
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'bnet_api'
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bnet_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Connolly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby wrapper for the Battle.net web API. For more info visit https://dev.battle.net
70
+ email:
71
+ - tconnolly1991@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.md
81
+ - README.md
82
+ - bnet_api.gemspec
83
+ - lib/bnet_api.rb
84
+ - lib/bnet_api/version.rb
85
+ - lib/bnet_api/wow.rb
86
+ - lib/bnet_api/wow_data.rb
87
+ - spec/bnet_api/bnet_api_spec.rb
88
+ - spec/bnet_api/wow/wow_achievement_spec.rb
89
+ - spec/bnet_api/wow/wow_auction_data_spec.rb
90
+ - spec/bnet_api/wow/wow_battlepet_spec.rb
91
+ - spec/bnet_api/wow/wow_challenge_mode_spec.rb
92
+ - spec/bnet_api/wow/wow_character_spec.rb
93
+ - spec/bnet_api/wow/wow_data_spec.rb
94
+ - spec/bnet_api/wow/wow_guild_spec.rb
95
+ - spec/bnet_api/wow/wow_item_spec.rb
96
+ - spec/bnet_api/wow/wow_pvp_spec.rb
97
+ - spec/bnet_api/wow/wow_quest_spec.rb
98
+ - spec/bnet_api/wow/wow_realm_status_spec.rb
99
+ - spec/bnet_api/wow/wow_recipe_spec.rb
100
+ - spec/bnet_api/wow/wow_spell_spec.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/tconnolly/bnetapi
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.4.5
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Ruby wrapper for the Battle.net web API.
126
+ test_files:
127
+ - spec/bnet_api/bnet_api_spec.rb
128
+ - spec/bnet_api/wow/wow_achievement_spec.rb
129
+ - spec/bnet_api/wow/wow_auction_data_spec.rb
130
+ - spec/bnet_api/wow/wow_battlepet_spec.rb
131
+ - spec/bnet_api/wow/wow_challenge_mode_spec.rb
132
+ - spec/bnet_api/wow/wow_character_spec.rb
133
+ - spec/bnet_api/wow/wow_data_spec.rb
134
+ - spec/bnet_api/wow/wow_guild_spec.rb
135
+ - spec/bnet_api/wow/wow_item_spec.rb
136
+ - spec/bnet_api/wow/wow_pvp_spec.rb
137
+ - spec/bnet_api/wow/wow_quest_spec.rb
138
+ - spec/bnet_api/wow/wow_realm_status_spec.rb
139
+ - spec/bnet_api/wow/wow_recipe_spec.rb
140
+ - spec/bnet_api/wow/wow_spell_spec.rb
141
+ - spec/spec_helper.rb
142
+ has_rdoc: