blizzard_api 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/blizzard_api.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'blizzard_api/configuration'
|
4
|
+
require_relative 'blizzard_api/request'
|
5
|
+
require_relative 'blizzard_api/exception'
|
6
|
+
require_relative 'blizzard_api/version'
|
7
|
+
require_relative 'blizzard_api/wow'
|
8
|
+
require_relative 'blizzard_api/diablo'
|
9
|
+
require_relative 'blizzard_api/starcraft'
|
10
|
+
|
11
|
+
# Blizzard namespace
|
12
|
+
module BlizzardApi
|
13
|
+
extend Configuration
|
14
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
# Global configurations
|
5
|
+
module Configuration
|
6
|
+
##
|
7
|
+
# @!attribute app_id
|
8
|
+
# Application ID.
|
9
|
+
# @see https://develop.battle.net/access/clients
|
10
|
+
# @return [String] Application ID
|
11
|
+
attr_accessor :app_id
|
12
|
+
|
13
|
+
##
|
14
|
+
# @!attribute app_secret
|
15
|
+
# Application secret.
|
16
|
+
# @see https://develop.battle.net/access/clients
|
17
|
+
# @return [String] Application secret
|
18
|
+
attr_accessor :app_secret
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute region
|
22
|
+
# Default region.
|
23
|
+
# @return [String] Default region
|
24
|
+
attr_accessor :region
|
25
|
+
|
26
|
+
##
|
27
|
+
# @!attribute use_cache
|
28
|
+
# If true requests will be cached using a Redis server.
|
29
|
+
# @see https://redis.io/
|
30
|
+
# @return [Boolean] Application ID
|
31
|
+
attr_accessor :use_cache
|
32
|
+
|
33
|
+
##
|
34
|
+
# @!attribute redis_host
|
35
|
+
# Redis host.
|
36
|
+
# @see https://redis.io/
|
37
|
+
# @return [String] Redis host
|
38
|
+
attr_accessor :redis_host
|
39
|
+
|
40
|
+
##
|
41
|
+
# @!attribute redis_port
|
42
|
+
# Redis port.
|
43
|
+
# @see https://redis.io/
|
44
|
+
# @return [Integer] Redis port
|
45
|
+
attr_accessor :redis_port
|
46
|
+
|
47
|
+
##
|
48
|
+
# @!attribute format
|
49
|
+
# Response format:
|
50
|
+
# * *:raw* plain text (String)
|
51
|
+
# * *:json* for native ruby json (Array).
|
52
|
+
# * Any other value *OpenStruct* will be used.
|
53
|
+
# @return [Symbol] Response format.
|
54
|
+
attr_accessor :format
|
55
|
+
|
56
|
+
##
|
57
|
+
# @!attribute access_token
|
58
|
+
# Access token. Optional. If you don't provide one it will be generate using your client credentials.
|
59
|
+
# @return [String] Access token.
|
60
|
+
attr_accessor :access_token
|
61
|
+
|
62
|
+
##
|
63
|
+
# This method return the singleton instance of the configuration module. Use this to initialize the default values
|
64
|
+
# and options.
|
65
|
+
#
|
66
|
+
# @yield self
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# Blizzard.configure do |config|
|
70
|
+
# config.app_id = ENV['BNET_APPLICATION_ID']
|
71
|
+
# config.app_secret = ENV['BNET_APPLICATION_SECRET']
|
72
|
+
# config.region = 'us'
|
73
|
+
# config.use_cache = true
|
74
|
+
# config.redis_host = ENV['REDIS_HOST']
|
75
|
+
# config.redis_port = ENV['REDIS_PORT']
|
76
|
+
# config.format = :json
|
77
|
+
# end
|
78
|
+
def configure
|
79
|
+
yield self
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
# Diablo III related classes
|
5
|
+
module Diablo
|
6
|
+
require_relative 'diablo/request'
|
7
|
+
require_relative 'diablo/game_data/generic_data_endpoint'
|
8
|
+
|
9
|
+
# Diablo data api
|
10
|
+
require_relative 'diablo/game_data/season'
|
11
|
+
require_relative 'diablo/game_data/era'
|
12
|
+
|
13
|
+
##
|
14
|
+
# @return {Season}
|
15
|
+
def season
|
16
|
+
BlizzardApi::Diablo::Season.new
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# @return {Era}
|
21
|
+
def era
|
22
|
+
BlizzardApi::Diablo::Era.new
|
23
|
+
end
|
24
|
+
|
25
|
+
# Diablo community api
|
26
|
+
require_relative 'diablo/community/act'
|
27
|
+
require_relative 'diablo/community/artisan'
|
28
|
+
require_relative 'diablo/community/follower'
|
29
|
+
require_relative 'diablo/community/character'
|
30
|
+
require_relative 'diablo/community/item_type'
|
31
|
+
require_relative 'diablo/community/item'
|
32
|
+
require_relative 'diablo/community/profile'
|
33
|
+
|
34
|
+
##
|
35
|
+
# @return {Act}
|
36
|
+
def act
|
37
|
+
BlizzardApi::Diablo::Act.new
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# @return {Artisan}
|
42
|
+
def artisan
|
43
|
+
BlizzardApi::Diablo::Artisan.new
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# @return {Follower}
|
48
|
+
def follower
|
49
|
+
BlizzardApi::Diablo::Follower.new
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# @return {Character}
|
54
|
+
def character
|
55
|
+
BlizzardApi::Diablo::Character.new
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# @return {ItemType}
|
60
|
+
def item_type
|
61
|
+
BlizzardApi::Diablo::ItemType.new
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# @return {Type}
|
66
|
+
def item
|
67
|
+
BlizzardApi::Diablo::Item.new
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# @return {Profile}
|
72
|
+
def profile
|
73
|
+
BlizzardApi::Diablo::Profile.new
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III act data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.act
|
12
|
+
class Act < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return a list with all acts
|
15
|
+
#
|
16
|
+
# @!macro request_options
|
17
|
+
#
|
18
|
+
# @!macro response
|
19
|
+
def index(options = {})
|
20
|
+
api_request "#{base_url(:community)}/data/act", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Return complete information about an act
|
25
|
+
#
|
26
|
+
# @param id [Integer] Act id
|
27
|
+
# @!macro request_options
|
28
|
+
#
|
29
|
+
# @!macro response
|
30
|
+
def get(id, options = {})
|
31
|
+
api_request "#{base_url(:community)}/data/act/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III artisan data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.artisan
|
12
|
+
class Artisan < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return data about an artisan by its slug
|
15
|
+
#
|
16
|
+
# @param artisan_slug [String] Artisan slug
|
17
|
+
# @!macro request_options
|
18
|
+
#
|
19
|
+
# @!macro response
|
20
|
+
def get(artisan_slug, options = {})
|
21
|
+
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Return data about an artisan recipe
|
26
|
+
#
|
27
|
+
# @param artisan_slug [String] Artisan slug
|
28
|
+
# @param recipe_slug [String] Recipe slug
|
29
|
+
# @!macro request_options
|
30
|
+
#
|
31
|
+
# @!macro response
|
32
|
+
def recipe(artisan_slug, recipe_slug, options = {})
|
33
|
+
opts = { ttl: CACHE_TRIMESTER }.merge(options)
|
34
|
+
api_request "#{base_url(:community)}/data/artisan/#{artisan_slug}/recipe/#{recipe_slug}", opts
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III character data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.character
|
12
|
+
class Character < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return information about a class
|
15
|
+
#
|
16
|
+
# @param class_slug [String] Class slug
|
17
|
+
# @!macro request_options
|
18
|
+
#
|
19
|
+
# @!macro response
|
20
|
+
def get(class_slug, options = {})
|
21
|
+
api_request "#{base_url(:community)}/data/hero/#{class_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Return information about a class' skill
|
26
|
+
#
|
27
|
+
# @param class_slug [String] Class slug
|
28
|
+
# @param skill_slug [String] Skill slug
|
29
|
+
# @!macro request_options
|
30
|
+
#
|
31
|
+
# @!macro response
|
32
|
+
def skill(class_slug, skill_slug, options = {})
|
33
|
+
opts = { ttl: CACHE_TRIMESTER }.merge(options)
|
34
|
+
api_request "#{base_url(:community)}/data/hero/#{class_slug}/skill/#{skill_slug}", opts
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III follower data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.follower
|
12
|
+
class Follower < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return information about a follower
|
15
|
+
#
|
16
|
+
# @param follower_slug [String] Follower slug
|
17
|
+
# @!macro request_options
|
18
|
+
#
|
19
|
+
# @!macro response
|
20
|
+
def get(follower_slug, options = {})
|
21
|
+
api_request "#{base_url(:community)}/data/follower/#{follower_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III item data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.item
|
12
|
+
class Item < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return information about an item
|
15
|
+
#
|
16
|
+
# @param item_slug [String] Item slug
|
17
|
+
# @param item_id [Integer] Item id
|
18
|
+
# @!macro request_options
|
19
|
+
#
|
20
|
+
# @!macro response
|
21
|
+
def get(item_slug, item_id, options = {})
|
22
|
+
api_request "#{base_url(:community)}/data/item/#{item_slug}-#{item_id}", { ttl: CACHE_TRIMESTER }.merge(options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III item type data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.item_type
|
12
|
+
class ItemType < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return a list of item types
|
15
|
+
#
|
16
|
+
# @!macro request_options
|
17
|
+
#
|
18
|
+
# @!macro response
|
19
|
+
def index(options = {})
|
20
|
+
api_request "#{base_url(:community)}/data/item-type", { ttl: CACHE_TRIMESTER }.merge(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Return more information about an item type
|
25
|
+
#
|
26
|
+
# @param item_type_slug [String] Item type slug
|
27
|
+
# @!macro request_options
|
28
|
+
#
|
29
|
+
# @!macro response
|
30
|
+
def get(item_type_slug, options = {})
|
31
|
+
api_request "#{base_url(:community)}/data/item-type/#{item_type_slug}", { ttl: CACHE_TRIMESTER }.merge(options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BlizzardApi
|
4
|
+
module Diablo
|
5
|
+
##
|
6
|
+
# This class allows access to Diablo III profile data
|
7
|
+
#
|
8
|
+
# @see https://develop.battle.net/documentation/api-reference/diablo-3-community-api
|
9
|
+
#
|
10
|
+
# You can get an instance of this class using the default region as follows:
|
11
|
+
# api_instance = BlizzardApi::Diablo.profile
|
12
|
+
class Profile < BlizzardApi::Diablo::Request
|
13
|
+
##
|
14
|
+
# Return an user's profile data with a list of heroes
|
15
|
+
#
|
16
|
+
# @param battletag [String] User's battletag
|
17
|
+
# @param oauth_token [String] A token generated by the OAuth authorization flow. See the link below for more info.
|
18
|
+
# @!macro request_options
|
19
|
+
#
|
20
|
+
# @!macro response
|
21
|
+
#
|
22
|
+
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
23
|
+
def index(battletag, oauth_token, options = {})
|
24
|
+
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
25
|
+
api_request "#{base_url(:community)}/data/profile/#{battletag}", opts
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Return more data about a hero
|
30
|
+
#
|
31
|
+
# @param battletag [String] User's battletag
|
32
|
+
# @param oauth_token [String] A token generated by the OAuth authorization flow. See the link below for more info.
|
33
|
+
# @param hero_id [Integer] Hero id
|
34
|
+
# @!macro request_options
|
35
|
+
#
|
36
|
+
# @!macro response
|
37
|
+
#
|
38
|
+
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
39
|
+
def hero(battletag, oauth_token, hero_id, options = {})
|
40
|
+
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
41
|
+
api_request "#{base_url(:community)}/data/profile/#{battletag}/hero/#{hero_id}", opts
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Return more data about a hero's items
|
46
|
+
#
|
47
|
+
# @param battletag [String] User's battletag
|
48
|
+
# @param oauth_token [String] A token generated by the OAuth authorization flow. See the link below for more info.
|
49
|
+
# @param hero_id [Integer] Hero id
|
50
|
+
# @!macro request_options
|
51
|
+
#
|
52
|
+
# @!macro response
|
53
|
+
#
|
54
|
+
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
55
|
+
def hero_items(battletag, oauth_token, hero_id, options = {})
|
56
|
+
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
57
|
+
api_request "#{base_url(:community)}/data/profile/#{battletag}/hero/#{hero_id}/items", opts
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# Return more data about a hero's followers
|
62
|
+
#
|
63
|
+
# @param battletag [String] User's battletag
|
64
|
+
# @param oauth_token [String] A token generated by the OAuth authorization flow. See the link below for more info.
|
65
|
+
# @param hero_id [Integer] Hero id
|
66
|
+
# @!macro request_options
|
67
|
+
#
|
68
|
+
# @!macro response
|
69
|
+
#
|
70
|
+
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
|
71
|
+
def hero_follower_items(battletag, oauth_token, hero_id, options = {})
|
72
|
+
opts = { access_token: oauth_token, ttl: CACHE_TRIMESTER }.merge(options)
|
73
|
+
api_request "#{base_url(:community)}/data/profile/#{battletag}/hero/#{hero_id}/follower-items", opts
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|