battlenet-api 0.1.0 → 0.2.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683fb02cb8c591d4c10d640cbd8180906f63bff4
4
- data.tar.gz: 19c5877277059a1f544599f934b1c6c49ca2f4fb
3
+ metadata.gz: 2f6009e021ba8b5d67293b21b656dea571e959eb
4
+ data.tar.gz: 8abe07468e5d82506dd1d7122b639da784bbd9cd
5
5
  SHA512:
6
- metadata.gz: 624d4c74aec95c3e5e4b908e7b683e29bef24e840ce740898d73cf5c7e31946f289e406a08dcf657db79c403edcd14642ec12a129a4a17eb4e449f46e32588cd
7
- data.tar.gz: dcc0b456b88ebef73c8533a98cdef94518f57725b4ae439691745baee5c1fd5d34e9269badd9d774fb414a3352bb41333c9a39693439de127091bf72af50fb0c
6
+ metadata.gz: 7031729ba3fe8595c0c256bc2ce5b71bab92379419b82ad715ac76e90778148737df8690a714251f74c16454ee995f1a645b2b8a97ba017ac0ca135aae75c1aa
7
+ data.tar.gz: e48e5d71bc7af0633c32ba4787340aec1aac3aa73562f5ea0d18eb5daaa909d140d533cb958296e64ba217b25930823312fcd39c07e9a3738ac9b769fd80dc4b
data/README.md CHANGED
@@ -1,6 +1,122 @@
1
- # Battlenet API Gem [![Dependency Status](https://gemnasium.com/goodcodeguy/battlenet-api.svg)](https://gemnasium.com/goodcodeguy/battlenet-api) [![Code Climate](https://codeclimate.com/github/goodcodeguy/battlenet-api/badges/gpa.svg)](https://codeclimate.com/github/goodcodeguy/battlenet-api)
1
+ # Battlenet API Gem
2
+ [![Gem Version](https://badge.fury.io/rb/battlenet-api.svg)](http://badge.fury.io/rb/battlenet-api) [![Dependency Status](https://gemnasium.com/goodcodeguy/battlenet-api.svg)](https://gemnasium.com/goodcodeguy/battlenet-api) [![Code Climate](https://codeclimate.com/github/goodcodeguy/battlenet-api/badges/gpa.svg)](https://codeclimate.com/github/goodcodeguy/battlenet-api)
2
3
 
3
- TODO:
4
+ ## Installation
5
+
6
+ `$ gem install battlenet-api`
7
+
8
+ ## How to Use
9
+
10
+ ### Configuration
11
+
12
+ ````ruby
13
+ Battlenet.configure do |config|
14
+ config.api_key = 'apikey'
15
+ config.region = :us
16
+ end
17
+ ````
18
+
19
+ ### World of Warcraft Client
20
+
21
+ ````ruby
22
+ client = Battlenet.WOWClient
23
+
24
+ # Available Methods
25
+ client.achievement(id)
26
+ client.auction_data_status(realm)
27
+
28
+ client.battlepet_ability(ability_id)
29
+ client.battlepet_species(species_id)
30
+ client.battlepet_stats(species_id)
31
+
32
+ client.challengemode_realm_leaderboard(realm)
33
+ client.challengemode_region_leaderboard
34
+
35
+ client.character_profile(realm, character_name)
36
+ client.character_achievements(realm, character_name)
37
+ client.character_appearance(realm, character_name)
38
+ client.character_feed(realm, character_name)
39
+ client.character_guild(realm, character_name)
40
+ client.character_hunter_pets(realm, character_name)
41
+ client.character_items(realm, character_name)
42
+ client.character_mounts(realm, character_name)
43
+ client.character_pets(realm, character_name)
44
+ client.character_pet_slots(realm, character_name)
45
+ client.character_progression(realm, character_name)
46
+ client.character_pvp(realm, character_name)
47
+ client.character_quests(realm, character_name)
48
+ client.character_reputation(realm, character_name)
49
+ client.character_stats(realm, character_name)
50
+ client.character_talents(realm, character_name)
51
+ client.character_titles(realm, character_name)
52
+ client.character_audit(realm, character_name)
53
+
54
+ client.data_battlegroups
55
+ client.data_character_races
56
+ client.data_character_classes
57
+ client.data_character_achievements
58
+ client.data_guild_rewards
59
+ client.data_guild_perks
60
+ client.data_guild_achievements
61
+ client.data_item_classes
62
+ client.data_talents
63
+ client.data_pet_types
64
+
65
+ client.guild_profile(realm, guild_name)
66
+ client.guild_members(realm, guild_name)
67
+ client.guild_achievements(realm, guild_name)
68
+ client.guild_news(realm, guild_name)
69
+ client.guild_challenge(realm, guild_name)
70
+
71
+ client.item(item_id)
72
+ client.item_set(set_id)
73
+
74
+ client.pvp_leaderboards(bracket)
75
+
76
+ client.quest(quest_id)
77
+
78
+ client.realm_status
79
+
80
+ client.recipe(recipe_id)
81
+
82
+ client.spell(spell_id)
83
+
84
+ ````
85
+
86
+ ### Diablo 3 Client
87
+
88
+ ````ruby
89
+ client = Battlenet.D3Client
90
+
91
+ #Available Methods
92
+
93
+ client.data_item(data_id)
94
+ client.data_follower(follower_id)
95
+ client.data_artisan(artisan_id)
96
+
97
+ client.career_profile(battletag)
98
+ client.hero_profile(battletag,hero_id)
99
+ ````
100
+
101
+ ### Starcraft 2 Client
102
+
103
+ ````ruby
104
+ client = Battlenet.S2Client
105
+
106
+ #Available Methods
107
+
108
+ client.achievements
109
+ client.rewards
110
+
111
+ client.ladder(ladder_id)
112
+
113
+ client.profile(id, region, name)
114
+ client.profile_ladders(id, region, name)
115
+ client.profile_match_history(id, region, name)
116
+ ````
117
+
118
+
119
+ ## TODO
4
120
 
5
121
  - Community OAuth Profile APIs
6
122
  - Account APIs
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "httparty"
22
- spec.add_dependency "oauth2"
21
+ spec.add_runtime_dependency "httparty", "~> 0.13"
22
+ spec.add_runtime_dependency "oauth2", "~> 1.0"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec", "~> 3.1"
27
27
  end
data/lib/battlenet/api.rb CHANGED
@@ -1,6 +1,26 @@
1
- require 'battlenet/api/version'
1
+ require File.expand_path('../api/version', __FILE__)
2
2
 
3
- require 'battlenet/api/client'
4
- require 'battlenet/api/wow_client'
5
- require 'battlenet/api/sc2_client'
6
- require 'battlenet/api/d3_client'
3
+ require File.expand_path('../api/configuration', __FILE__)
4
+ require File.expand_path('../api/client', __FILE__)
5
+ require File.expand_path('../api/wow_client', __FILE__)
6
+ require File.expand_path('../api/d3_client', __FILE__)
7
+ require File.expand_path('../api/sc2_client', __FILE__)
8
+
9
+
10
+
11
+ module Battlenet
12
+ extend Configuration
13
+
14
+ def self.WOWClient(options={})
15
+ Battlenet::WOWClient.new(options)
16
+ end
17
+
18
+ def self.SC2Client(options={})
19
+ Battlenet::SC2Client.new(options)
20
+ end
21
+
22
+ def self.D3Client(options={})
23
+ Battlenet::D3Client.new(options)
24
+ end
25
+
26
+ end
@@ -6,19 +6,23 @@ module Battlenet
6
6
  class Client
7
7
  include HTTParty
8
8
 
9
- def initialize(api_key = nil, region = :us)
10
-
11
- @api_key = api_key
12
- @endpoint = nil
9
+ attr_accessor *Configuration::OPTIONS_KEYS
13
10
 
14
- domain = region_uri(region)
11
+ def initialize(options={})
12
+
13
+ options = Battlenet.options.merge(client_defaults)
14
+ options = Battlenet.options.merge(options)
15
+
16
+ Configuration::OPTIONS_KEYS.each do |key|
17
+ send("#{key}=", options[key])
18
+ end
15
19
 
16
20
  self.class.base_uri "https://#{domain}#{endpoint}"
17
21
 
18
22
  end
19
23
 
20
- def region_uri(region = :us)
21
- domain = case region
24
+ def domain
25
+ domain = case @region
22
26
  when :us
23
27
  'us.api.battle.net'
24
28
  when :eu
@@ -58,4 +62,4 @@ module Battlenet
58
62
 
59
63
  end
60
64
 
61
- end
65
+ end
@@ -0,0 +1,27 @@
1
+ module Battlenet
2
+ module Configuration
3
+
4
+ OPTIONS_KEYS = [
5
+ :api_key,
6
+ :region,
7
+ :endpoint
8
+ ].freeze
9
+
10
+ DEFAULT_API_KEY = nil
11
+ DEFAULT_ENDPOINT = nil
12
+ DEFAULT_REGION = :us
13
+
14
+ attr_accessor *OPTIONS_KEYS
15
+
16
+ def configure
17
+ yield self
18
+ end
19
+
20
+ def options
21
+ OPTIONS_KEYS.inject({}) do |option, key|
22
+ option.merge!(key => send(key))
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -9,12 +9,8 @@ module Battlenet
9
9
 
10
10
  include Battlenet::D3
11
11
 
12
- def initialize(api_key = nil, region = :us)
13
- super(api_key, region)
14
- end
15
-
16
- def endpoint
17
- @endpoint = '/d3'
12
+ def client_defaults
13
+ { :endpoint => '/d3', :region => :us }
18
14
  end
19
15
 
20
16
  end
@@ -10,12 +10,8 @@ module Battlenet
10
10
 
11
11
  include Battlenet::SC2
12
12
 
13
- def initialize(api_key = nil, region = :us)
14
- super(api_key, region)
15
- end
16
-
17
- def endpoint
18
- @endpoint = '/sc2'
13
+ def client_defaults
14
+ { :endpoint => '/sc2', :region => :us }
19
15
  end
20
16
 
21
17
  end
@@ -1,5 +1,5 @@
1
1
  module Battlenet
2
2
  module Api
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -16,18 +16,14 @@ require 'battlenet/modules/wow/data'
16
16
 
17
17
  module Battlenet
18
18
 
19
- class WOWClient < Client
19
+ class WOWClient < Client
20
20
 
21
- include Battlenet::WOW
22
-
23
- def initialize(api_key = nil, region = :us)
24
- super(api_key, region)
25
- end
26
-
27
- def endpoint
28
- @endpoint = '/wow'
29
- end
21
+ include Battlenet::WOW
30
22
 
23
+ def client_defaults
24
+ { :endpoint => '/wow', :region => :us }
31
25
  end
32
26
 
27
+ end
28
+
33
29
  end
@@ -1,11 +1,11 @@
1
1
  require 'battlenet/api'
2
2
 
3
3
  describe Battlenet::Client do
4
-
5
- it "has a valid factory" do
6
- c = Battlenet::Client.new('5g856v32mx5bwx3rwxzkt9z9yrehtuq2')
4
+ before(:all) do
5
+ Battlenet.configure do |config|
6
+ config.api_key = 'test-api'
7
+ config.region = :us
8
+ end
7
9
  end
8
10
 
9
- it "connects to the battlenet wow community servers"
10
-
11
- end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'battlenet/api'
2
+
3
+ describe Battlenet::D3Client do
4
+ before(:all) do
5
+ Battlenet.configure do |config|
6
+ config.api_key = 'test-d3client-api'
7
+ config.region = :us
8
+ end
9
+ end
10
+
11
+ it "should pass the api key to the d3 client" do
12
+ c = Battlenet.D3Client
13
+ expect(c.api_key).to eq('test-d3client-api')
14
+ end
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) }
22
+
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'battlenet/api'
2
+
3
+ describe Battlenet::SC2Client do
4
+ before(:all) do
5
+ Battlenet.configure do |config|
6
+ config.api_key = 'test-sc2client-api'
7
+ config.region = :us
8
+ end
9
+ end
10
+
11
+ it "should pass the api key to the SC2 client" do
12
+ c = Battlenet.SC2Client
13
+ expect(c.api_key).to eq('test-sc2client-api')
14
+ end
15
+
16
+ it { should respond_to(:achievements) }
17
+ it { should respond_to(:rewards) }
18
+
19
+ it { should respond_to(:ladder) }
20
+
21
+ it { should respond_to(:profile) }
22
+ it { should respond_to(:profile_ladders) }
23
+ it { should respond_to(:profile_match_history) }
24
+
25
+ end
@@ -0,0 +1,75 @@
1
+ require 'battlenet/api'
2
+
3
+ describe Battlenet::WOWClient do
4
+ before(:all) do
5
+ Battlenet.configure do |config|
6
+ config.api_key = 'test-wow-api-key'
7
+ config.region = :us
8
+ end
9
+ end
10
+
11
+ it "should pass the api key to the wow client" do
12
+ c = Battlenet.WOWClient
13
+ expect(c.api_key).to eq('test-wow-api-key')
14
+ end
15
+
16
+ it { should respond_to(:achievement) }
17
+ it { should respond_to(:auction_data_status) }
18
+
19
+ it { should respond_to(:battlepet_ability) }
20
+ it { should respond_to(:battlepet_species) }
21
+ it { should respond_to(:battlepet_stats) }
22
+
23
+ it { should respond_to(:challengemode_realm_leaderboard) }
24
+ it { should respond_to(:challengemode_region_leaderboard) }
25
+
26
+ it { should respond_to(:character_profile) }
27
+ it { should respond_to(:character_achievements) }
28
+ it { should respond_to(:character_appearance) }
29
+ it { should respond_to(:character_feed) }
30
+ it { should respond_to(:character_guild) }
31
+ it { should respond_to(:character_hunter_pets) }
32
+ it { should respond_to(:character_items) }
33
+ it { should respond_to(:character_mounts) }
34
+ it { should respond_to(:character_pets) }
35
+ it { should respond_to(:character_pet_slots) }
36
+ it { should respond_to(:character_progression) }
37
+ it { should respond_to(:character_pvp) }
38
+ it { should respond_to(:character_quests) }
39
+ it { should respond_to(:character_reputation) }
40
+ it { should respond_to(:character_stats) }
41
+ it { should respond_to(:character_talents) }
42
+ it { should respond_to(:character_titles) }
43
+ it { should respond_to(:character_audit) }
44
+
45
+ it { should respond_to(:data_battlegroups) }
46
+ it { should respond_to(:data_character_races) }
47
+ it { should respond_to(:data_character_classes) }
48
+ it { should respond_to(:data_character_achievements) }
49
+ it { should respond_to(:data_guild_rewards) }
50
+ it { should respond_to(:data_guild_perks) }
51
+ it { should respond_to(:data_guild_achievements) }
52
+ it { should respond_to(:data_item_classes) }
53
+ it { should respond_to(:data_talents) }
54
+ it { should respond_to(:data_pet_types) }
55
+
56
+ it { should respond_to(:guild_profile) }
57
+ it { should respond_to(:guild_members) }
58
+ it { should respond_to(:guild_achievements) }
59
+ it { should respond_to(:guild_news) }
60
+ it { should respond_to(:guild_challenge) }
61
+
62
+ it { should respond_to(:item) }
63
+ it { should respond_to(:item_set) }
64
+
65
+ it { should respond_to(:pvp_leaderboards)}
66
+
67
+ it { should respond_to(:quest) }
68
+
69
+ it { should respond_to(:realm_status) }
70
+
71
+ it { should respond_to(:recipe) }
72
+
73
+ it { should respond_to(:spell) }
74
+
75
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: battlenet-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - goodcodeguy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-13 00:00:00.000000000 Z
11
+ date: 2014-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '3.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '3.1'
83
83
  description: API Wrapper for the Battlenet API
84
84
  email:
85
85
  - goodcodeguy@gmail.com
@@ -96,6 +96,7 @@ files:
96
96
  - examples/example_oauth.rb
97
97
  - lib/battlenet/api.rb
98
98
  - lib/battlenet/api/client.rb
99
+ - lib/battlenet/api/configuration.rb
99
100
  - lib/battlenet/api/d3_client.rb
100
101
  - lib/battlenet/api/sc2_client.rb
101
102
  - lib/battlenet/api/version.rb
@@ -119,6 +120,9 @@ files:
119
120
  - lib/battlenet/modules/wow/recipe.rb
120
121
  - lib/battlenet/modules/wow/spell.rb
121
122
  - spec/battlenetapi_spec.rb
123
+ - spec/d3client_spec.rb
124
+ - spec/sc2client_spec.rb
125
+ - spec/wowclient_spec.rb
122
126
  homepage: https://github.com/goodcodeguy/battlenet-api
123
127
  licenses:
124
128
  - MIT
@@ -145,3 +149,6 @@ specification_version: 4
145
149
  summary: Battlenet Client API
146
150
  test_files:
147
151
  - spec/battlenetapi_spec.rb
152
+ - spec/d3client_spec.rb
153
+ - spec/sc2client_spec.rb
154
+ - spec/wowclient_spec.rb