blizzard_api 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.rubocop_todo.yml +0 -6
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile.lock +2 -2
  6. data/README.md +93 -34
  7. data/lib/blizzard_api/configuration.rb +32 -0
  8. data/lib/blizzard_api/request.rb +17 -10
  9. data/lib/blizzard_api/version.rb +1 -1
  10. data/lib/blizzard_api/wow.rb +111 -47
  11. data/lib/blizzard_api/wow/community/character.rb +1 -22
  12. data/lib/blizzard_api/wow/game_data/achievement.rb +101 -0
  13. data/lib/blizzard_api/wow/game_data/connected_realm.rb +1 -15
  14. data/lib/blizzard_api/wow/game_data/creature.rb +99 -0
  15. data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +14 -7
  16. data/lib/blizzard_api/wow/{community → game_data}/guild.rb +42 -3
  17. data/lib/blizzard_api/wow/game_data/guild_crest.rb +50 -0
  18. data/lib/blizzard_api/wow/game_data/mount.rb +37 -0
  19. data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +97 -0
  20. data/lib/blizzard_api/wow/game_data/mythic_keystone_leaderboard.rb +48 -0
  21. data/lib/blizzard_api/wow/game_data/mythic_raid_leaderboard.rb +28 -0
  22. data/lib/blizzard_api/wow/{community/pets.rb → game_data/pet.rb} +14 -1
  23. data/lib/blizzard_api/wow/game_data/playable_class.rb +10 -4
  24. data/lib/blizzard_api/wow/game_data/pvp_season.rb +53 -0
  25. data/lib/blizzard_api/wow/game_data/pvp_tier.rb +33 -0
  26. data/lib/blizzard_api/wow/game_data/race.rb +1 -15
  27. data/lib/blizzard_api/wow/game_data/realm.rb +0 -14
  28. data/lib/blizzard_api/wow/game_data/region.rb +0 -13
  29. data/lib/blizzard_api/wow/game_data/wow_token.rb +25 -0
  30. data/lib/blizzard_api/wow/profile/character_profile.rb +77 -0
  31. metadata +15 -6
  32. data/lib/blizzard_api/wow/community/achievements.rb +0 -45
  33. data/lib/blizzard_api/wow/community/mount.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 986e5045b51505acbdcbe757c1cab63997ae59ccd517ea10f31e53005a6a59d0
4
- data.tar.gz: d0cc98867e15d90d40418474e5b3be6e3fdac5dd06b6bb0d065c94d32e879882
3
+ metadata.gz: 9c949d92a0d0319778a898e3e42f3d96b4a6e2328735cea5e04be4793411fd7f
4
+ data.tar.gz: 1878247e2dbe3f00dd97350c8335fb624100fa69d244c897a054812df2e7b295
5
5
  SHA512:
6
- metadata.gz: 84d3dbf1f764c2ebfc05d91ae9f78c0e081f722b10b03874c97b710cbac0357fdfa03d2272c833c5ca5726eb69c0a79c68af56552f945b1f6f08c74f991de94c
7
- data.tar.gz: 4622761622e15884190e238d79f4fd00ae26091098394c84673a8a6d8c465e09773038b1bd85e5169d6da72cbcb8a21984025477a96a5c95dc05228c16af1e52
6
+ metadata.gz: 9f3d4741c338306be140799708a739b56e907b5f740697db53175a1147ca897cb2457008e41ece15d4173eeba16ebf7aa5c3bb6b0a16c6243c5efb00f0075bc7
7
+ data.tar.gz: 48c7583dbc4a25200789f7ec4443670a9f0769f34ab035cf058fee3ae3a78b12234e95f2da476925bbd86621a8dde70ed57501a7c71c84969dbdb97de0bda80a
data/.rubocop.yml CHANGED
@@ -3,6 +3,10 @@ inherit_from: .rubocop_todo.yml
3
3
  Metrics/LineLength:
4
4
  Max: 120
5
5
 
6
+ Metrics/ModuleLength:
7
+ Exclude:
8
+ - 'lib/blizzard_api/wow.rb'
9
+
6
10
  Metrics/AbcSize:
7
11
  Max: 20
8
12
 
data/.rubocop_todo.yml CHANGED
@@ -5,9 +5,3 @@
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 3
10
- Lint/UriEscapeUnescape:
11
- Exclude:
12
- - 'lib/blizzard_api/wow/community/character.rb'
13
- - 'lib/blizzard_api/wow/community/guild.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 0.2.2**
4
+ * Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20771546990
5
+
3
6
  **Version 0.2.1**
4
7
  * Added icon to playable_class return value
5
8
  * Temporarily ignoring some rubocop offenses as the recommended alternatives are not suitable
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (0.2.0)
4
+ blizzard_api (0.2.2)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
@@ -17,7 +17,7 @@ GEM
17
17
  powerpack (0.1.2)
18
18
  rainbow (3.0.0)
19
19
  rake (10.5.0)
20
- redis (4.1.0)
20
+ redis (4.1.1)
21
21
  rubocop (0.61.1)
22
22
  jaro_winkler (~> 1.5.1)
23
23
  parallel (~> 1.10)
data/README.md CHANGED
@@ -11,7 +11,7 @@ This gem allow you to interface with the new blizzard api (2018) using the OAuth
11
11
  ## Table of contents
12
12
  1. [Installation](#1-installation)
13
13
  2. [Configuration](#2-configuration)
14
- 3. [Basic usage](#1-basic-usage)
14
+ 3. [Basic usage](#3-basic-usage)
15
15
  4. [Available endpoints](#4-available-endpoints)
16
16
  - 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
17
17
  - 4.2. [Diablo III endpoints](#42-diablo-iii-endpoints)
@@ -36,7 +36,7 @@ Before you use the api you must create a developer account at https://develop.ba
36
36
  Once you have a pair of client ID and SECRET you must set up an initialization code.
37
37
 
38
38
  ```ruby
39
- Blizzard.configure do |config|
39
+ BlizzardApi.configure do |config|
40
40
  config.app_id = ENV['BNET_APPLICATION_ID']
41
41
  config.app_secret = ENV['BNET_APPLICATION_SECRET']
42
42
  config.region = 'us'
@@ -84,78 +84,137 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
84
84
 
85
85
  * Blizzard::Wow::Achievement
86
86
  - get :id
87
+ - index
88
+ - categories
89
+ - category :id
87
90
  - character_achievement_index
88
91
  - guild_achievement_index
89
- * Blizzard::Wow::Auction
90
- - get :realm
91
- * Blizzard::Wow::Boss
92
+ - media :id
93
+ * Blizzard::Wow::ConnectedRealm
92
94
  - index
93
95
  - get :id
94
- * Blizzard::Wow::Challenge
95
- - realm_index
96
- - region_index
97
- * Blizzard::Wow::Character
98
- - get :realm, :character, :fields
99
- - get_keystone_profile :realm, :character, :user_token, :season
100
- - get_user_characters :user_token
96
+ - complete
97
+ * Blizzard::Wow::Creature
98
+ - get :id
99
+ - families
100
+ - family :id
101
+ - family_media :id
102
+ - types
103
+ - type :id
104
+ - display_media :id
101
105
  * Blizzard::Wow::Guild
102
- - get :relam, :name, :fields
103
106
  - rewards
104
107
  - perks
105
- * Blizzard::Wow::Item
108
+ - get :realm, :guild
109
+ - roster :realm, :guild
110
+ - achievements :realm, :guild
111
+ * Blizzard::Wow::GuildCrest
112
+ - index
113
+ - border_media :id
114
+ - emblem_media :id
115
+ * Blizzard::Wow::MythicKeystonesAffix
116
+ - index
106
117
  - get :id
107
- - item_set :setId
118
+ - complete
119
+ * Blizzard::Wow::MythicKeystone
120
+ - index
121
+ - dungeons
122
+ - dungeon :id
123
+ - periods
124
+ - period :id
125
+ - seasons
126
+ - season :id
127
+ * Blizzard::Wow::MythicRaidLeaderboard
128
+ - get :raid_slug, :faction_slug
108
129
  * Blizzard::Wow::Mount
109
130
  - index
131
+ - get :id
132
+ - complete
133
+ * Blizzard::Wow::MythicKeystoneLeaderboard
134
+ - index :connected_realm_id
135
+ - get :connected_realm_id, :dungeon_id, :period
110
136
  * Blizzard::Wow::Pet
111
137
  - index
138
+ - get
112
139
  - ability :id
113
140
  - species :id
114
141
  - stats :level, :breed_id, :quality_id
115
142
  - types
116
- * Blizzard::Wow::PvP
117
- - get :bracket
118
- * Blizzard::Wow::Quest
119
- - get :id
120
- * Blizzard::Wow::Recipe
121
- - get :id
122
- * Blizzard::Wow::Spell
123
- - get :id
124
- * Blizzard::Wow::Zone
143
+ * Blizzard::Wow::PlayableClass
125
144
  - index
126
145
  - get :id
127
- * Blizzard::Wow::ConnectedRealm
146
+ - complete
147
+ - talent_slots :id
148
+ * Blizzard::Wow::PlayableSpecialization
128
149
  - index
129
150
  - get :id
130
151
  - complete
131
- * Blizzard::Wow::MythicKeystonesAffix
152
+ * Blizzard::Wow::PowerType
132
153
  - index
133
154
  - get :id
134
155
  - complete
135
- * Blizzard::Wow::PlayableClass
156
+ * Blizzard::Wow::PvpSeason
136
157
  - index
137
158
  - get :id
138
- - complete
139
- * Blizzard::Wow::PlayableSpecialization
159
+ - leaderboards :season_id
160
+ - leaderboard :season_id, :brackets
161
+ - rewards :season_id
162
+ * Blizzard::Wow::PvpTier
163
+ - index
164
+ - get :id
165
+ - tier_media :id
166
+ * Blizzard::Wow::Realm
140
167
  - index
141
168
  - get :id
142
169
  - complete
143
- * Blizzard::Wow::PowerType
170
+ * Blizzard::Wow::Region
144
171
  - index
145
172
  - get :id
146
173
  - complete
174
+ * Blizzard::Wow::WowToken
175
+ - get
147
176
  * Blizzard::Wow::Race
148
177
  - index
149
178
  - get :id
150
179
  - complete
151
- * Blizzard::Wow::Realm
180
+
181
+
182
+ * Blizzard::Wow::Auction
183
+ - get :realm
184
+ * Blizzard::Wow::Boss
152
185
  - index
153
186
  - get :id
154
- - complete
155
- * Blizzard::Wow::Region
187
+ * Blizzard::Wow::Challenge
188
+ - realm_index
189
+ - region_index
190
+ * Blizzard::Wow::Character
191
+ - get :realm, :character, :fields
192
+ - get_keystone_profile :realm, :character, :user_token, :season
193
+ - get_user_characters :user_token
194
+ * Blizzard::Wow::Guild
195
+ - get :relam, :name, :fields
196
+ - rewards
197
+ - perks
198
+ * Blizzard::Wow::Item
199
+ - get :id
200
+ - item_set :setId
201
+ * Blizzard::Wow::PvP
202
+ - get :bracket
203
+ * Blizzard::Wow::Quest
204
+ - get :id
205
+ * Blizzard::Wow::Recipe
206
+ - get :id
207
+ * Blizzard::Wow::Spell
208
+ - get :id
209
+ * Blizzard::Wow::Zone
156
210
  - index
157
211
  - get :id
158
- - complete
212
+
213
+
214
+ * BlizzardApi::Wow::CharacterProfile
215
+ - get_keystone_profile :realm, :character, :user_token, :season
216
+ - pvp_summmary :realm, :character, :user_token
217
+ - pvp_bracket :realm, :character, :bracket, :user_token
159
218
 
160
219
  ### 4.2. Diablo III endpoints
161
220
 
@@ -59,6 +59,33 @@ module BlizzardApi
59
59
  # @return [String] Access token.
60
60
  attr_accessor :access_token
61
61
 
62
+ ##
63
+ # @!attribute icons_directory
64
+ # Icons directory.
65
+ # This directory stores icons for many World of Warcraft endpoints.
66
+ # @return [String] icons_directory
67
+ attr_accessor :wow_icons_directory
68
+
69
+ ##
70
+ # @!attribute guild_emblem_directory
71
+ # Guild crest images directory. Some sub directories will be crated.
72
+ # @see https://develop.battle.net/access/clients
73
+ # @return [String] Guild crest directory
74
+ attr_accessor :wow_guild_crest_directory
75
+
76
+ ##
77
+ # @!attribute wow_character_profile_directory
78
+ # This directory stores images for World of Warcraft character profiles. Sub directories will be created for
79
+ # each realm and character.
80
+ # @return [String] Character profile media directory
81
+ attr_accessor :wow_character_profile_directory
82
+
83
+ ##
84
+ # @!attribute wow_npc_directory
85
+ # This directory stores images for World of Warcraft NPCs and creatures.
86
+ # @return [String] NPCs media directory
87
+ attr_accessor :wow_npc_directory
88
+
62
89
  ##
63
90
  # This method return the singleton instance of the configuration module. Use this to initialize the default values
64
91
  # and options.
@@ -70,10 +97,15 @@ module BlizzardApi
70
97
  # config.app_id = ENV['BNET_APPLICATION_ID']
71
98
  # config.app_secret = ENV['BNET_APPLICATION_SECRET']
72
99
  # config.region = 'us'
100
+ #
73
101
  # config.use_cache = true
74
102
  # config.redis_host = ENV['REDIS_HOST']
75
103
  # config.redis_port = ENV['REDIS_PORT']
76
104
  # config.format = :json
105
+ #
106
+ # config.icons_directory = './wow/icons'
107
+ # config.guild_crest_directory = './wow/guild_crest'
108
+ # config.wow_character_profile_directory = './wow/profile'
77
109
  # end
78
110
  def configure
79
111
  yield self
@@ -45,6 +45,14 @@ module BlizzardApi
45
45
  # Three (commercial) months cache
46
46
  CACHE_TRIMESTER = CACHE_MONTH * 3
47
47
 
48
+ # Common endpoints
49
+ BASE_URLS = {
50
+ game_data: 'https://%s.api.blizzard.com/data/%s',
51
+ community: 'https://%s.api.blizzard.com/%s',
52
+ profile: 'https://%s.api.blizzard.com/profile/%s',
53
+ media: 'https://%s.api.blizzard.com/data/%s/media'
54
+ }.freeze
55
+
48
56
  ##
49
57
  # @!attribute region
50
58
  # @return [String] Api region
@@ -67,16 +75,9 @@ module BlizzardApi
67
75
  protected
68
76
 
69
77
  def base_url(scope)
70
- case scope
71
- when :game_data
72
- "https://#{region}.api.blizzard.com/data/#{@game}"
73
- when :community
74
- "https://#{region}.api.blizzard.com/#{@game}"
75
- when :profile
76
- "https://#{region}.api.blizzard.com/profile/#{@game}"
77
- else
78
- raise ArgumentError
79
- end
78
+ raise ArgumentError, 'Invalid scope' unless BASE_URLS.include? scope
79
+
80
+ format BASE_URLS[scope], region, @game
80
81
  end
81
82
 
82
83
  ##
@@ -89,11 +90,17 @@ module BlizzardApi
89
90
  "dynamic-#{region}"
90
91
  when :static
91
92
  "static-#{region}"
93
+ when :profile
94
+ "profile-#{region}"
92
95
  else
93
96
  raise ArgumentError, 'Invalid namespace scope'
94
97
  end
95
98
  end
96
99
 
100
+ def string_to_slug(string)
101
+ string.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')
102
+ end
103
+
97
104
  def create_access_token
98
105
  uri = URI.parse("https://#{BlizzardApi.region}.battle.net/oauth/token")
99
106
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.2'
6
6
  end
@@ -7,25 +7,31 @@ module BlizzardApi
7
7
  require_relative 'wow/game_data/generic_data_endpoint'
8
8
 
9
9
  # WoW data api
10
- require_relative 'wow/game_data/region'
11
- require_relative 'wow/game_data/realm'
10
+ require_relative 'wow/game_data/achievement'
12
11
  require_relative 'wow/game_data/connected_realm'
13
- require_relative 'wow/game_data/race'
12
+ require_relative 'wow/game_data/creature'
13
+ require_relative 'wow/game_data/guild'
14
+ require_relative 'wow/game_data/guild_crest'
15
+ require_relative 'wow/game_data/mythic_keystone_affix'
16
+ require_relative 'wow/game_data/mythic_keystone'
17
+ require_relative 'wow/game_data/mythic_raid_leaderboard'
18
+ require_relative 'wow/game_data/mount'
19
+ require_relative 'wow/game_data/mythic_keystone_leaderboard'
20
+ require_relative 'wow/game_data/pet'
14
21
  require_relative 'wow/game_data/playable_class'
15
22
  require_relative 'wow/game_data/playable_specialization'
16
23
  require_relative 'wow/game_data/power_type'
17
- require_relative 'wow/game_data/mythic_keystone_affix'
18
-
19
- ##
20
- # @return {Region}
21
- def self.region
22
- BlizzardApi::Wow::Region.new
23
- end
24
+ require_relative 'wow/game_data/pvp_season'
25
+ require_relative 'wow/game_data/pvp_tier'
26
+ require_relative 'wow/game_data/realm'
27
+ require_relative 'wow/game_data/region'
28
+ require_relative 'wow/game_data/wow_token'
29
+ require_relative 'wow/game_data/race'
24
30
 
25
31
  ##
26
- # @return {Realm}
27
- def self.realm
28
- BlizzardApi::Wow::Realm.new
32
+ # @return {Achievement}
33
+ def self.achievement
34
+ BlizzardApi::Wow::Achievement.new
29
35
  end
30
36
 
31
37
  ##
@@ -35,9 +41,57 @@ module BlizzardApi
35
41
  end
36
42
 
37
43
  ##
38
- # @return {Race}
39
- def self.race
40
- BlizzardApi::Wow::Race.new
44
+ # @return {Creature}
45
+ def self.creature
46
+ BlizzardApi::Wow::Creature.new
47
+ end
48
+
49
+ ##
50
+ # @return {Guild}
51
+ def self.guild
52
+ BlizzardApi::Wow::Guild.new
53
+ end
54
+
55
+ ##
56
+ # @return {GuildCrest}
57
+ def self.guild_crest
58
+ BlizzardApi::Wow::GuildCrest.new
59
+ end
60
+
61
+ ##
62
+ # @return {MythicKeystoneAffix}
63
+ def self.mythic_keystone_affix
64
+ BlizzardApi::Wow::MythicKeystoneAffix.new
65
+ end
66
+
67
+ ##
68
+ # @return {MythicKeystone}
69
+ def self.mythic_keystone
70
+ BlizzardApi::Wow::MythicKeystone.new
71
+ end
72
+
73
+ ##
74
+ # @return {MythicRaidLeaderboard}
75
+ def self.mythic_raid_leaderboard
76
+ BlizzardApi::Wow::MythicRaidLeaderboard.new
77
+ end
78
+
79
+ ##
80
+ # @return {Mount}
81
+ def self.mount
82
+ BlizzardApi::Wow::Mount.new
83
+ end
84
+
85
+ ##
86
+ # @return {MythicKeystoneLeaderboard}
87
+ def self.mythic_keystone_leaderboard
88
+ BlizzardApi::Wow::MythicKeystoneLeaderboard.new
89
+ end
90
+
91
+ ##
92
+ # @return {Pet}
93
+ def self.pet
94
+ BlizzardApi::Wow::Pet.new
41
95
  end
42
96
 
43
97
  ##
@@ -59,33 +113,53 @@ module BlizzardApi
59
113
  end
60
114
 
61
115
  ##
62
- # @return {MythicKeystoneAffix}
63
- def self.mythic_keystone_affix
64
- BlizzardApi::Wow::MythicKeystoneAffix.new
116
+ # @return {PvpSeason}
117
+ def self.pvp_season
118
+ BlizzardApi::Wow::PvpSeason.new
119
+ end
120
+
121
+ ##
122
+ # @return {PvpTier}
123
+ def self.pvp_tier
124
+ BlizzardApi::Wow::PvpTier.new
125
+ end
126
+
127
+ ##
128
+ # @return {Realm}
129
+ def self.realm
130
+ BlizzardApi::Wow::Realm.new
131
+ end
132
+
133
+ ##
134
+ # @return {Region}
135
+ def self.region
136
+ BlizzardApi::Wow::Region.new
137
+ end
138
+
139
+ ##
140
+ # @return {WowToken}
141
+ def self.wow_token
142
+ BlizzardApi::Wow::WowToken.new
143
+ end
144
+
145
+ ##
146
+ # @return {Race}
147
+ def self.race
148
+ BlizzardApi::Wow::Race.new
65
149
  end
66
150
 
67
151
  # Wow community api
68
- require_relative 'wow/community/achievements'
69
152
  require_relative 'wow/community/auction'
70
153
  require_relative 'wow/community/boss'
71
154
  require_relative 'wow/community/challenge'
72
155
  require_relative 'wow/community/character'
73
- require_relative 'wow/community/guild'
74
156
  require_relative 'wow/community/item'
75
- require_relative 'wow/community/mount'
76
- require_relative 'wow/community/pets'
77
157
  require_relative 'wow/community/pvp'
78
158
  require_relative 'wow/community/quest'
79
159
  require_relative 'wow/community/recipe'
80
160
  require_relative 'wow/community/spell'
81
161
  require_relative 'wow/community/zone'
82
162
 
83
- ##
84
- # @return {Achievement}
85
- def self.achievement
86
- BlizzardApi::Wow::Achievement.new
87
- end
88
-
89
163
  ##
90
164
  # @return {Auction}
91
165
  def self.auction
@@ -110,30 +184,12 @@ module BlizzardApi
110
184
  BlizzardApi::Wow::Character.new
111
185
  end
112
186
 
113
- ##
114
- # @return {Guild}
115
- def self.guild
116
- BlizzardApi::Wow::Guild.new
117
- end
118
-
119
187
  ##
120
188
  # @return {Item}
121
189
  def self.item
122
190
  BlizzardApi::Wow::Item.new
123
191
  end
124
192
 
125
- ##
126
- # @return {Mount}
127
- def self.mount
128
- BlizzardApi::Wow::Mount.new
129
- end
130
-
131
- ##
132
- # @return {Pet}
133
- def self.pet
134
- BlizzardApi::Wow::Pet.new
135
- end
136
-
137
193
  ##
138
194
  # @return {PvP}
139
195
  def self.pvp
@@ -163,5 +219,13 @@ module BlizzardApi
163
219
  def self.zone
164
220
  BlizzardApi::Wow::Zone.new
165
221
  end
222
+
223
+ require_relative 'wow/profile/character_profile'
224
+
225
+ ##
226
+ # @return {CharacterProfile}
227
+ def self.character_profile
228
+ BlizzardApi::Wow::CharacterProfile.new
229
+ end
166
230
  end
167
231
  end