blizzard_api 0.6.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Gemfile.lock +12 -14
  4. data/blizzard_api.gemspec +0 -1
  5. data/lib/blizzard_api/api_standards.rb +55 -0
  6. data/lib/blizzard_api/configuration.rb +20 -17
  7. data/lib/blizzard_api/diablo/community/profile.rb +4 -4
  8. data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +2 -2
  9. data/lib/blizzard_api/diablo/request.rb +3 -3
  10. data/lib/blizzard_api/diablo.rb +33 -27
  11. data/lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb +2 -2
  12. data/lib/blizzard_api/hearthstone/request.rb +3 -3
  13. data/lib/blizzard_api/hearthstone.rb +18 -12
  14. data/lib/blizzard_api/request.rb +27 -76
  15. data/lib/blizzard_api/starcraft/community/account.rb +1 -1
  16. data/lib/blizzard_api/starcraft/community/legacy.rb +6 -6
  17. data/lib/blizzard_api/starcraft/request.rb +3 -3
  18. data/lib/blizzard_api/starcraft.rb +20 -14
  19. data/lib/blizzard_api/token_manager.rb +49 -0
  20. data/lib/blizzard_api/version.rb +1 -1
  21. data/lib/blizzard_api/wow/game_data/achievement.rb +1 -16
  22. data/lib/blizzard_api/wow/game_data/azerite_essence.rb +2 -9
  23. data/lib/blizzard_api/wow/game_data/connected_realm.rb +1 -8
  24. data/lib/blizzard_api/wow/game_data/covenant.rb +2 -9
  25. data/lib/blizzard_api/wow/game_data/creature.rb +2 -13
  26. data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +10 -37
  27. data/lib/blizzard_api/wow/game_data/guild_crest.rb +4 -10
  28. data/lib/blizzard_api/wow/game_data/item.rb +3 -18
  29. data/lib/blizzard_api/wow/game_data/journal.rb +2 -17
  30. data/lib/blizzard_api/wow/game_data/media.rb +2 -13
  31. data/lib/blizzard_api/wow/game_data/modified_crafting.rb +1 -12
  32. data/lib/blizzard_api/wow/game_data/mount.rb +1 -8
  33. data/lib/blizzard_api/wow/game_data/mythic_keystone.rb +2 -13
  34. data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +2 -9
  35. data/lib/blizzard_api/wow/game_data/pet.rb +2 -9
  36. data/lib/blizzard_api/wow/game_data/playable_class.rb +2 -23
  37. data/lib/blizzard_api/wow/game_data/playable_race.rb +1 -8
  38. data/lib/blizzard_api/wow/game_data/playable_specialization.rb +1 -18
  39. data/lib/blizzard_api/wow/game_data/power_type.rb +1 -8
  40. data/lib/blizzard_api/wow/game_data/profession.rb +2 -9
  41. data/lib/blizzard_api/wow/game_data/pvp_region.rb +82 -0
  42. data/lib/blizzard_api/wow/game_data/pvp_season.rb +7 -9
  43. data/lib/blizzard_api/wow/game_data/pvp_tier.rb +3 -10
  44. data/lib/blizzard_api/wow/game_data/quest.rb +2 -9
  45. data/lib/blizzard_api/wow/game_data/realm.rb +1 -8
  46. data/lib/blizzard_api/wow/game_data/region.rb +1 -8
  47. data/lib/blizzard_api/wow/game_data/reputation.rb +2 -9
  48. data/lib/blizzard_api/wow/game_data/spell.rb +2 -17
  49. data/lib/blizzard_api/wow/game_data/talent.rb +2 -9
  50. data/lib/blizzard_api/wow/game_data/tech_talent.rb +2 -9
  51. data/lib/blizzard_api/wow/game_data/title.rb +1 -16
  52. data/lib/blizzard_api/wow/profile/profile.rb +3 -3
  53. data/lib/blizzard_api/wow/request.rb +3 -3
  54. data/lib/blizzard_api/wow/search/search_composer.rb +2 -2
  55. data/lib/blizzard_api/wow.rb +122 -108
  56. data/lib/blizzard_api.rb +9 -0
  57. metadata +5 -16
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # @!macro [new] init_options
5
+ # @param options [Hash] Initialization options
6
+ # @option options [String] :region API region
7
+ # @option options [Symbol] :model API mode (:regular, :extended)
8
+
3
9
  module BlizzardApi
4
10
  # World of Warcraft related classes
5
11
  module Wow
@@ -32,6 +38,7 @@ module BlizzardApi
32
38
  require_relative 'wow/game_data/playable_specialization'
33
39
  require_relative 'wow/game_data/power_type'
34
40
  require_relative 'wow/game_data/profession'
41
+ require_relative 'wow/game_data/pvp_region'
35
42
  require_relative 'wow/game_data/pvp_season'
36
43
  require_relative 'wow/game_data/pvp_tier'
37
44
  require_relative 'wow/game_data/quest'
@@ -45,234 +52,241 @@ module BlizzardApi
45
52
  require_relative 'wow/game_data/wow_token'
46
53
 
47
54
  ##
48
- # @param region [String] API Region
55
+ # @!macro init_options
49
56
  # @return {Achievement}
50
- def self.achievement(region = BlizzardApi.region)
51
- BlizzardApi::Wow::Achievement.new(region)
57
+ def self.achievement(**options)
58
+ BlizzardApi::Wow::Achievement.new(**options)
52
59
  end
53
60
 
54
61
  ##
55
- # @param region [String] API Region
62
+ # @!macro init_options
56
63
  # @return {Auction}
57
- def self.auction(region = BlizzardApi.region)
58
- BlizzardApi::Wow::Auction.new(region)
64
+ def self.auction(**options)
65
+ BlizzardApi::Wow::Auction.new(**options)
59
66
  end
60
67
 
61
68
  ##
62
- # @param region [String] API Region
69
+ # @!macro init_options
63
70
  # @return {AzeriteEssence}
64
- def self.azerite_essence(region = BlizzardApi.region)
65
- BlizzardApi::Wow::AzeriteEssence.new(region)
71
+ def self.azerite_essence(**options)
72
+ BlizzardApi::Wow::AzeriteEssence.new(**options)
66
73
  end
67
74
 
68
75
  ##
69
- # @param region [String] API Region
76
+ # @!macro init_options
70
77
  # @return {ConnectedRealm}
71
- def self.connected_realm(region = BlizzardApi.region)
72
- BlizzardApi::Wow::ConnectedRealm.new(region)
78
+ def self.connected_realm(**options)
79
+ BlizzardApi::Wow::ConnectedRealm.new(**options)
73
80
  end
74
81
 
75
82
  ##
76
- # @param region [String] API Region
83
+ # @!macro init_options
77
84
  # @return {Covenant}
78
- def self.covenant(region = BlizzardApi.region)
79
- BlizzardApi::Wow::Covenant.new(region)
85
+ def self.covenant(**options)
86
+ BlizzardApi::Wow::Covenant.new(**options)
80
87
  end
81
88
 
82
89
  ##
83
- # @param region [String] API Region
90
+ # @!macro init_options
84
91
  # @return {Creature}
85
- def self.creature(region = BlizzardApi.region)
86
- BlizzardApi::Wow::Creature.new(region)
92
+ def self.creature(**options)
93
+ BlizzardApi::Wow::Creature.new(**options)
87
94
  end
88
95
 
89
96
  ##
90
- # @param region [String] API Region
97
+ # @!macro init_options
91
98
  # @return {GuildCrest}
92
- def self.guild_crest(region = BlizzardApi.region)
93
- BlizzardApi::Wow::GuildCrest.new(region)
99
+ def self.guild_crest(**options)
100
+ BlizzardApi::Wow::GuildCrest.new(**options)
94
101
  end
95
102
 
96
103
  ##
97
- # @param region [String] API Region
104
+ # @!macro init_options
98
105
  # @return {Item}
99
- def self.item(region = BlizzardApi.region)
100
- BlizzardApi::Wow::Item.new(region)
106
+ def self.item(**options)
107
+ BlizzardApi::Wow::Item.new(**options)
101
108
  end
102
109
 
103
110
  ##
104
- # @param region [String] API Region
111
+ # @!macro init_options
105
112
  # @return {Journal}
106
- def self.journal(region = BlizzardApi.region)
107
- BlizzardApi::Wow::Journal.new(region)
113
+ def self.journal(**options)
114
+ BlizzardApi::Wow::Journal.new(**options)
108
115
  end
109
116
 
110
117
  ##
111
- # @param region [String] API Region
118
+ # @!macro init_options
112
119
  # @return {Media}
113
- def self.media(region = BlizzardApi.region)
114
- BlizzardApi::Wow::Media.new(region)
120
+ def self.media(**options)
121
+ BlizzardApi::Wow::Media.new(**options)
115
122
  end
116
123
 
117
124
  ##
118
- # @param region [String] API Region
125
+ # @!macro init_options
119
126
  # @return {ModifiedCrafting}
120
- def self.modified_crafting(region = BlizzardApi.region)
121
- BlizzardApi::Wow::ModifiedCrafting.new(region)
127
+ def self.modified_crafting(**options)
128
+ BlizzardApi::Wow::ModifiedCrafting.new(**options)
122
129
  end
123
130
 
124
131
  ##
125
- # @param region [String] API Region
132
+ # @!macro init_options
126
133
  # @return {Mount}
127
- def self.mount(region = BlizzardApi.region)
128
- BlizzardApi::Wow::Mount.new(region)
134
+ def self.mount(**options)
135
+ BlizzardApi::Wow::Mount.new(**options)
129
136
  end
130
137
 
131
138
  ##
132
- # @param region [String] API Region
139
+ # @!macro init_options
133
140
  # @return {MythicKeystoneAffix}
134
- def self.mythic_keystone_affix(region = BlizzardApi.region)
135
- BlizzardApi::Wow::MythicKeystoneAffix.new(region)
141
+ def self.mythic_keystone_affix(**options)
142
+ BlizzardApi::Wow::MythicKeystoneAffix.new(**options)
136
143
  end
137
144
 
138
145
  ##
139
- # @param region [String] API Region
146
+ # @!macro init_options
140
147
  # @return {MythicKeystone}
141
- def self.mythic_keystone(region = BlizzardApi.region)
142
- BlizzardApi::Wow::MythicKeystone.new(region)
148
+ def self.mythic_keystone(**options)
149
+ BlizzardApi::Wow::MythicKeystone.new(**options)
143
150
  end
144
151
 
145
152
  ##
146
- # @param region [String] API Region
153
+ # @!macro init_options
147
154
  # @return {MythicRaidLeaderboard}
148
- def self.mythic_raid_leaderboard(region = BlizzardApi.region)
149
- BlizzardApi::Wow::MythicRaidLeaderboard.new(region)
155
+ def self.mythic_raid_leaderboard(**options)
156
+ BlizzardApi::Wow::MythicRaidLeaderboard.new(**options)
150
157
  end
151
158
 
152
159
  ##
153
- # @param region [String] API Region
160
+ # @!macro init_options
154
161
  # @return {MythicKeystoneLeaderboard}
155
- def self.mythic_keystone_leaderboard(region = BlizzardApi.region)
156
- BlizzardApi::Wow::MythicKeystoneLeaderboard.new(region)
162
+ def self.mythic_keystone_leaderboard(**options)
163
+ BlizzardApi::Wow::MythicKeystoneLeaderboard.new(**options)
157
164
  end
158
165
 
159
166
  ##
160
- # @param region [String] API Region
167
+ # @!macro init_options
161
168
  # @return {Pet}
162
- def self.pet(region = BlizzardApi.region)
163
- BlizzardApi::Wow::Pet.new(region)
169
+ def self.pet(**options)
170
+ BlizzardApi::Wow::Pet.new(**options)
164
171
  end
165
172
 
166
173
  ##
167
- # @param region [String] API Region
174
+ # @!macro init_options
168
175
  # @return {PlayableClass}
169
- def self.playable_class(region = BlizzardApi.region)
170
- BlizzardApi::Wow::PlayableClass.new(region)
176
+ def self.playable_class(**options)
177
+ BlizzardApi::Wow::PlayableClass.new(**options)
171
178
  end
172
179
 
173
180
  ##
174
- # @param region [String] API Region
181
+ # @!macro init_options
175
182
  # @return {Race}
176
- def self.playable_race(region = BlizzardApi.region)
177
- BlizzardApi::Wow::PlayableRace.new(region)
183
+ def self.playable_race(**options)
184
+ BlizzardApi::Wow::PlayableRace.new(**options)
178
185
  end
179
186
 
180
187
  ##
181
- # @param region [String] API Region
188
+ # @!macro init_options
182
189
  # @return {PlayableSpecialization}
183
- def self.playable_specialization(region = BlizzardApi.region)
184
- BlizzardApi::Wow::PlayableSpecialization.new(region)
190
+ def self.playable_specialization(**options)
191
+ BlizzardApi::Wow::PlayableSpecialization.new(**options)
185
192
  end
186
193
 
187
194
  ##
188
- # @param region [String] API Region
195
+ # @!macro init_options
189
196
  # @return {PowerType}
190
- def self.power_type(region = BlizzardApi.region)
191
- BlizzardApi::Wow::PowerType.new(region)
197
+ def self.power_type(**options)
198
+ BlizzardApi::Wow::PowerType.new(**options)
192
199
  end
193
200
 
194
201
  ##
195
- # @param region [String] API Region
202
+ # @!macro init_options
196
203
  # @return {Profession}
197
- def self.profession(region = BlizzardApi.region)
198
- BlizzardApi::Wow::Profession.new(region)
204
+ def self.profession(**options)
205
+ BlizzardApi::Wow::Profession.new(**options)
206
+ end
207
+
208
+ ##
209
+ # @!macro init_options
210
+ # @return {PvpRegion}
211
+ def self.pvp_region(**options)
212
+ BlizzardApi::Wow::PvpRegion.new(**options)
199
213
  end
200
214
 
201
215
  ##
202
- # @param region [String] API Region
216
+ # @!macro init_options
203
217
  # @return {PvpSeason}
204
- def self.pvp_season(region = BlizzardApi.region)
205
- BlizzardApi::Wow::PvpSeason.new(region)
218
+ def self.pvp_season(**options)
219
+ BlizzardApi::Wow::PvpSeason.new(**options)
206
220
  end
207
221
 
208
222
  ##
209
- # @param region [String] API Region
223
+ # @!macro init_options
210
224
  # @return {PvpTier}
211
- def self.pvp_tier(region = BlizzardApi.region)
212
- BlizzardApi::Wow::PvpTier.new(region)
225
+ def self.pvp_tier(**options)
226
+ BlizzardApi::Wow::PvpTier.new(**options)
213
227
  end
214
228
 
215
229
  ##
216
- # @param region [String] API Region
230
+ # @!macro init_options
217
231
  # @return {Quest}
218
- def self.quest(region = BlizzardApi.region)
219
- BlizzardApi::Wow::Quest.new(region)
232
+ def self.quest(**options)
233
+ BlizzardApi::Wow::Quest.new(**options)
220
234
  end
221
235
 
222
236
  ##
223
- # @param region [String] API Region
237
+ # @!macro init_options
224
238
  # @return {Realm}
225
- def self.realm(region = BlizzardApi.region)
226
- BlizzardApi::Wow::Realm.new(region)
239
+ def self.realm(**options)
240
+ BlizzardApi::Wow::Realm.new(**options)
227
241
  end
228
242
 
229
243
  ##
230
- # @param region [String] API Region
244
+ # @!macro init_options
231
245
  # @return {Region}
232
- def self.region(region = BlizzardApi.region)
233
- BlizzardApi::Wow::Region.new(region)
246
+ def self.region(**options)
247
+ BlizzardApi::Wow::Region.new(**options)
234
248
  end
235
249
 
236
250
  ##
237
- # @param region [String] API Region
251
+ # @!macro init_options
238
252
  # @return {Reputation}
239
- def self.reputation(region = BlizzardApi.region)
240
- BlizzardApi::Wow::Reputation.new(region)
253
+ def self.reputation(**options)
254
+ BlizzardApi::Wow::Reputation.new(**options)
241
255
  end
242
256
 
243
257
  ##
244
- # @param region [String] API Region
258
+ # @!macro init_options
245
259
  # @return {Spell}
246
- def self.spell(region = BlizzardApi.region)
247
- BlizzardApi::Wow::Spell.new(region)
260
+ def self.spell(**options)
261
+ BlizzardApi::Wow::Spell.new(**options)
248
262
  end
249
263
 
250
264
  ##
251
- # @param region [String] API Region
265
+ # @!macro init_options
252
266
  # @return {Talent}
253
- def self.talent(region = BlizzardApi.region)
254
- BlizzardApi::Wow::Talent.new(region)
267
+ def self.talent(**options)
268
+ BlizzardApi::Wow::Talent.new(**options)
255
269
  end
256
270
 
257
271
  ##
258
- # @param region [String] API Region
272
+ # @!macro init_options
259
273
  # @return {TechTalent}
260
- def self.tech_talent(region = BlizzardApi.region)
261
- BlizzardApi::Wow::TechTalent.new(region)
274
+ def self.tech_talent(**options)
275
+ BlizzardApi::Wow::TechTalent.new(**options)
262
276
  end
263
277
 
264
278
  ##
265
- # @param region [String] API Region
279
+ # @!macro init_options
266
280
  # @return {Title}
267
- def self.title(region = BlizzardApi.region)
268
- BlizzardApi::Wow::Title.new(region)
281
+ def self.title(**options)
282
+ BlizzardApi::Wow::Title.new(**options)
269
283
  end
270
284
 
271
285
  ##
272
- # @param region [String] API Region
286
+ # @!macro init_options
273
287
  # @return {WowToken}
274
- def self.wow_token(region = BlizzardApi.region)
275
- BlizzardApi::Wow::WowToken.new(region)
288
+ def self.wow_token(**options)
289
+ BlizzardApi::Wow::WowToken.new(**options)
276
290
  end
277
291
 
278
292
  require_relative 'wow/profile/profile'
@@ -281,25 +295,25 @@ module BlizzardApi
281
295
 
282
296
  ##
283
297
  # @param token [String] A token obtained using the authorization_code flow
284
- # @param region [String] API Region
298
+ # @!macro init_options
285
299
  #
286
300
  # @return {Profile}
287
- def self.profile(token, region = BlizzardApi.region)
288
- BlizzardApi::Wow::AccountProfile.new(token, region)
301
+ def self.profile(token, **options)
302
+ BlizzardApi::Wow::AccountProfile.new(token, **options)
289
303
  end
290
304
 
291
305
  ##
292
- # @param region [String] API Region
306
+ # @!macro init_options
293
307
  # @return {Guild}
294
- def self.guild(region = BlizzardApi.region)
295
- BlizzardApi::Wow::Guild.new(region)
308
+ def self.guild(**options)
309
+ BlizzardApi::Wow::Guild.new(**options)
296
310
  end
297
311
 
298
312
  ##
299
- # @param region [String] API Region
313
+ # @!macro init_options
300
314
  # @return {CharacterProfile}
301
- def self.character_profile(region = BlizzardApi.region)
302
- BlizzardApi::Wow::CharacterProfile.new(region)
315
+ def self.character_profile(**options)
316
+ BlizzardApi::Wow::CharacterProfile.new(**options)
303
317
  end
304
318
  end
305
319
  end
data/lib/blizzard_api.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'blizzard_api/configuration'
4
+ require_relative 'blizzard_api/token_manager'
5
+ require_relative 'blizzard_api/api_standards'
4
6
  require_relative 'blizzard_api/request'
5
7
  require_relative 'blizzard_api/exception'
6
8
  require_relative 'blizzard_api/version'
@@ -11,5 +13,12 @@ require_relative 'blizzard_api/starcraft'
11
13
 
12
14
  # Blizzard namespace
13
15
  module BlizzardApi
16
+ extend TokenManager
14
17
  extend Configuration
18
+
19
+ def self.redis_connection
20
+ return nil unless use_cache
21
+
22
+ @redis_connection ||= Redis.new(host: redis_host, port: redis_port, db: redis_database)
23
+ end
15
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blizzard_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Schiavo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-03 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -30,20 +30,6 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.1.0
33
- - !ruby/object:Gem::Dependency
34
- name: thwait
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: 0.2.0
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: 0.2.0
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: dotenv
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +121,7 @@ files:
135
121
  - bin/setup
136
122
  - blizzard_api.gemspec
137
123
  - lib/blizzard_api.rb
124
+ - lib/blizzard_api/api_standards.rb
138
125
  - lib/blizzard_api/configuration.rb
139
126
  - lib/blizzard_api/diablo.rb
140
127
  - lib/blizzard_api/diablo/community/act.rb
@@ -164,6 +151,7 @@ files:
164
151
  - lib/blizzard_api/starcraft/community/profile.rb
165
152
  - lib/blizzard_api/starcraft/game_data/league.rb
166
153
  - lib/blizzard_api/starcraft/request.rb
154
+ - lib/blizzard_api/token_manager.rb
167
155
  - lib/blizzard_api/version.rb
168
156
  - lib/blizzard_api/wow.rb
169
157
  - lib/blizzard_api/wow/game_data/achievement.rb
@@ -189,6 +177,7 @@ files:
189
177
  - lib/blizzard_api/wow/game_data/playable_specialization.rb
190
178
  - lib/blizzard_api/wow/game_data/power_type.rb
191
179
  - lib/blizzard_api/wow/game_data/profession.rb
180
+ - lib/blizzard_api/wow/game_data/pvp_region.rb
192
181
  - lib/blizzard_api/wow/game_data/pvp_season.rb
193
182
  - lib/blizzard_api/wow/game_data/pvp_tier.rb
194
183
  - lib/blizzard_api/wow/game_data/quest.rb