blizzard_api 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 +7 -0
- data/.gitignore +12 -0
- data/.gitlab-ci.yml +28 -0
- data/.rubocop.yml +13 -0
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +21 -0
- data/README.md +208 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/blizzard_api.gemspec +42 -0
- data/lib/blizzard_api.rb +14 -0
- data/lib/blizzard_api/configuration.rb +82 -0
- data/lib/blizzard_api/diablo.rb +76 -0
- data/lib/blizzard_api/diablo/community/act.rb +35 -0
- data/lib/blizzard_api/diablo/community/artisan.rb +38 -0
- data/lib/blizzard_api/diablo/community/character.rb +38 -0
- data/lib/blizzard_api/diablo/community/follower.rb +25 -0
- data/lib/blizzard_api/diablo/community/item.rb +26 -0
- data/lib/blizzard_api/diablo/community/item_type.rb +35 -0
- data/lib/blizzard_api/diablo/community/profile.rb +77 -0
- data/lib/blizzard_api/diablo/game_data/era.rb +21 -0
- data/lib/blizzard_api/diablo/game_data/generic_data_endpoint.rb +58 -0
- data/lib/blizzard_api/diablo/game_data/season.rb +21 -0
- data/lib/blizzard_api/diablo/request.rb +15 -0
- data/lib/blizzard_api/exception.rb +12 -0
- data/lib/blizzard_api/request.rb +182 -0
- data/lib/blizzard_api/starcraft.rb +40 -0
- data/lib/blizzard_api/starcraft/community/account.rb +23 -0
- data/lib/blizzard_api/starcraft/community/ladder.rb +34 -0
- data/lib/blizzard_api/starcraft/community/profile.rb +76 -0
- data/lib/blizzard_api/starcraft/game_data/league.rb +27 -0
- data/lib/blizzard_api/starcraft/request.rb +36 -0
- data/lib/blizzard_api/version.rb +6 -0
- data/lib/blizzard_api/wow.rb +167 -0
- data/lib/blizzard_api/wow/community/achievements.rb +45 -0
- data/lib/blizzard_api/wow/community/auction.rb +25 -0
- data/lib/blizzard_api/wow/community/boss.rb +35 -0
- data/lib/blizzard_api/wow/community/challenge.rb +35 -0
- data/lib/blizzard_api/wow/community/character.rb +103 -0
- data/lib/blizzard_api/wow/community/guild.rb +67 -0
- data/lib/blizzard_api/wow/community/item.rb +46 -0
- data/lib/blizzard_api/wow/community/mount.rb +24 -0
- data/lib/blizzard_api/wow/community/pets.rb +85 -0
- data/lib/blizzard_api/wow/community/pvp.rb +34 -0
- data/lib/blizzard_api/wow/community/quest.rb +25 -0
- data/lib/blizzard_api/wow/community/recipe.rb +25 -0
- data/lib/blizzard_api/wow/community/spell.rb +25 -0
- data/lib/blizzard_api/wow/community/zone.rb +35 -0
- data/lib/blizzard_api/wow/game_data/connected_realm.rb +37 -0
- data/lib/blizzard_api/wow/game_data/generic_data_endpoint.rb +58 -0
- data/lib/blizzard_api/wow/game_data/mythic_keystone_affix.rb +23 -0
- data/lib/blizzard_api/wow/game_data/playable_class.rb +62 -0
- data/lib/blizzard_api/wow/game_data/playable_specialization.rb +70 -0
- data/lib/blizzard_api/wow/game_data/power_type.rb +23 -0
- data/lib/blizzard_api/wow/game_data/race.rb +51 -0
- data/lib/blizzard_api/wow/game_data/realm.rb +48 -0
- data/lib/blizzard_api/wow/game_data/region.rb +49 -0
- data/lib/blizzard_api/wow/request.rb +16 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 25a4f7ae3f8e8b5230e6cc493c10f964dc977f45d1813e6d074b24237094299f
|
4
|
+
data.tar.gz: bc1a1ab587dec338a24e6013373e32cc21fb32db7c098128098b7f0246f50439
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88c61c928fb2743d79cdf7d5fd4b8c6117317c5e102908d7108fea7d71887a9ebf916e7dc858055daff7dbf7df563e3525638382ba411cf51a14bdd78a46de54
|
7
|
+
data.tar.gz: 7b73bd97fa40f2ffb7161a855c107a515e42a155b5357d51f094f54f02060f8079eb5fb2ec60a49651d71920aa5be98e25c93f02d266709b73cfa0bfbb22a362
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
cache:
|
2
|
+
paths:
|
3
|
+
- .env
|
4
|
+
|
5
|
+
stages:
|
6
|
+
- prepare
|
7
|
+
- codecheck
|
8
|
+
- test
|
9
|
+
|
10
|
+
environment-setup:
|
11
|
+
stage: prepare
|
12
|
+
script:
|
13
|
+
- rvm use 2.5.3 --install
|
14
|
+
- bundle install
|
15
|
+
- cat /dev/null > .env
|
16
|
+
- echo "BNET_APPLICATION_ID=$BNET_APP_ID" >> .env
|
17
|
+
- echo "BNET_APPLICATION_SECRET=$BNET_APP_SECRET" >> .env
|
18
|
+
- echo "USE_CACHE=$USE_CACHE" >> .env
|
19
|
+
|
20
|
+
rubocop:
|
21
|
+
stage: codecheck
|
22
|
+
script:
|
23
|
+
- rubocop
|
24
|
+
|
25
|
+
minitest:
|
26
|
+
stage: test
|
27
|
+
script:
|
28
|
+
- rake
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-12-16 19:08:57 -0200 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/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
blizzard_api (0.1.0)
|
5
|
+
redis (~> 4.1, >= 4.1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.0)
|
11
|
+
dotenv (2.5.0)
|
12
|
+
jaro_winkler (1.5.1)
|
13
|
+
minitest (5.11.3)
|
14
|
+
parallel (1.12.1)
|
15
|
+
parser (2.5.3.0)
|
16
|
+
ast (~> 2.4.0)
|
17
|
+
powerpack (0.1.2)
|
18
|
+
rainbow (3.0.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
redis (4.1.0)
|
21
|
+
rubocop (0.61.1)
|
22
|
+
jaro_winkler (~> 1.5.1)
|
23
|
+
parallel (~> 1.10)
|
24
|
+
parser (>= 2.5, != 2.5.1.1)
|
25
|
+
powerpack (~> 0.1)
|
26
|
+
rainbow (>= 2.2.2, < 4.0)
|
27
|
+
ruby-progressbar (~> 1.7)
|
28
|
+
unicode-display_width (~> 1.4.0)
|
29
|
+
ruby-progressbar (1.10.0)
|
30
|
+
unicode-display_width (1.4.0)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
blizzard_api!
|
37
|
+
bundler (~> 1.16)
|
38
|
+
dotenv (~> 2.5)
|
39
|
+
minitest (~> 5.0)
|
40
|
+
rake (~> 10.0)
|
41
|
+
rubocop (~> 0.61)
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
1.17.3
|
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,208 @@
|
|
1
|
+
# Blizzard Api
|
2
|
+
|
3
|
+
[](https://gitlab.com/francisschiavo/blizzard_api/commits/master)
|
4
|
+
[](https://badge.fury.io/rb/blizzard_api)
|
5
|
+
|
6
|
+
|
7
|
+
This gem allow you to interface with the new blizzard api (2018) using the OAuth2 protocol for every request.
|
8
|
+
|
9
|
+
**Important**: This gem does not support, nor will support China endpoints.
|
10
|
+
|
11
|
+
## Table of contents
|
12
|
+
1. [Installation](#1-installation)
|
13
|
+
2. [Configuration](#2-configuration)
|
14
|
+
3. [Basic usage](#1-basic-usage)
|
15
|
+
4. [Available endpoints](#4-available-endpoints)
|
16
|
+
- 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
|
17
|
+
- 4.2. [Diablo III endpoints](#42-diablo-iii-endpoints)
|
18
|
+
- 4.3. [Starcraft II endpoints](#43-starcraft-ii-endpoints)
|
19
|
+
|
20
|
+
## 1. Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'blizzard_api'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
## 2. Configuration
|
33
|
+
|
34
|
+
Before you use the api you must create a developer account at https://develop.battle.net and create the client authorization keys.
|
35
|
+
|
36
|
+
Once you have a pair of client ID and SECRET you must set up an initialization code.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Blizzard.configure do |config|
|
40
|
+
config.app_id = ENV['BNET_APPLICATION_ID']
|
41
|
+
config.app_secret = ENV['BNET_APPLICATION_SECRET']
|
42
|
+
config.region = 'us'
|
43
|
+
config.use_cache = true
|
44
|
+
config.redis_host = ENV['REDIS_HOST']
|
45
|
+
config.redis_port = ENV['REDIS_PORT']
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
It is highly recommended to use [redis](https://redis.io/) to cache all requests as it avoids unnecessary calls and speeds up your application.
|
50
|
+
|
51
|
+
## 3. Basic usage
|
52
|
+
|
53
|
+
You can now consume the api by instantiating a specific endpoint:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
race = BlizzardApi::Wow::Race.new :us
|
57
|
+
race_data = race.complete
|
58
|
+
```
|
59
|
+
|
60
|
+
or you can just use the game namespace wrapper as follows:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
race = BlizzardApi::Wow.race
|
64
|
+
race_data = race.complete
|
65
|
+
```
|
66
|
+
|
67
|
+
:bulb: If you use the wrapper it will always use the default region specified in the configuration file.
|
68
|
+
|
69
|
+
Most **data** endpoints will have always 3 methods available `index`, `get` and `complete`.
|
70
|
+
|
71
|
+
* `index` is used to get a list of all resources od that endpoint.
|
72
|
+
* `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.
|
73
|
+
* `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.
|
74
|
+
|
75
|
+
## 4. Available endpoints
|
76
|
+
|
77
|
+
**Hint**: All methods support an additional optional hash parameter that allows you to override the following configurations for a single call:
|
78
|
+
|
79
|
+
* **ttl**: < int > - Cache duration (seconds) (Only works if you have redis enabled)
|
80
|
+
* **ignore_cache**: true - Ignores the cache and forces an api request (Only works if you have redis enabled)
|
81
|
+
* **locale**: < locale id > - Changes the default locale (if any)
|
82
|
+
|
83
|
+
### 4.1. World of Warcraft endpoints
|
84
|
+
|
85
|
+
* Blizzard::Wow::Achievement
|
86
|
+
- get :id
|
87
|
+
- character_achievement_index
|
88
|
+
- guild_achievement_index
|
89
|
+
* Blizzard::Wow::Auction
|
90
|
+
- get :realm
|
91
|
+
* Blizzard::Wow::Boss
|
92
|
+
- index
|
93
|
+
- 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
|
101
|
+
* Blizzard::Wow::Guild
|
102
|
+
- get :relam, :name, :fields
|
103
|
+
- rewards
|
104
|
+
- perks
|
105
|
+
* Blizzard::Wow::Item
|
106
|
+
- get :id
|
107
|
+
- item_set :setId
|
108
|
+
* Blizzard::Wow::Mount
|
109
|
+
- index
|
110
|
+
* Blizzard::Wow::Pet
|
111
|
+
- index
|
112
|
+
- ability :id
|
113
|
+
- species :id
|
114
|
+
- stats :level, :breed_id, :quality_id
|
115
|
+
- 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
|
125
|
+
- index
|
126
|
+
- get :id
|
127
|
+
* Blizzard::Wow::ConnectedRealm
|
128
|
+
- index
|
129
|
+
- get :id
|
130
|
+
- complete
|
131
|
+
* Blizzard::Wow::MythicKeystonesAffix
|
132
|
+
- index
|
133
|
+
- get :id
|
134
|
+
- complete
|
135
|
+
* Blizzard::Wow::PlayableClass
|
136
|
+
- index
|
137
|
+
- get :id
|
138
|
+
- complete
|
139
|
+
* Blizzard::Wow::PlayableSpecialization
|
140
|
+
- index
|
141
|
+
- get :id
|
142
|
+
- complete
|
143
|
+
* Blizzard::Wow::PowerType
|
144
|
+
- index
|
145
|
+
- get :id
|
146
|
+
- complete
|
147
|
+
* Blizzard::Wow::Race
|
148
|
+
- index
|
149
|
+
- get :id
|
150
|
+
- complete
|
151
|
+
* Blizzard::Wow::Realm
|
152
|
+
- index
|
153
|
+
- get :id
|
154
|
+
- complete
|
155
|
+
* Blizzard::Wow::Region
|
156
|
+
- index
|
157
|
+
- get :id
|
158
|
+
- complete
|
159
|
+
|
160
|
+
### 4.2. Diablo III endpoints
|
161
|
+
|
162
|
+
* BlizzardApi::Diablo::Act
|
163
|
+
- index
|
164
|
+
- get :id
|
165
|
+
* BlizzardApi::Diablo::Artisan
|
166
|
+
- get :artisan_slug
|
167
|
+
- recipe :artisan_slug, :recipe_slug
|
168
|
+
* BlizzardApi::Diablo::Follower
|
169
|
+
- get :slug
|
170
|
+
* BlizzardApi::Diablo::Character
|
171
|
+
- get :class_slug
|
172
|
+
- skill :class_slug, :skill_slug
|
173
|
+
* BlizzardApi::Diablo::ItemType
|
174
|
+
- index
|
175
|
+
- get :item_type_slug
|
176
|
+
* BlizzardApi::Diablo::Item
|
177
|
+
- get :item_slug, :item_id
|
178
|
+
* BlizzardApi::Diablo::Profile
|
179
|
+
- index :battletag, :oauth_token
|
180
|
+
- hero :battletag, :oauth_token, :hero_id
|
181
|
+
- hero_items :battletag, :oauth_token, :hero_id
|
182
|
+
- hero_follower_items :battletag, :oauth_token, :hero_id
|
183
|
+
|
184
|
+
### 4.3. 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::League
|
189
|
+
- get :season_id, :queue_id, :team_type, :league_id
|
190
|
+
* BlizzardApi::Starcraft::Profile
|
191
|
+
- static :region_id
|
192
|
+
- metadata :region_id, :realm_id, :profile_id
|
193
|
+
- profile :region_id, :realm_id, :profile_id
|
194
|
+
- ladder_summary :region_id, :realm_id, :profile_id
|
195
|
+
- ladder :region_id, :realm_id, :profile_id, :ladder_id
|
196
|
+
* BlizzardApi::Starcraft::Ladder
|
197
|
+
- grandmaster :region_id, :options
|
198
|
+
- season :region_id
|
199
|
+
* BlizzardApi::Starcraft::Account
|
200
|
+
- player :account_id
|
201
|
+
|
202
|
+
## Contributing
|
203
|
+
|
204
|
+
Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/francisschiavo/blizzard_api/issues
|
205
|
+
|
206
|
+
## License
|
207
|
+
|
208
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
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,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'blizzard_api/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.required_ruby_version = '>= 2.5'
|
9
|
+
spec.name = 'blizzard_api'
|
10
|
+
spec.version = BlizzardApi::VERSION
|
11
|
+
spec.authors = ['Francis Schiavo']
|
12
|
+
spec.email = ['francis.schiavo@francisschiavo.com']
|
13
|
+
spec.summary = 'Unofficial Ruby client for Blizzard Entertainment API'
|
14
|
+
spec.description = 'This is a simple interface to obtain data from Blizzard API'
|
15
|
+
spec.homepage = 'https://gitlab.com/francisschiavo/blizzard_api'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
21
|
+
|
22
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
spec.metadata['source_code_uri'] = 'https://gitlab.com/francisschiavo/blizzard_api'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://gitlab.com/francisschiavo/blizzard_api/blob/master/CHANGELOG.md'
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = 'exe'
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_runtime_dependency 'redis', '~> 4.1', '>= 4.1.0'
|
36
|
+
|
37
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
38
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
39
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rubocop', '~> 0.61'
|
42
|
+
end
|