blizzard_api_rb_rb 3.4.2

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.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +22 -0
  3. data/.gitignore +12 -0
  4. data/.rubocop.yml +18 -0
  5. data/.rubocop_todo.yml +7 -0
  6. data/CHANGELOG.md +269 -0
  7. data/Gemfile +8 -0
  8. data/Gemfile.lock +50 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +200 -0
  11. data/Rakefile +12 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/blizzard_api_rb.gemspec +44 -0
  15. data/lib/blizzard_api_rb/api_response.rb +27 -0
  16. data/lib/blizzard_api_rb/api_standards.rb +55 -0
  17. data/lib/blizzard_api_rb/configuration.rb +93 -0
  18. data/lib/blizzard_api_rb/diablo/community/act.rb +35 -0
  19. data/lib/blizzard_api_rb/diablo/community/artisan.rb +38 -0
  20. data/lib/blizzard_api_rb/diablo/community/character_class.rb +38 -0
  21. data/lib/blizzard_api_rb/diablo/community/follower.rb +25 -0
  22. data/lib/blizzard_api_rb/diablo/community/item.rb +25 -0
  23. data/lib/blizzard_api_rb/diablo/community/item_type.rb +35 -0
  24. data/lib/blizzard_api_rb/diablo/community/profile.rb +83 -0
  25. data/lib/blizzard_api_rb/diablo/game_data/era.rb +21 -0
  26. data/lib/blizzard_api_rb/diablo/game_data/generic_data_endpoint.rb +58 -0
  27. data/lib/blizzard_api_rb/diablo/game_data/season.rb +21 -0
  28. data/lib/blizzard_api_rb/diablo/request.rb +15 -0
  29. data/lib/blizzard_api_rb/diablo.rb +91 -0
  30. data/lib/blizzard_api_rb/exception.rb +14 -0
  31. data/lib/blizzard_api_rb/hearthstone/game_data/back.rb +59 -0
  32. data/lib/blizzard_api_rb/hearthstone/game_data/card.rb +111 -0
  33. data/lib/blizzard_api_rb/hearthstone/game_data/deck.rb +30 -0
  34. data/lib/blizzard_api_rb/hearthstone/game_data/generic_data_endpoint.rb +49 -0
  35. data/lib/blizzard_api_rb/hearthstone/game_data/metadata.rb +22 -0
  36. data/lib/blizzard_api_rb/hearthstone/request.rb +15 -0
  37. data/lib/blizzard_api_rb/hearthstone.rb +49 -0
  38. data/lib/blizzard_api_rb/overwatch_league/community/matches.rb +22 -0
  39. data/lib/blizzard_api_rb/overwatch_league/community/players.rb +22 -0
  40. data/lib/blizzard_api_rb/overwatch_league/community/segments.rb +22 -0
  41. data/lib/blizzard_api_rb/overwatch_league/community/summary.rb +22 -0
  42. data/lib/blizzard_api_rb/overwatch_league/community/teams.rb +22 -0
  43. data/lib/blizzard_api_rb/overwatch_league/request.rb +15 -0
  44. data/lib/blizzard_api_rb/overwatch_league.rb +50 -0
  45. data/lib/blizzard_api_rb/request.rb +189 -0
  46. data/lib/blizzard_api_rb/starcraft/community/account.rb +23 -0
  47. data/lib/blizzard_api_rb/starcraft/community/ladder.rb +34 -0
  48. data/lib/blizzard_api_rb/starcraft/community/legacy.rb +87 -0
  49. data/lib/blizzard_api_rb/starcraft/community/profile.rb +76 -0
  50. data/lib/blizzard_api_rb/starcraft/game_data/league.rb +27 -0
  51. data/lib/blizzard_api_rb/starcraft/request.rb +36 -0
  52. data/lib/blizzard_api_rb/starcraft.rb +57 -0
  53. data/lib/blizzard_api_rb/token_manager.rb +49 -0
  54. data/lib/blizzard_api_rb/version.rb +6 -0
  55. data/lib/blizzard_api_rb/wow/game_data/achievement.rb +46 -0
  56. data/lib/blizzard_api_rb/wow/game_data/auction.rb +50 -0
  57. data/lib/blizzard_api_rb/wow/game_data/azerite_essence.rb +30 -0
  58. data/lib/blizzard_api_rb/wow/game_data/connected_realm.rb +18 -0
  59. data/lib/blizzard_api_rb/wow/game_data/covenant.rb +72 -0
  60. data/lib/blizzard_api_rb/wow/game_data/creature.rb +102 -0
  61. data/lib/blizzard_api_rb/wow/game_data/generic_data_endpoint.rb +50 -0
  62. data/lib/blizzard_api_rb/wow/game_data/guild_crest.rb +48 -0
  63. data/lib/blizzard_api_rb/wow/game_data/heirloom.rb +16 -0
  64. data/lib/blizzard_api_rb/wow/game_data/item.rb +102 -0
  65. data/lib/blizzard_api_rb/wow/game_data/journal.rb +110 -0
  66. data/lib/blizzard_api_rb/wow/game_data/media.rb +26 -0
  67. data/lib/blizzard_api_rb/wow/game_data/modified_crafting.rb +60 -0
  68. data/lib/blizzard_api_rb/wow/game_data/mount.rb +18 -0
  69. data/lib/blizzard_api_rb/wow/game_data/mythic_keystone.rb +86 -0
  70. data/lib/blizzard_api_rb/wow/game_data/mythic_keystone_affix.rb +28 -0
  71. data/lib/blizzard_api_rb/wow/game_data/mythic_keystone_leaderboard.rb +48 -0
  72. data/lib/blizzard_api_rb/wow/game_data/mythic_raid_leaderboard.rb +28 -0
  73. data/lib/blizzard_api_rb/wow/game_data/pet.rb +62 -0
  74. data/lib/blizzard_api_rb/wow/game_data/playable_class.rb +39 -0
  75. data/lib/blizzard_api_rb/wow/game_data/playable_race.rb +16 -0
  76. data/lib/blizzard_api_rb/wow/game_data/playable_specialization.rb +65 -0
  77. data/lib/blizzard_api_rb/wow/game_data/power_type.rb +16 -0
  78. data/lib/blizzard_api_rb/wow/game_data/profession.rb +65 -0
  79. data/lib/blizzard_api_rb/wow/game_data/pvp_region.rb +82 -0
  80. data/lib/blizzard_api_rb/wow/game_data/pvp_season.rb +53 -0
  81. data/lib/blizzard_api_rb/wow/game_data/pvp_tier.rb +26 -0
  82. data/lib/blizzard_api_rb/wow/game_data/quest.rb +79 -0
  83. data/lib/blizzard_api_rb/wow/game_data/realm.rb +18 -0
  84. data/lib/blizzard_api_rb/wow/game_data/region.rb +16 -0
  85. data/lib/blizzard_api_rb/wow/game_data/reputation.rb +74 -0
  86. data/lib/blizzard_api_rb/wow/game_data/spell.rb +38 -0
  87. data/lib/blizzard_api_rb/wow/game_data/talent.rb +75 -0
  88. data/lib/blizzard_api_rb/wow/game_data/tech_talent.rb +50 -0
  89. data/lib/blizzard_api_rb/wow/game_data/title.rb +16 -0
  90. data/lib/blizzard_api_rb/wow/game_data/toy.rb +16 -0
  91. data/lib/blizzard_api_rb/wow/game_data/wow_token.rb +20 -0
  92. data/lib/blizzard_api_rb/wow/profile/account_profile.rb +97 -0
  93. data/lib/blizzard_api_rb/wow/profile/character_profile.rb +415 -0
  94. data/lib/blizzard_api_rb/wow/profile/guild.rb +75 -0
  95. data/lib/blizzard_api_rb/wow/request.rb +16 -0
  96. data/lib/blizzard_api_rb/wow/search/search_composer.rb +97 -0
  97. data/lib/blizzard_api_rb/wow/search/search_request.rb +24 -0
  98. data/lib/blizzard_api_rb/wow/slug.rb +12 -0
  99. data/lib/blizzard_api_rb/wow.rb +335 -0
  100. data/lib/blizzard_api_rb.rb +26 -0
  101. metadata +237 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f24cda3f7bd0a3e3719edb0946e57f9acabf5db4c35a83e08c749f3fa7c65f17
4
+ data.tar.gz: 19ee721f8d9f0607a6468dfba3263310a1dbfbecbabe5b9a257f6b4ef54c8023
5
+ SHA512:
6
+ metadata.gz: d2a140e1454072d80b9e77be11e787e30720e24603645b23815b5eb17e384b4e90b0809c84adc35dfe620b9f8d24058a5e90df425b4d230a6faa6121b009f5cc
7
+ data.tar.gz: 44552b6ab31ad7fa516a7fc44c6f9e7943cde3021a2f26f0674ad2aabeeac545061560335c287f386fe10b571894b43eac79b56591f8745cd1c3f533664a438d
@@ -0,0 +1,22 @@
1
+ name: Ruby
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
12
+ with:
13
+ ruby-version: 3.1
14
+ - name: Install dependencies
15
+ run: bundle install
16
+ - name: Run tests
17
+ run: bundle exec rake
18
+ env:
19
+ BNET_APPLICATION_ID: ${{ secrets.BNET_APPLICATION_ID }}
20
+ BNET_APPLICATION_SECRET: ${{ secrets.BNET_APPLICATION_SECRET }}
21
+ USE_CACHE: false
22
+ IGNORE_CLASSIC_TESTS: true
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .env
10
+ .idea
11
+ *.gem
12
+ .directory
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Layout/LineLength:
4
+ Max: 140
5
+
6
+ Metrics/ModuleLength:
7
+ Exclude:
8
+ - 'lib/blizzard_api_rb/wow.rb'
9
+
10
+ Metrics/AbcSize:
11
+ Max: 20
12
+
13
+ AllCops:
14
+ TargetRubyVersion: 2.7
15
+ NewCops: enable
16
+ Exclude:
17
+ - 'vendor/**/*'
18
+ - 'bin/**/*'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-03-06 13:04:37 -0300 using RuboCop version 0.61.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
data/CHANGELOG.md ADDED
@@ -0,0 +1,269 @@
1
+ Please view this file on the master branch, otherwise it may be outdated
2
+
3
+ **Version 3.4.0**
4
+
5
+ Added new collections endpoints for toys and heirlooms.
6
+
7
+ **Version 3.2.0**
8
+
9
+ Added new WoW Dragonflight talents endpoint.
10
+ Added support for Overwatch League API
11
+
12
+ **Version 3.2.0**
13
+
14
+ Added new AH commodities endpoint.
15
+
16
+ **Version 3.1.0**
17
+
18
+ Fixed the latest build to exclude non 200 responses from caching.
19
+
20
+ **Version 3.0.0**
21
+
22
+ Changed the way `:extended` mode is handled regarding caching. Now the extended mode will use cache and return a fake
23
+ response object if the content is cached (Cache is still ignored when using the `:since` option).
24
+ A cached response can be identified by the presence of a `cached?` method on the response object.
25
+
26
+ Some automated tests for SC2 endpoints are now ignoring `503` errors. The state of the API is somehow unknown since it
27
+ is down most of the time.
28
+
29
+ **Version 2.0.0**
30
+
31
+ Removed the `icon` field from PlayableClass, it was meant to mimic the old communit API behavior during the transition
32
+ to the new game_data version.
33
+
34
+ **Version 1.0.0**
35
+
36
+ Removed the `complete` method from WoW game data endpoints.
37
+ Removed the `concurrency` request and configuration option as it is not necessary anymore.
38
+ Removed the `thwait` dependency.
39
+
40
+ Added the `redis_database` option to support selecting the redis database for caching data.
41
+ The gem will now share a single Redis connection across all calls.
42
+ The gem now creates a new token on demand if the previous one has expired.
43
+ It is now possible to cache the token in Redis to avoid needlessly creating a new token.
44
+ It is now possible to set the default mode for API calls
45
+
46
+ **Version 0.6.4**
47
+
48
+ Fixed argument propagation in SC2 legacy profile methods.
49
+
50
+ **Version 0.6.3**
51
+
52
+ Fixed argument propagation in some profile methods.
53
+
54
+ **Version 0.6.2**
55
+
56
+ Fixed an encoding problem on search endpoints.
57
+
58
+ **Version 0.6.1**
59
+
60
+ Added support for TBCC and Classice Era endpoints.
61
+
62
+ **Version 0.6.0**
63
+
64
+ Upgraded gem dependencies and refactored the code to support Ruby 3.0.0
65
+ Required ruby version upgraded to 2.7.2
66
+ Added concurrency to all WoW game data *complete* methods. Default of 4 threads. Should be close to # of threads available.
67
+
68
+ **Version 0.5.6**
69
+
70
+ Upgrade gem dependencies to fix a security vulnerability
71
+
72
+ **Version 0.5.5**
73
+
74
+ Removing old and deprecated function from community endpoint.
75
+
76
+ Refactored all `options` arguments to use double splat syntax.
77
+
78
+ Modified README.md to point to the actual documentation and include missing endpoints.
79
+
80
+ **Version 0.5.4**
81
+
82
+ Added missing legacy SC2 endpoints
83
+
84
+ See https://github.com/francis-schiavo/blizzard_api_rb/pull/2
85
+
86
+ **Version 0.5.2**
87
+
88
+ Added new endpoints: https://us.forums.blizzard.com/en/blizzard/t/wow-shadowlands-api-update-covenenats-soulbinds-more/13385
89
+
90
+ **Version 0.5.1**
91
+
92
+ Added new endpoints: https://us.forums.blizzard.com/en/blizzard/t/wow-game-data-api-modified-crafting-support/12727
93
+
94
+ **Version 0.5.0**
95
+
96
+ This version brings a lot of internal changes to the way the gem works. While
97
+ there no breaking change is expected use it carefully.
98
+
99
+ ## New features:
100
+
101
+ ### Extended mode
102
+
103
+ When creating a request you can now specify **mode** as the last argument. Available modes:
104
+ * **regular**: No changes, should work as it always did.
105
+ * **extended**: All requests now return an array with two objects, the actual HTTPResponse object and the usual Hash.
106
+
107
+ ```ruby
108
+ api_client = BlizzardApi::Wow::Item.new 'us', :extended
109
+ response, item_data = api_client.get 35_000
110
+
111
+ puts response.code # 200
112
+ puts item_data[:name][:en_US] # Brutal Gladiator's Dragonhide Legguards
113
+ ```
114
+
115
+ This is intended to expose the response code and headers.
116
+
117
+ **Important**: Extended mode completely disables the cache.
118
+
119
+ ### Custom headers
120
+
121
+ You an now pass custom headers in the **options** hash.
122
+
123
+ There is also a new shorthand for the `If-Modified-Since` header.
124
+
125
+ ```ruby
126
+ # If-Modified-Since shorhand
127
+ auction_data = BlizzardApi::Wow.auction.get 1146, since: DateTime.parse('2099-01-01Z')
128
+
129
+ # Using custom headers
130
+ auction_data = BlizzardApi::Wow.auction.get 1146, headers: { 'If-Modified-Since' => 'Sun, 27 Sep 2020 02:17:03 GMT' }
131
+ ```
132
+
133
+ **Important**
134
+ * Headers are not part of the cache key, use the option `ignore_cache: true` when needed.
135
+ * The `since` shorthand will always disable the cache.
136
+
137
+ **Version 0.4.2**
138
+
139
+ Added new retail and classic search endpoints described here: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200708/10310
140
+
141
+ **Version 0.4.1**
142
+
143
+ Added new retail and classic endpoints described here: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200609/8902
144
+
145
+ **Version 0.4.0**
146
+
147
+ Added support to searchable endpoints
148
+
149
+ https://develop.battle.net/documentation/world-of-warcraft/guides/search
150
+
151
+ **Version 0.3.11**
152
+
153
+ Fixed D3 item URL.
154
+
155
+ **Version 0.3.10**
156
+
157
+ Really fixed D3 profile URLs this time.
158
+
159
+ **Version 0.3.9**
160
+
161
+ Fix D3 profile URLs.
162
+
163
+ **Version 0.3.8**
164
+
165
+ Added new profession endpoints.
166
+
167
+ https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200414/5680
168
+
169
+ **Version 0.3.7**
170
+
171
+ Automated test improvements
172
+ Added region parameters to all game module methods. This will allow multi-region applications to have more flexibility when creating instances.
173
+
174
+ **Version 0.3.6**
175
+
176
+ Fix Diablo shortcuts.
177
+ Adding SC2 endpoints back.
178
+
179
+ https://us.forums.blizzard.com/en/blizzard/t/starcraft-ii-community-api-update/2652/5
180
+
181
+ **Version 0.3.5**
182
+
183
+ Fixed a bug for generating slugs for Korean
184
+
185
+ Removed deprecated WoW community endpoints.
186
+
187
+ **Version 0.3.4**
188
+
189
+ Fixed account endpoints
190
+
191
+ **Version 0.3.3**
192
+
193
+ Added character profile encounter endpoints:
194
+ https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200226/3713
195
+
196
+ Added missing media endpoints for `playable_class`, `playable_specialization` and `mythic_keystone_affix`
197
+
198
+ **Version 0.3.2**
199
+
200
+ Added new WoW endpoints: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-update-visions-of-nzoth/3461
201
+
202
+ **Attention:** Removed compatibility with community endpoints for all migrated endpoints.
203
+
204
+ **Version 0.3.1**
205
+
206
+ https://us.forums.blizzard.com/en/blizzard/t/hearthstone-api-updates/2978
207
+
208
+ Hearthstone updates:
209
+
210
+ * Added the new Cardback endpoint
211
+ * Card endpoint now supports the new `gameMode` search option
212
+
213
+ **Version 0.3.0**
214
+
215
+ https://us.forums.blizzard.com/en/blizzard/t/starcraft-ii-community-api-update/2652
216
+
217
+ Removed all Starcraft II related code.
218
+
219
+ **Version 0.2.9**
220
+
221
+ https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-update-collections-hunter-pets-and-reputations/757
222
+ * Added new character endpoints:
223
+ * reputations
224
+ * hunter-pets
225
+ * collections
226
+ * pets
227
+ * mounts
228
+
229
+ * Added new endpoints:
230
+ * reputation-tiers
231
+ * reputation-faction
232
+
233
+ * Marked all WoW community endpoints as deprecated: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
234
+
235
+ **Version 0.2.8**
236
+ * Added the new character status endpoint
237
+
238
+ **Version 0.2.7**
239
+ * Changed CI process to use docker ruby images.
240
+
241
+ **Version 0.2.6**
242
+ * Added namespace `static-classic` for wow classic support.
243
+ * Some WoW endpoints now support the `classic: true` option.
244
+
245
+ **Version 0.2.5**
246
+ * Added two unreleased endpoints for character profile(`raid_progression` and `collections`).
247
+ * Added new WoW profile endpoints
248
+ * Added missing profile automated tests
249
+
250
+ **Version 0.2.4**
251
+ * Added new WoW profile endpoints: #2 https://us.battle.net/forums/en/bnet/topic/20772457051
252
+ * Added support for HearthStone: !1 (Thanks Bradyn Glines for implementing this)
253
+
254
+ **Version 0.2.3**
255
+ * Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20772337044
256
+
257
+ **Version 0.2.2**
258
+ * Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20771546990
259
+
260
+ **Version 0.2.1**
261
+ * Added icon to playable_class return value
262
+ * Temporarily ignoring some rubocop offenses as the recommended alternatives are not suitable
263
+
264
+ **Version 0.2.0**
265
+ * D3/SC2 endpoints
266
+ * Lots of improvements to WoW endpoints
267
+
268
+ **Version 0.1.0**
269
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in blizzard-api.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ blizzard_api_rb_rb (3.4.2)
5
+ redis (~> 4.1, >= 4.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ dotenv (2.8.1)
12
+ minitest (5.16.3)
13
+ parallel (1.22.1)
14
+ parser (3.1.3.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ redis (4.8.1)
19
+ regexp_parser (2.6.1)
20
+ rexml (3.2.5)
21
+ rubocop (0.93.1)
22
+ parallel (~> 1.10)
23
+ parser (>= 2.7.1.5)
24
+ rainbow (>= 2.2.2, < 4.0)
25
+ regexp_parser (>= 1.8)
26
+ rexml
27
+ rubocop-ast (>= 0.6.0)
28
+ ruby-progressbar (~> 1.7)
29
+ unicode-display_width (>= 1.4.0, < 2.0)
30
+ rubocop-ast (1.24.0)
31
+ parser (>= 3.1.1.0)
32
+ ruby-progressbar (1.11.0)
33
+ unicode-display_width (1.8.0)
34
+ webrick (1.7.0)
35
+ yard (0.9.28)
36
+ webrick (~> 1.7.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ blizzard_api_rb_rb!
43
+ dotenv
44
+ minitest (~> 5.0)
45
+ rake (~> 13.0)
46
+ rubocop (~> 0.61)
47
+ yard
48
+
49
+ BUNDLED WITH
50
+ 2.2.17
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Francis Schiavo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # Blizzard Api
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/blizzard_api_rb.svg)](https://badge.fury.io/rb/blizzard_api_rb)
4
+
5
+ This gem allow you to interface with the new blizzard api (2018) using the OAuth2 protocol for every request.
6
+
7
+ **Important**: This gem does not support, nor will support China endpoints.
8
+
9
+ ## Table of contents
10
+ 1. [Installation](#1-installation)
11
+ 2. [Configuration](#2-configuration)
12
+ 3. [Basic usage](#3-basic-usage)
13
+ 4. [Available endpoints](#4-available-endpoints)
14
+ - 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
15
+ - 4.2. [Diablo III endpoints](#42-diablo-iii-endpoints)
16
+ - 4.3. [Hearthstone endpoints](#43-hearthstone-endpoints)
17
+ - 4.4. [Starcraft II endpoints](#43-starcraft-ii-endpoints)
18
+
19
+ ## 1. Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'blizzard_api_rb'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ ## 2. Configuration
32
+
33
+ Before you use the api you must create a developer account at https://develop.battle.net and create the client authorization keys.
34
+
35
+ Once you have a pair of client ID and SECRET you must set up an initialization code.
36
+
37
+ ```ruby
38
+ BlizzardApi.configure do |config|
39
+ config.app_id = ENV['BNET_APPLICATION_ID']
40
+ config.app_secret = ENV['BNET_APPLICATION_SECRET']
41
+ config.region = 'us'
42
+ config.use_cache = true
43
+ config.redis_host = ENV['REDIS_HOST']
44
+ config.redis_port = ENV['REDIS_PORT']
45
+ end
46
+ ```
47
+
48
+ It is highly recommended to use [redis](https://redis.io/) to cache all requests as it avoids unnecessary calls and speeds up your application.
49
+
50
+ ## 3. Basic usage
51
+
52
+ You can now consume the api by instantiating a specific endpoint:
53
+
54
+ ```ruby
55
+ race = BlizzardApi::Wow::Race.new :us
56
+ race_data = race.complete
57
+ ```
58
+
59
+ or you can just use the game namespace wrapper as follows:
60
+
61
+ ```ruby
62
+ race = BlizzardApi::Wow.race
63
+ race_data = race.complete
64
+ ```
65
+
66
+ Most **game data** endpoints will have always 3 methods available `index`, `get` and `complete`.
67
+
68
+ * `index` is used to get a list of all resources of that endpoint.
69
+ * `get` is used to get all information about a entry of the index returned data. It receives an id or slug as the first parameter, that depends on the endpoint.
70
+ * `complete` is a complete information of all items listed in index. **This may perform various calls to the blizzard api** only use if you really need all information.
71
+
72
+ ### 3.1 Searchable endpoints
73
+
74
+ Some endpoints support search filters. To perform a search you can use the following formats:
75
+
76
+ To use the **or** operator you may pass an array of values as argument to `where` or `where_not` methods.
77
+ ```ruby
78
+ realm = BlizzardApi::Wow.realm
79
+ realm_data = realm.search(1, 100) do |options|
80
+ options.where 'name.en_US', %w[Azralon Nemesis]
81
+ end
82
+ ```
83
+
84
+ To use the **and** operator you may call `where` or `where_not` multiple times methods.
85
+ ```ruby
86
+ realm = BlizzardApi::Wow.realm
87
+ realm_data = realm.search(1, 100) do |options|
88
+ options.where 'name.en_US', 'Azralon'
89
+ options.where 'id', 3209
90
+ end
91
+ ```
92
+
93
+ To use the **range** operator you may pass a hash to `where` or `where_not`.
94
+ ```ruby
95
+ realm = BlizzardApi::Wow.realm
96
+ realm_data = realm.search(1, 100) do |options|
97
+ options.where 'id', min: 3209, max: 4000, mode: :exclusive
98
+ end
99
+ ```
100
+ *Note*: If you don't pass the `mode` key as `:exclusive` it will be `:inclusive` by default.
101
+
102
+ To **sort** fields you may call the `order_by` method multiple times:
103
+ ```ruby
104
+ realm = BlizzardApi::Wow.realm
105
+ realm_data = realm.search(1, 100) do |options|
106
+ options.where 'id', min: 3209, max: 4000, mode: :exclusive
107
+ options.order_by 'id', :desc
108
+ end
109
+ ```
110
+
111
+ ## 4. Available endpoints
112
+
113
+ **Hint**: All methods support an additional optional hash parameter that allows you to override the following configurations for a single call:
114
+
115
+ * **ttl**: < int > - Cache duration (seconds) (Only works if you have redis enabled)
116
+ * **ignore_cache**: true - Ignores the cache and forces an api request (Only works if you have redis enabled)
117
+ * **locale**: < locale id > - Changes the default locale (if any)
118
+
119
+ **World of Warcraft** supports two additional options:
120
+ * **use_community_endpoint**: Some methods in game data still have an odl community version available.
121
+ * **classic**: Set to true to query WoW Classic data, only works for some game data endpoints.
122
+
123
+ ### 4.1. World of Warcraft endpoints
124
+
125
+ * [BlizzardApi::Wow.achievement](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Achievement)
126
+ * [BlizzardApi::Wow.auction](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Auction)
127
+ * [BlizzardApi::Wow.azerite_essence](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/AzeriteEssence)
128
+ * [BlizzardApi::Wow.connected_realm](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/ConnectedRealm)
129
+ * [BlizzardApi::Wow.covenant](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Covenant)
130
+ * [BlizzardApi::Wow.creature](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Creature)
131
+ * [BlizzardApi::Wow.guild_crest](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/GuildCrest)
132
+ * [BlizzardApi::Wow.heirloom](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Heirloom)
133
+ * [BlizzardApi::Wow.item](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Item)
134
+ * [BlizzardApi::Wow.journal](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Journal)
135
+ * [BlizzardApi::Wow.media](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Media)
136
+ * [BlizzardApi::Wow.modified_crafting](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/ModifiedCrafting)
137
+ * [BlizzardApi::Wow.mount](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Mount)
138
+ * [BlizzardApi::Wow.mythic_keystone_affix](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/MythicKeystoneAffix)
139
+ * [BlizzardApi::Wow.mythic_keystone](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/MythicKeystone)
140
+ * [BlizzardApi::Wow.mythic_raid_leaderboard](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/MythicRaidLeaderboard)
141
+ * [BlizzardApi::Wow.mythic_keystone_leaderboard](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/MythicKeystoneLeaderboard)
142
+ * [BlizzardApi::Wow.pet](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Pet)
143
+ * [BlizzardApi::Wow.playable_class](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PlayableClass)
144
+ * [BlizzardApi::Wow.playable_race](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PlayableRace)
145
+ * [BlizzardApi::Wow.playable_specialization](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PlayableSpecialization)
146
+ * [BlizzardApi::Wow.power_type](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PowerType)
147
+ * [BlizzardApi::Wow.profession](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Profession)
148
+ * [BlizzardApi::Wow.pvp_season](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PvpSeason)
149
+ * [BlizzardApi::Wow.pvp_tier](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/PvpTier)
150
+ * [BlizzardApi::Wow.quest](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Quest)
151
+ * [BlizzardApi::Wow.realm](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Realm)
152
+ * [BlizzardApi::Wow.region](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Region)
153
+ * [BlizzardApi::Wow.reputation](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Reputation)
154
+ * [BlizzardApi::Wow.spell](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Spell)
155
+ * [BlizzardApi::Wow.talent](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Talent)
156
+ * [BlizzardApi::Wow.tech_talent](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/TechTalent)
157
+ * [BlizzardApi::Wow.title](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Title)
158
+ * [BlizzardApi::Wow.toy](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Toy)
159
+ * [BlizzardApi::Wow.wow_token](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/WowToken)
160
+
161
+ * [BlizzardApi::Wow.profile](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Profile)
162
+ * [BlizzardApi::Wow.guild](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/Guild)
163
+ * [BlizzardApi::Wow.character_profile](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Wow/CharacterProfile)
164
+
165
+ ### 4.2. Diablo III endpoints
166
+
167
+ * [BlizzardApi::Diablo.season](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Season)
168
+ * [BlizzardApi::Diablo.era](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Era)
169
+ * [BlizzardApi::Diablo.act](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Act)
170
+ * [BlizzardApi::Diablo.artisan](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Artisan)
171
+ * [BlizzardApi::Diablo.follower](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Follower)
172
+ * [BlizzardApi::Diablo.character](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Character)
173
+ * [BlizzardApi::Diablo.item_type](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/ItemType)
174
+ * [BlizzardApi::Diablo.item](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Item)
175
+ * [BlizzardApi::Diablo.profile](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Diablo/Profile)
176
+
177
+ ### 4.3. Hearthstone endpoints
178
+
179
+ * [BlizzardApi::Hearthstone.card](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Hearthstone/Card)
180
+ * [BlizzardApi::Hearthstone.back](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Hearthstone/Back)
181
+ * [BlizzardApi::Hearthstone.deck](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Hearthstone/Deck)
182
+ * [BlizzardApi::Hearthstone.metadata](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Hearthstone/Metadata)
183
+
184
+ ### 4.4. Starcraft II endpoints
185
+
186
+ Every endpoint requiring a *region_id* parameter will accepts either the integer representation of the region described in the api docs or a symbol: `:US`, `:EU`, `:KO` or `:TW`
187
+
188
+ * [BlizzardApi::Starcraft.profile](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Starcraft/Profile)
189
+ * [BlizzardApi::Starcraft.ladder](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Starcraft/Ladder)
190
+ * [BlizzardApi::Starcraft.account](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Starcraft/Account)
191
+ * [BlizzardApi::Starcraft.legacy](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Starcraft/Legacy)
192
+ * [BlizzardApi::Starcraft.league](https://rubydoc.info/gems/blizzard_api_rb/BlizzardApi/Starcraft/League)
193
+
194
+ ## Contributing
195
+
196
+ Bug reports and pull requests are welcome on Github at https://github.com/francis-schiavo/blizzard_api_rb/issues
197
+
198
+ ## License
199
+
200
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'blizzard/api'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here