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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9abf4010781883ec5d265c7c5afc9800b6d9687c
4
- data.tar.gz: 774f81c62b4c50d3604553ab75ea8587d5a1d348
3
+ metadata.gz: c7ae9075e2ca3a2e42b93143d7c97f3676250def
4
+ data.tar.gz: 16f7e1fdf7f6eaac2e0d3dda5ad7529a793c7fde
5
5
  SHA512:
6
- metadata.gz: f23d179f18eee8a09c681c9adb6a0293d52ef111ef0922306522013f3a9f0f225238376cb5523020c6286e29f8af924b3f026469d2bc215241859727f8e79cf0
7
- data.tar.gz: 8bd5eaca8a678377abfbc4034b0c8f364c0fc1bb2a5bf4ec41130533b41998e8c9d00805d1a521e8990135b5118dcd8985ad63930494d3fe5df219a11e34e76a
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({:achievement => 'achievement_id'})
25
- auction_data = client.auction({:realm => 'realm'})
26
- character = client.character({:realm => 'realm', :character_name => 'character_name'})
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({:realm => 'realm', :guild_name => 'guild_name'})
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 = client.item({:item => 'item_id'})
38
+ item = data.item({item: 'item_id'})
39
39
  puts item.details
40
40
 
41
- item = client.item_set({:item_set => 'item_set_id'})
41
+ item = data.item_set({item_set: 'item_set_id'})
42
42
  puts item.details
43
43
 
44
- pvp_leaderboards = client.pvp_leaderboards({:bracket => 'bracket'})
44
+ pvp_leaderboards = data.pvp_leaderboards({bracket: 'bracket'})
45
45
  puts pvp_leaderboards.details
46
46
 
47
- quest = client.quest({:quest => 'quest_id'})
47
+ quest = data.quest({quest: 'quest_id'})
48
48
  puts quest.details
49
49
 
50
- recipe = client.recipe({:recipe => 'recipe_id'})
50
+ recipe = data.recipe({recipe: 'recipe_id'})
51
51
  puts recipe.details
52
52
 
53
- spell = client.spell({:spell => 'spell_id'})
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
- client.data_item(data_id)
66
- client.data_follower(follower_id)
67
- client.data_artisan(artisan_id)
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.career_profile(battletag)
70
- client.hero_profile(battletag,hero_id)
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
- client.achievements
81
- client.rewards
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
- client.profile_ladders(id, region, name)
87
- client.profile_match_history(id, region, name)
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 File.expand_path('../client', __FILE__)
1
+ require 'battlenet/api/client'
2
2
 
3
- Dir[File.expand_path('../../modules/d3/*.rb', __FILE__)].each{|f| require f}
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
@@ -1,5 +1,5 @@
1
1
  module Battlenet
2
2
  module Api
3
- VERSION = "0.3.2"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -2,22 +2,22 @@ require 'uri'
2
2
 
3
3
  module Battlenet
4
4
  module D3
5
- def data_item(data, options = {})
6
- data = URI.escape data
5
+ class Data < Battlenet::APIResponse
6
+ def initialize(options={})
7
+ super(options)
8
+ end
7
9
 
8
- get "/data/item/#{data}", options
9
- end
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
- def data_artisan(artisan, options = {})
18
- artisan = URI.escape artisan
14
+ def follower(follower, options = {})
15
+ get_data("/data/follower/#{follower}", options)
16
+ end
19
17
 
20
- get "/data/artisan/#{artisan}", options
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
- def career_profile(battletag, options = {})
6
- battletag = URI.escape battletag
5
+ class Profile < Battlenet::APIResponse
6
+ def initialize(options={})
7
+ super(options)
8
+ end
7
9
 
8
- get "/profile/#{battletag}", options
9
- end
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
- get "/profile/#{battletag}/hero/#{id}", options
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
- def achievements(options = {})
6
- get "/data/achievements", options
7
- end
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
- def ladder(id, options = {})
6
- id = URI.escape id
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
- def profile(id, region, name, options = {})
6
- id = URI.escape id
7
- region = URI.escape region
8
- name = URI.escape name
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
- get "/profile/#{id}/#{region}/#{name}", options
11
- end
11
+ @endpoint = "/profile/#{@profile_id}/#{@region}/#{@name}"
12
12
 
13
- def profile_ladders(id, region, name, options = {})
14
- id = URI.escape id
15
- region = URI.escape region
16
- name = URI.escape name
13
+ super(options)
14
+ end
17
15
 
18
- get "/profile/#{id}/#{region}/#{name}/ladders", options
19
- end
16
+ def details(options = {})
17
+ get_data(@endpoint, options)
18
+ end
20
19
 
21
- def profile_match_history(id, region, name, options = {})
22
- id = URI.escape id
23
- region = URI.escape region
24
- name = URI.escape name
20
+ def ladders(options = {})
21
+ get_data("#{@endpoint}/ladders", options)
22
+ end
25
23
 
26
- get "/profile/#{id}/#{region}/#{name}/matches", options
24
+ def match_history(options = {})
25
+ get_data("#{@endpoint}/matches", options)
26
+ end
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -3,8 +3,7 @@ module Battlenet
3
3
  class Achievement < Battlenet::APIResponse
4
4
 
5
5
  def initialize(options={})
6
- @realm = options.delete(:achievement)
7
-
6
+ @achievement = options.delete(:achievement)
8
7
  @endpoint = "/achievement/#{@achievement}"
9
8
 
10
9
  super(options)
@@ -4,7 +4,6 @@ module Battlenet
4
4
 
5
5
  def initialize(options={})
6
6
  @realm = options.delete(:realm)
7
-
8
7
  @endpoint = "/auction/data/#{@realm}"
9
8
 
10
9
  super(options)
@@ -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
@@ -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(:data_item) }
17
- it { should respond_to(:data_follower) }
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
@@ -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(:achievements) }
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.3.2
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: 2015-12-11 00:00:00.000000000 Z
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