GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit bb8814bf authored by Francis's avatar Francis
Browse files

Updated new endpoints

parent d5abf1a6
Pipeline #68724672 passed with stages
in 4 minutes and 22 seconds
......@@ -3,6 +3,10 @@ inherit_from: .rubocop_todo.yml
Metrics/LineLength:
Max: 120
Metrics/ModuleLength:
Exclude:
- 'lib/blizzard_api/wow.rb'
Metrics/AbcSize:
Max: 20
......
......@@ -5,9 +5,3 @@
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 3
Lint/UriEscapeUnescape:
Exclude:
- 'lib/blizzard_api/wow/community/character.rb'
- 'lib/blizzard_api/wow/community/guild.rb'
Please view this file on the master branch, otherwise it may be outdated
**Version 0.2.2**
* Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20771546990
**Version 0.2.1**
* Added icon to playable_class return value
* Temporarily ignoring some rubocop offenses as the recommended alternatives are not suitable
......
PATH
remote: .
specs:
blizzard_api (0.2.1)
blizzard_api (0.2.2)
redis (~> 4.1, >= 4.1.0)
GEM
......@@ -17,7 +17,7 @@ GEM
powerpack (0.1.2)
rainbow (3.0.0)
rake (10.5.0)
redis (4.1.0)
redis (4.1.1)
rubocop (0.61.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
......
......@@ -11,7 +11,7 @@ This gem allow you to interface with the new blizzard api (2018) using the OAuth
## Table of contents
1. [Installation](#1-installation)
2. [Configuration](#2-configuration)
3. [Basic usage](#1-basic-usage)
3. [Basic usage](#3-basic-usage)
4. [Available endpoints](#4-available-endpoints)
- 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
- 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
Once you have a pair of client ID and SECRET you must set up an initialization code.
```ruby
Blizzard.configure do |config|
BlizzardApi.configure do |config|
config.app_id = ENV['BNET_APPLICATION_ID']
config.app_secret = ENV['BNET_APPLICATION_SECRET']
config.region = 'us'
......@@ -84,78 +84,137 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
* Blizzard::Wow::Achievement
- get :id
- index
- categories
- category :id
- character_achievement_index
- guild_achievement_index
* Blizzard::Wow::Auction
- get :realm
* Blizzard::Wow::Boss
- media :id
* Blizzard::Wow::ConnectedRealm
- index
- get :id
* Blizzard::Wow::Challenge
- realm_index
- region_index
* Blizzard::Wow::Character
- get :realm, :character, :fields
- get_keystone_profile :realm, :character, :user_token, :season
- get_user_characters :user_token
- complete
* Blizzard::Wow::Creature
- get :id
- families
- family :id
- family_media :id
- types
- type :id
- display_media :id
* Blizzard::Wow::Guild
- get :relam, :name, :fields
- rewards
- perks
* Blizzard::Wow::Item
- get :realm, :guild
- roster :realm, :guild
- achievements :realm, :guild
* Blizzard::Wow::GuildCrest
- index
- border_media :id
- emblem_media :id
* Blizzard::Wow::MythicKeystonesAffix
- index
- get :id
- item_set :setId
- complete
* Blizzard::Wow::MythicKeystone
- index
- dungeons
- dungeon :id
- periods
- period :id
- seasons
- season :id
* Blizzard::Wow::MythicRaidLeaderboard
- get :raid_slug, :faction_slug
* Blizzard::Wow::Mount
- index
- get :id
- complete
* Blizzard::Wow::MythicKeystoneLeaderboard
- index :connected_realm_id
- get :connected_realm_id, :dungeon_id, :period
* Blizzard::Wow::Pet
- index
- get
- ability :id
- species :id
- stats :level, :breed_id, :quality_id
- types
* Blizzard::Wow::PvP
- get :bracket
* Blizzard::Wow::Quest
- get :id
* Blizzard::Wow::Recipe
- get :id
* Blizzard::Wow::Spell
- get :id
* Blizzard::Wow::Zone
* Blizzard::Wow::PlayableClass
- index
- get :id
* Blizzard::Wow::ConnectedRealm
- complete
- talent_slots :id
* Blizzard::Wow::PlayableSpecialization
- index
- get :id
- complete
* Blizzard::Wow::MythicKeystonesAffix
* Blizzard::Wow::PowerType
- index
- get :id
- complete
* Blizzard::Wow::PlayableClass
* Blizzard::Wow::PvpSeason
- index
- get :id
- complete
* Blizzard::Wow::PlayableSpecialization
- leaderboards :season_id
- leaderboard :season_id, :brackets
- rewards :season_id
* Blizzard::Wow::PvpTier
- index
- get :id
- tier_media :id
* Blizzard::Wow::Realm
- index
- get :id
- complete
* Blizzard::Wow::PowerType
* Blizzard::Wow::Region
- index
- get :id
- complete
* Blizzard::Wow::WowToken
- get
* Blizzard::Wow::Race
- index
- get :id
- complete
* Blizzard::Wow::Realm
* Blizzard::Wow::Auction
- get :realm
* Blizzard::Wow::Boss
- index
- get :id
- complete
* Blizzard::Wow::Region
* Blizzard::Wow::Challenge
- realm_index
- region_index
* Blizzard::Wow::Character
- get :realm, :character, :fields
- get_keystone_profile :realm, :character, :user_token, :season
- get_user_characters :user_token
* Blizzard::Wow::Guild
- get :relam, :name, :fields
- rewards
- perks
* Blizzard::Wow::Item
- get :id
- item_set :setId
* Blizzard::Wow::PvP
- get :bracket
* Blizzard::Wow::Quest
- get :id
* Blizzard::Wow::Recipe
- get :id
* Blizzard::Wow::Spell
- get :id
* Blizzard::Wow::Zone
- index
- get :id
- complete
* BlizzardApi::Wow::CharacterProfile
- get_keystone_profile :realm, :character, :user_token, :season
- pvp_summmary :realm, :character, :user_token
- pvp_bracket :realm, :character, :bracket, :user_token
### 4.2. Diablo III endpoints
......
......@@ -59,6 +59,33 @@ module BlizzardApi
# @return [String] Access token.
attr_accessor :access_token
##
# @!attribute icons_directory
# Icons directory.
# This directory stores icons for many World of Warcraft endpoints.
# @return [String] icons_directory
attr_accessor :wow_icons_directory
##
# @!attribute guild_emblem_directory
# Guild crest images directory. Some sub directories will be crated.
# @see https://develop.battle.net/access/clients
# @return [String] Guild crest directory
attr_accessor :wow_guild_crest_directory
##
# @!attribute wow_character_profile_directory
# This directory stores images for World of Warcraft character profiles. Sub directories will be created for
# each realm and character.
# @return [String] Character profile media directory
attr_accessor :wow_character_profile_directory
##
# @!attribute wow_npc_directory
# This directory stores images for World of Warcraft NPCs and creatures.
# @return [String] NPCs media directory
attr_accessor :wow_npc_directory
##
# This method return the singleton instance of the configuration module. Use this to initialize the default values
# and options.
......@@ -70,10 +97,15 @@ module BlizzardApi
# config.app_id = ENV['BNET_APPLICATION_ID']
# config.app_secret = ENV['BNET_APPLICATION_SECRET']
# config.region = 'us'
#
# config.use_cache = true
# config.redis_host = ENV['REDIS_HOST']
# config.redis_port = ENV['REDIS_PORT']
# config.format = :json
#
# config.icons_directory = './wow/icons'
# config.guild_crest_directory = './wow/guild_crest'
# config.wow_character_profile_directory = './wow/profile'
# end
def configure
yield self
......
require_relative 'media/configuration'
module Blizzard
# Media related implementations
module Media
extend MediaConfiguration
end
end
\ No newline at end of file
module BlizzardApi
module Media
# Media configuration and helpers
module MediaConfiguration
##
# @!attribute icons_directory
# Icons directory.
# This directory stores icons for many World of Warcraft endpoints.
# @return [String] icons_directory
attr_accessor :wow_icons_directory
##
# @!attribute guild_emblem_directory
# Guild crest images directory. Some sub directories will be crated.
# @see https://develop.battle.net/access/clients
# @return [String] Guild crest directory
attr_accessor :wow_guild_crest_directory
##
# @!attribute wow_character_profile_directory
# This directory stores images for World of Warcraft character profiles. Sub directories will be created for each
# realm and character.
# @return [String] Character profile media directory
attr_accessor :wow_character_profile_directory
##
# This method return the singleton instance of the media module. Use this to initialize the default values
# and options.
#
# @yield self
#
# @example
# Blizzard::Media.configure do |config|
# config.icons_directory = './wow/icons'
# config.guild_crest_directory = './wow/guild_crest'
# config.wow_character_profile_directory = './wow/profile'
# end
def configure
yield self
end
end
end
end
module BlizzardApi
module Media
# Used to store and retrieve API media files
class MediaCache
def download_media(filename, url)
require 'net/http'
require 'fileutils'
FileUtils.mkdir_p File.dirname(filename)
File.open(filename, 'wb') do |file|
data = Net::HTTP.get_response(URI.parse(url)).body
file << data
end
end
end
end
end
......@@ -90,11 +90,17 @@ module BlizzardApi
"dynamic-#{region}"
when :static
"static-#{region}"
when :profile
"profile-#{region}"
else
raise ArgumentError, 'Invalid namespace scope'
end
end
def string_to_slug(string)
string.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')
end
def create_access_token
uri = URI.parse("https://#{BlizzardApi.region}.battle.net/oauth/token")
......
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.2.1'
VERSION = '0.2.2'
end
......@@ -8,15 +8,25 @@ module BlizzardApi
# WoW data api
require_relative 'wow/game_data/achievement'
require_relative 'wow/game_data/achievement_category'
require_relative 'wow/game_data/region'
require_relative 'wow/game_data/realm'
require_relative 'wow/game_data/connected_realm'
require_relative 'wow/game_data/race'
require_relative 'wow/game_data/creature'
require_relative 'wow/game_data/guild'
require_relative 'wow/game_data/guild_crest'
require_relative 'wow/game_data/mythic_keystone_affix'
require_relative 'wow/game_data/mythic_keystone'
require_relative 'wow/game_data/mythic_raid_leaderboard'
require_relative 'wow/game_data/mount'
require_relative 'wow/game_data/mythic_keystone_leaderboard'
require_relative 'wow/game_data/pet'
require_relative 'wow/game_data/playable_class'
require_relative 'wow/game_data/playable_specialization'
require_relative 'wow/game_data/power_type'
require_relative 'wow/game_data/mythic_keystone_affix'
require_relative 'wow/game_data/pvp_season'
require_relative 'wow/game_data/pvp_tier'
require_relative 'wow/game_data/realm'
require_relative 'wow/game_data/region'
require_relative 'wow/game_data/wow_token'
require_relative 'wow/game_data/race'
##
# @return {Achievement}
......@@ -25,33 +35,63 @@ module BlizzardApi
end
##
# @return {AchievementCategory}
def self.achievement_category
BlizzardApi::Wow::AchievementCategory.new
# @return {ConnectedRealm}
def self.connected_realm
BlizzardApi::Wow::ConnectedRealm.new
end
##
# @return {Region}
def self.region
BlizzardApi::Wow::Region.new
# @return {Creature}
def self.creature
BlizzardApi::Wow::Creature.new
end
##
# @return {Realm}
def self.realm
BlizzardApi::Wow::Realm.new
# @return {Guild}
def self.guild
BlizzardApi::Wow::Guild.new
end
##
# @return {ConnectedRealm}
def self.connected_realm
BlizzardApi::Wow::ConnectedRealm.new
# @return {GuildCrest}
def self.guild_crest
BlizzardApi::Wow::GuildCrest.new
end
##
# @return {Race}
def self.race
BlizzardApi::Wow::Race.new
# @return {MythicKeystoneAffix}
def self.mythic_keystone_affix
BlizzardApi::Wow::MythicKeystoneAffix.new
end
##
# @return {MythicKeystone}
def self.mythic_keystone
BlizzardApi::Wow::MythicKeystone.new
end
##
# @return {MythicRaidLeaderboard}
def self.mythic_raid_leaderboard
BlizzardApi::Wow::MythicRaidLeaderboard.new
end
##
# @return {Mount}
def self.mount
BlizzardApi::Wow::Mount.new
end
##
# @return {MythicKeystoneLeaderboard}
def self.mythic_keystone_leaderboard
BlizzardApi::Wow::MythicKeystoneLeaderboard.new
end
##
# @return {Pet}
def self.pet
BlizzardApi::Wow::Pet.new
end
##
......@@ -73,9 +113,39 @@ module BlizzardApi
end
##
# @return {MythicKeystoneAffix}
def self.mythic_keystone_affix
BlizzardApi::Wow::MythicKeystoneAffix.new
# @return {PvpSeason}
def self.pvp_season
BlizzardApi::Wow::PvpSeason.new
end
##
# @return {PvpTier}
def self.pvp_tier
BlizzardApi::Wow::PvpTier.new
end
##
# @return {Realm}
def self.realm
BlizzardApi::Wow::Realm.new
end
##
# @return {Region}
def self.region
BlizzardApi::Wow::Region.new
end
##
# @return {WowToken}
def self.wow_token
BlizzardApi::Wow::WowToken.new
end
##
# @return {Race}
def self.race
BlizzardApi::Wow::Race.new
end
# Wow community api
......@@ -83,10 +153,7 @@ module BlizzardApi
require_relative 'wow/community/boss'
require_relative 'wow/community/challenge'
require_relative 'wow/community/character'
require_relative 'wow/community/guild'
require_relative 'wow/community/item'
require_relative 'wow/community/mount'
require_relative 'wow/community/pets'
require_relative 'wow/community/pvp'
require_relative 'wow/community/quest'
require_relative 'wow/community/recipe'
......@@ -117,30 +184,12 @@ module BlizzardApi
BlizzardApi::Wow::Character.new
end
##
# @return {Guild}
def self.guild
BlizzardApi::Wow::Guild.new
end
##
# @return {Item}
def self.item
BlizzardApi::Wow::Item.new
end
##
# @return {Mount}
def self.mount
BlizzardApi::Wow::Mount.new
end
##
# @return {Pet}
def self.pet
BlizzardApi::Wow::Pet.new
end
##
# @return {PvP}
def self.pvp
......@@ -170,5 +219,13 @@ module BlizzardApi
def self.zone
BlizzardApi::Wow::Zone.new
end
require_relative 'wow/profile/character_profile'
##
# @return {CharacterProfile}
def self.character_profile
BlizzardApi::Wow::CharacterProfile.new
end
end
end
......@@ -60,28 +60,7 @@ module BlizzardApi
opts = { ttl: CACHE_DAY, fields: fields.join(',') }.merge(options)
api_request "#{base_url(:community)}/character/#{realm}/#{URI.encode(character)}", opts
end
##
# Return the mythic keystone profile of a character
#
# @note This endpoint requires a user token obtained through the user authorization flow
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
#
# @param realm [String] The character realm's slug
# @param character [String] The character name
# @param user_token [String] A token obtained by the authorization flow. See link below.
# @param season [Integer] Season ID if you want only a specific season or nil to include all.
# @!macro request_options
#