bnet_api 0.1.2 → 0.1.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmEwYWMxYWUzNGFkNjhkYmY1NjAyZGJmOTkwZTcxNzczMWE1ZWRiNA==
4
+ YmZiYWQ0YWIwOWI2MGFkZWZmOWQxZDBmZmM2MWZhNzBmYzMyYzFiNA==
5
5
  data.tar.gz: !binary |-
6
- ZDBhYTljZjAwYTk3NGQ5NTgyZTIyZjZjMDRiNzliMmZjNjBiNzNkMA==
6
+ Njc2Y2UwOTcyNWI4N2MyN2I1NWFlNDI2YWE4ZDVkNGM5ZWJlMzljYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjU5ZWRhNjRhYmJhZTMwNDUzMjMyZTk4ZTk3MGViYTY1NTJhZWU0ZmVkMDA3
10
- ODFkZmZkYjRkZGIyMjg0NDMwOWQ1ZDgwNDYzMjYyZWViYmQ2OTlkZjljMWI1
11
- MDc3ZWYzNWNjMzkwMDk0ZjZmY2E5YjAxOTQxYmQ2ZDI0OTQ0ZTY=
9
+ MjVhOTJmYmU3ODgwZDc1NTY1MTUzMzQyNzRlNDhkYzEwMjQwMjZlYjhhYjBk
10
+ NDNjYjRhNGU0YmQzMmY4NzE3MTJiOTFlZTkzYjQwNTU4Mzg1OGE4YmMyZDBl
11
+ NTg3MWM5NDQwNDA4NjA0YjE3MjNhZDI2OGM0MGM4YjU0NjFlMDA=
12
12
  data.tar.gz: !binary |-
13
- YjM3ZGE3NmRkNTZkYjllN2QzMjU4YjA5OTdmYTJiZDdhMTBjYTQzNmU5MjQx
14
- OGVlMjk2ZjE1YWUzZjA0YjhmOGI2ODIzYzEzYTE0MmViNDE2Zjc0YmZlOTY1
15
- NmNiNmQwMmRhYjI3ZWNlYjU2ODU5NGIwZmI0ZGU4NmI2Y2YzMDQ=
13
+ N2ZmNTAyZmFhYmYxYzIwMGQ5NDNkNTRmZTEyMzBhM2YwZTBiYTA1ZWI2OTdh
14
+ MGIzZTRhZjkxNWNmMjVlN2E4Y2QzNjk0YjU2ZWI2NzM3MzAyOWZjMDRlYmI4
15
+ MzExNmFhZTcxMWI4MWZmNWRhYzYyZWUzZWZlNzY4MzhhMTZjMjY=
data/README.md CHANGED
@@ -8,16 +8,55 @@
8
8
 
9
9
  A Ruby wrapper for the Battle.net API
10
10
 
11
- ## Current Version: 0.1.2
11
+ ## Current Version: 0.1.3
12
12
 
13
13
  ### Status
14
14
 
15
15
  API | Status
16
16
  ------------------|-----------------
17
17
  World of Warcraft | Implemented
18
- Diablo III | Not implemented
18
+ Diablo III | Implemented
19
19
  Starcraft II | Not implemented
20
- OAuth | Implemented
20
+ OAuth | Implemented
21
+
22
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
23
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
24
+ **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
25
+
26
+ - [BnetApi](#bnetapi)
27
+ - [Current Version: 0.1.3](#current-version-013)
28
+ - [Status](#status)
29
+ - [Installation](#installation)
30
+ - [Configuration](#configuration)
31
+ - [Regions](#regions)
32
+ - [Locales](#locales)
33
+ - [Examples](#examples)
34
+ - [Achievement API](#achievement-api)
35
+ - [Auction Data API](#auction-data-api)
36
+ - [Sample Request](#sample-request)
37
+ - [Sample Response](#sample-response)
38
+ - [Battlepet API](#battlepet-api)
39
+ - [Battlepet Abilities](#battlepet-abilities)
40
+ - [Battlepet Species](#battlepet-species)
41
+ - [Battlepet Stats](#battlepet-stats)
42
+ - [Challenge Mode API](#challenge-mode-api)
43
+ - [Realm](#realm)
44
+ - [Region](#region)
45
+ - [Character Profile API](#character-profile-api)
46
+ - [Guild API](#guild-api)
47
+ - [Item API](#item-api)
48
+ - [PvP API](#pvp-api)
49
+ - [Quest API](#quest-api)
50
+ - [Realm Status API](#realm-status-api)
51
+ - [Recipe API](#recipe-api)
52
+ - [Spell API](#spell-api)
53
+ - [OAuth APIs](#oauth-apis)
54
+ - [Account ID](#account-id)
55
+ - [Battletag](#battletag)
56
+ - [Starcraft II Profile](#starcraft-ii-profile)
57
+ - [World of Warcraft Profile](#world-of-warcraft-profile)
58
+
59
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
21
60
 
22
61
  ## Installation
23
62
 
@@ -85,7 +124,7 @@ The Auction Data API returns the URL of a JSON file containing an auction data d
85
124
  #### Sample Request
86
125
 
87
126
  ```ruby
88
- BnetApi::WoW.auction_data('Thunderhorn')
127
+ BnetApi::WoW.auction_data('REALM')
89
128
  ```
90
129
 
91
130
  #### Sample Response
@@ -146,7 +185,7 @@ BnetApi::WoW.battlepet_stats(258, level: 25, breedId: 5, qualityId: 4)
146
185
  To get the challenge mode leaderboard for a realm:
147
186
 
148
187
  ```ruby
149
- BnetApi::WoW.challenge_mode_realm('Thunderhorn')
188
+ BnetApi::WoW.challenge_mode_realm('REALM')
150
189
  ```
151
190
 
152
191
  #### Region
@@ -162,19 +201,19 @@ BnetApi::WoW.challenge_mode_region
162
201
  To get the basic data for a character:
163
202
 
164
203
  ```ruby
165
- BnetApi::WoW.character('Thunderhorn', 'Ragwolf')
204
+ BnetApi::WoW.character('REALM', 'CHARACTER_NAME')
166
205
  ```
167
206
 
168
207
  To get any additional data fields, pass them in as extra symbol values:
169
208
 
170
209
  ```ruby
171
- BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :achievements, :quests)
210
+ BnetApi::WoW.character('REALM', 'CHARACTER_NAME', :achievements, :quests)
172
211
  ```
173
212
 
174
213
  To get all additional data fields, pass in :all as the extra parameter:
175
214
 
176
215
  ```ruby
177
- BnetApi::WoW.character('Thunderhorn', 'Ragwolf', :all)
216
+ BnetApi::WoW.character('REALM', 'CHARACTER_NAME', :all)
178
217
  ```
179
218
 
180
219
  Available optional fields:
@@ -201,19 +240,19 @@ Available optional fields:
201
240
  To get the basic data for a guild:
202
241
 
203
242
  ```ruby
204
- BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution')
243
+ BnetApi::WoW.guild('REALM', 'GUILD_NAME')
205
244
  ```
206
245
 
207
246
  To get any additional data fields, pass them in as extra symbol values:
208
247
 
209
248
  ```ruby
210
- BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :news, :achievements)
249
+ BnetApi::WoW.guild('REALM', 'GUILD_NAME', :news, :achievements)
211
250
  ```
212
251
 
213
252
  To get all additional data fields, pass in :all as the extra parameter:
214
253
 
215
254
  ```ruby
216
- BnetApi::WoW.guild('Thunderhorn', 'Banana Revolution', :all)
255
+ BnetApi::WoW.guild('REALM', 'GUILD_NAME', :all)
217
256
  ```
218
257
 
219
258
  Available optional fields:
@@ -283,3 +322,39 @@ To get the data for a spell:
283
322
  ```ruby
284
323
  BnetApi::WoW.spell(8056)
285
324
  ```
325
+
326
+ ### OAuth APIs
327
+
328
+ This library isn't concerned with the OAuth authentication, just retrieving data from the API.
329
+
330
+ You can use the [OmniAuth Bnet](https://github.com/Blizzard/omniauth-bnet) or any other OAuth library to authenticate against the Battle.net OAuth service, and then just pass the user's OAuth Access Token to the OAuth API methods.
331
+
332
+ #### Account ID
333
+
334
+ To get the user's account ID:
335
+
336
+ ```ruby
337
+ BnetApi::OAuth.account_id('ACCESS_TOKEN')
338
+ ```
339
+
340
+ #### Battletag
341
+
342
+ To get the user's battletag:
343
+
344
+ ```ruby
345
+ BnetApi::OAuth.battletag('ACCESS_TOKEN')
346
+ ```
347
+
348
+ #### Starcraft II Profile
349
+
350
+ To get the user's Starcraft II profile:
351
+
352
+ ```ruby
353
+ BnetApi::OAuth.sc2_profile('ACCESS_TOKEN')
354
+ ```
355
+
356
+ #### World of Warcraft Profile
357
+
358
+ ```ruby
359
+ BnetApi::OAuth.wow_profile('ACCESS_TOKEN')
360
+ ```
@@ -0,0 +1,27 @@
1
+ require 'uri'
2
+
3
+ module BnetApi
4
+ module D3
5
+ extend self
6
+
7
+ def career_profile(battletag)
8
+ BnetApi.make_request("/d3/profile/#{URI.encode(battletag)}/")
9
+ end
10
+
11
+ def hero_profile(battletag, id)
12
+ BnetApi.make_request("/d3/profile/#{URI.encode(battletag)}/hero/#{id}")
13
+ end
14
+
15
+ def item_data(data)
16
+ BnetApi.make_request("/d3/data/item/#{data}")
17
+ end
18
+
19
+ def follower_data(follower)
20
+ BnetApi.make_request("/d3/data/follower/#{follower}")
21
+ end
22
+
23
+ def artisan_data(artisan)
24
+ BnetApi.make_request("/d3/data/artisan/#{artisan}")
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module BnetApi
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/bnet_api.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'bnet_api/d3'
1
2
  require 'bnet_api/oauth'
2
3
  require 'bnet_api/wow'
3
4
  require 'bnet_api/wow_data'
@@ -19,13 +20,7 @@ module BnetApi
19
20
  end
20
21
 
21
22
  def make_request(request, *optional_fields)
22
- response = self.get("https://#{@config.region}.api.battle.net/#{request}#{build_url_params(optional_fields)}")
23
- if response["class"] != nil
24
- response["classId"] = response["class"]
25
- response.delete("class")
26
- end
27
-
28
- return response
23
+ self.get("https://#{@config.region}.api.battle.net/#{request}#{build_url_params(optional_fields)}")
29
24
  end
30
25
 
31
26
  def make_request_with_params(request, params)
@@ -35,13 +30,7 @@ module BnetApi
35
30
  end
36
31
  url += "locale=#{@config.locale}&apikey=#{@config.api_key}"
37
32
 
38
- response = self.get(url)
39
- if response["class"] != nil
40
- response["classId"] = response["class"]
41
- response.delete("class")
42
- end
43
-
44
- return response
33
+ self.get(url)
45
34
  end
46
35
 
47
36
  def make_request_oauth(request, access_token)
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe BnetApi::D3 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 career profile from the API" do
13
+ profile = BnetApi::D3.career_profile('Ragwolf#2851')
14
+
15
+ expect(profile['battleTag']).to eq 'Ragwolf#2851'
16
+ expect(profile['heroes']).not_to be_nil
17
+ end
18
+
19
+ it "gets a hero profile from the API" do
20
+ profile = BnetApi::D3.hero_profile('Ragwolf#2851', 47516365)
21
+
22
+ expect(profile['name']).to eq 'Ragwolf'
23
+ expect(profile['class']).to eq 'demon-hunter'
24
+ expect(profile['skills']).not_to be_nil
25
+ end
26
+
27
+ it "gets the data for an item from the API" do
28
+ item = BnetApi::D3.item_data('Co4BCJbokeUHEgcIBBV_-U5dHcj6vKAdjs3dnR2dB5UkHSCd5AQd6XAvux3DDZzlIgsIARW1RAMAGAogJjCLAjjqA0AASBNQEFgEYOwEaisKDAgAEMPSgK2BgIDAEhIbCJ7JnZUJEgcIBBUVn9irMIsCOABAAVgEkAEBpQEgneQErQFmIwZQuAHSiJmSBcABBhj-5ffUC1AAWAI')
29
+
30
+ expect(item['id']).to eq 'Helm_208'
31
+ expect(item['name']).to eq 'Prime Shelter'
32
+ expect(item['icon']).to eq 'helm_208_demonhunter_male'
33
+ expect(item['displayColor']).to eq 'yellow'
34
+ end
35
+
36
+ it "gets the data for the templar follower from the API" do
37
+ follower = BnetApi::D3.follower_data('templar')
38
+
39
+ expect(follower['slug']).to eq 'templar'
40
+ expect(follower['name']).to eq 'Templar'
41
+ expect(follower['realName']).to eq 'd3.follower.templar.realName'
42
+ expect(follower['portrait']).to eq 'templar'
43
+ expect(follower['skills']).not_to be_nil
44
+ end
45
+
46
+ it "gets the data for the enchantress follower from the API" do
47
+ follower = BnetApi::D3.follower_data('enchantress')
48
+
49
+ expect(follower['slug']).to eq 'enchantress'
50
+ expect(follower['name']).to eq 'Enchantress'
51
+ expect(follower['realName']).to eq 'd3.follower.enchantress.realName'
52
+ expect(follower['portrait']).to eq 'enchantress'
53
+ expect(follower['skills']).not_to be_nil
54
+ end
55
+
56
+ it "gets the data for the scoundrel follower from the API" do
57
+ follower = BnetApi::D3.follower_data('scoundrel')
58
+
59
+ expect(follower['slug']).to eq 'scoundrel'
60
+ expect(follower['name']).to eq 'Scoundrel'
61
+ expect(follower['realName']).to eq 'd3.follower.scoundrel.realName'
62
+ expect(follower['portrait']).to eq 'scoundrel'
63
+ expect(follower['skills']).not_to be_nil
64
+ end
65
+
66
+ it "gets the data for the blacksmith artisan from the API" do
67
+ artisan = BnetApi::D3.artisan_data('blacksmith')
68
+
69
+ expect(artisan['slug']).to eq 'blacksmith'
70
+ expect(artisan['name']).to eq 'Blacksmith'
71
+ expect(artisan['portrait']).to eq 'pt_blacksmith'
72
+ expect(artisan['training']).not_to be_nil
73
+ end
74
+
75
+ it "gets the data for the jeweler artisan from the API" do
76
+ artisan = BnetApi::D3.artisan_data('jeweler')
77
+
78
+ expect(artisan['slug']).to eq 'jeweler'
79
+ expect(artisan['name']).to eq 'Jeweler'
80
+ expect(artisan['portrait']).to eq 'pt_jeweler'
81
+ expect(artisan['training']).not_to be_nil
82
+ end
83
+
84
+ it "gets the data for the mystic artisan from the API" do
85
+ artisan = BnetApi::D3.artisan_data('mystic')
86
+
87
+ expect(artisan['slug']).to eq 'mystic'
88
+ expect(artisan['name']).to eq 'Mystic'
89
+ expect(artisan['portrait']).to eq 'pt_mystic'
90
+ expect(artisan['training']).not_to be_nil
91
+ end
92
+ end
@@ -18,7 +18,7 @@ describe BnetApi::WoW do
18
18
  expect(character['name']).to eq('Ragwolf')
19
19
  expect(character['realm']).to eq('Thunderhorn')
20
20
  expect(character['battlegroup']).to eq('Misery')
21
- expect(character['classId']).to eq(8)
21
+ expect(character['class']).to eq(8)
22
22
  expect(character['race']).to eq(5)
23
23
  expect(character['gender']).to eq(1)
24
24
  expect(character['level']).to eq(100)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bnet_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Connolly
@@ -70,11 +70,13 @@ files:
70
70
  - Rakefile
71
71
  - bnet_api.gemspec
72
72
  - lib/bnet_api.rb
73
+ - lib/bnet_api/d3.rb
73
74
  - lib/bnet_api/oauth.rb
74
75
  - lib/bnet_api/version.rb
75
76
  - lib/bnet_api/wow.rb
76
77
  - lib/bnet_api/wow_data.rb
77
78
  - spec/bnet_api/bnet_api_spec.rb
79
+ - spec/bnet_api/d3_spec.rb
78
80
  - spec/bnet_api/oauth_spec.rb
79
81
  - spec/bnet_api/wow/wow_achievement_spec.rb
80
82
  - spec/bnet_api/wow/wow_auction_data_spec.rb
@@ -116,6 +118,7 @@ specification_version: 4
116
118
  summary: Ruby wrapper for the Battle.net web API.
117
119
  test_files:
118
120
  - spec/bnet_api/bnet_api_spec.rb
121
+ - spec/bnet_api/d3_spec.rb
119
122
  - spec/bnet_api/oauth_spec.rb
120
123
  - spec/bnet_api/wow/wow_achievement_spec.rb
121
124
  - spec/bnet_api/wow/wow_auction_data_spec.rb