Commit 84eb83c2 authored by Francis's avatar Francis
Browse files

Region manipulation improvements

parent 5b10d77b
Pipeline #134877770 passed with stage
in 5 minutes and 39 seconds
Please view this file on the master branch, otherwise it may be outdated
**Version 0.3.7**
Automated test improvements
Added region parameters to all game module methods. This will allow multi-region applications to have more flexibility when creating instances.
**Version 0.3.6**
Fix Diablo shortcuts.
......
PATH
remote: .
specs:
blizzard_api (0.3.6)
blizzard_api (0.3.7)
redis (~> 4.1, >= 4.1.0)
GEM
......
......@@ -11,15 +11,17 @@ module BlizzardApi
require_relative 'diablo/game_data/era'
##
# @param region [String] API Region
# @return {Season}
def self.season
BlizzardApi::Diablo::Season.new
def self.season(region = BlizzardApi.region)
BlizzardApi::Diablo::Season.new(region)
end
##
# @param region [String] API Region
# @return {Era}
def self.era
BlizzardApi::Diablo::Era.new
def self.era(region = BlizzardApi.region)
BlizzardApi::Diablo::Era.new(region)
end
# Diablo community api
......@@ -32,45 +34,52 @@ module BlizzardApi
require_relative 'diablo/community/profile'
##
# @param region [String] API Region
# @return {Act}
def self.act
BlizzardApi::Diablo::Act.new
def self.act(region = BlizzardApi.region)
BlizzardApi::Diablo::Act.new(region)
end
##
# @param region [String] API Region
# @return {Artisan}
def self.artisan
BlizzardApi::Diablo::Artisan.new
def self.artisan(region = BlizzardApi.region)
BlizzardApi::Diablo::Artisan.new(region)
end
##
# @param region [String] API Region
# @return {Follower}
def self.follower
BlizzardApi::Diablo::Follower.new
def self.follower(region = BlizzardApi.region)
BlizzardApi::Diablo::Follower.new(region)
end
##
# @param region [String] API Region
# @return {Character}
def self.character
BlizzardApi::Diablo::Character.new
def self.character(region = BlizzardApi.region)
BlizzardApi::Diablo::Character.new(region)
end
##
# @param region [String] API Region
# @return {ItemType}
def self.item_type
BlizzardApi::Diablo::ItemType.new
def self.item_type(region = BlizzardApi.region)
BlizzardApi::Diablo::ItemType.new(region)
end
##
# @param region [String] API Region
# @return {Type}
def self.item
BlizzardApi::Diablo::Item.new
def self.item(region = BlizzardApi.region)
BlizzardApi::Diablo::Item.new(region)
end
##
# @param region [String] API Region
# @return {Profile}
def self.profile
BlizzardApi::Diablo::Profile.new
def self.profile(region = BlizzardApi.region)
BlizzardApi::Diablo::Profile.new(region)
end
end
end
......@@ -13,27 +13,31 @@ module BlizzardApi
require_relative 'hearthstone/game_data/metadata'
##
# @param region [String] API Region
# @return {Card}
def self.card
BlizzardApi::Hearthstone::Card.new
def self.card(region = BlizzardApi.region)
BlizzardApi::Hearthstone::Card.new(region)
end
##
# @param region [String] API Region
# @return {Back}
def self.back
BlizzardApi::Hearthstone::Back.new
def self.back(region = BlizzardApi.region)
BlizzardApi::Hearthstone::Back.new(region)
end
##
# @param region [String] API Region
# @return {Deck}
def self.deck
BlizzardApi::Hearthstone::Deck.new
def self.deck(region = BlizzardApi.region)
BlizzardApi::Hearthstone::Deck.new(region)
end
##
# @param region [String] API Region
# @return {Metadata}
def self.metadata
BlizzardApi::Hearthstone::Metadata.new
def self.metadata(region = BlizzardApi.region)
BlizzardApi::Hearthstone::Metadata.new(region)
end
end
end
......@@ -3,7 +3,6 @@
##
# @!macro [new] request_options
# @param {Hash} options You can specify some options
# @option options [String] :region Overrides the default region for a single call
# @option options [String] :locale Overrides the default locale for a single call
# @option options [String] :namespace Overrides the default namespace for a single call
# @option options [String] :access_token Overrides the access_token for a single call
......
......@@ -9,9 +9,10 @@ module BlizzardApi
require_relative 'starcraft/game_data/league'
##
# @param region [String] API Region
# @return {League}
def self.league
BlizzardApi::Starcraft::League.new
def self.league(region = BlizzardApi.region)
BlizzardApi::Starcraft::League.new(region)
end
# Starcraft community api
......@@ -20,21 +21,24 @@ module BlizzardApi
require_relative 'starcraft/community/account'
##
# @param region [String] API Region
# @return {Profile}
def self.profile
BlizzardApi::Starcraft::Profile.new
def self.profile(region = BlizzardApi.region)
BlizzardApi::Starcraft::Profile.new(region)
end
##
# @param region [String] API Region
# @return {Ladder}
def self.ladder
BlizzardApi::Starcraft::Ladder.new
def self.ladder(region = BlizzardApi.region)
BlizzardApi::Starcraft::Ladder.new(region)
end
##
# @param region [String] API Region
# @return {Account}
def self.account
BlizzardApi::Starcraft::Account.new
def self.account(region = BlizzardApi.region)
BlizzardApi::Starcraft::Account.new(region)
end
end
end
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.3.6'
VERSION = '0.3.7'
end
......@@ -37,207 +37,206 @@ module BlizzardApi
require_relative 'wow/game_data/wow_token'
##
# @param region [String] API Region
# @return {Achievement}
def self.achievement
BlizzardApi::Wow::Achievement.new
def self.achievement(region = BlizzardApi.region)
BlizzardApi::Wow::Achievement.new(region)
end
##
# @param region [String] API Region
# @return {Auction}
def self.auction
BlizzardApi::Wow::Auction.new
def self.auction(region = BlizzardApi.region)
BlizzardApi::Wow::Auction.new(region)
end
##
# @param region [String] API Region
# @return {AzeriteEssence}
def self.azerite_essence
BlizzardApi::Wow::AzeriteEssence.new
def self.azerite_essence(region = BlizzardApi.region)
BlizzardApi::Wow::AzeriteEssence.new(region)
end
##
# @param region [String] API Region
# @return {ConnectedRealm}
def self.connected_realm
BlizzardApi::Wow::ConnectedRealm.new
def self.connected_realm(region = BlizzardApi.region)
BlizzardApi::Wow::ConnectedRealm.new(region)
end
##
# @param region [String] API Region
# @return {Creature}
def self.creature
BlizzardApi::Wow::Creature.new
def self.creature(region = BlizzardApi.region)
BlizzardApi::Wow::Creature.new(region)
end
##
# @param region [String] API Region
# @return {GuildCrest}
def self.guild_crest
BlizzardApi::Wow::GuildCrest.new
def self.guild_crest(region = BlizzardApi.region)
BlizzardApi::Wow::GuildCrest.new(region)
end
##
# @param region [String] API Region
# @return {Item}
def self.item
BlizzardApi::Wow::Item.new
def self.item(region = BlizzardApi.region)
BlizzardApi::Wow::Item.new(region)
end
##
# @param region [String] API Region
# @return {Journal}
def self.journal
BlizzardApi::Wow::Journal.new
def self.journal(region = BlizzardApi.region)
BlizzardApi::Wow::Journal.new(region)
end
##
# @param region [String] API Region
# @return {Mount}
def self.mount
BlizzardApi::Wow::Mount.new
def self.mount(region = BlizzardApi.region)
BlizzardApi::Wow::Mount.new(region)
end
##
# @param region [String] API Region
# @return {MythicKeystoneAffix}
def self.mythic_keystone_affix
BlizzardApi::Wow::MythicKeystoneAffix.new
def self.mythic_keystone_affix(region = BlizzardApi.region)
BlizzardApi::Wow::MythicKeystoneAffix.new(region)
end
##
# @param region [String] API Region
# @return {MythicKeystone}
def self.mythic_keystone
BlizzardApi::Wow::MythicKeystone.new
def self.mythic_keystone(region = BlizzardApi.region)
BlizzardApi::Wow::MythicKeystone.new(region)
end
##
# @param region [String] API Region
# @return {MythicRaidLeaderboard}
def self.mythic_raid_leaderboard
BlizzardApi::Wow::MythicRaidLeaderboard.new
def self.mythic_raid_leaderboard(region = BlizzardApi.region)
BlizzardApi::Wow::MythicRaidLeaderboard.new(region)
end
##
# @param region [String] API Region
# @return {MythicKeystoneLeaderboard}
def self.mythic_keystone_leaderboard
BlizzardApi::Wow::MythicKeystoneLeaderboard.new
def self.mythic_keystone_leaderboard(region = BlizzardApi.region)
BlizzardApi::Wow::MythicKeystoneLeaderboard.new(region)
end
##
# @param region [String] API Region
# @return {Pet}
def self.pet
BlizzardApi::Wow::Pet.new
def self.pet(region = BlizzardApi.region)
BlizzardApi::Wow::Pet.new(region)
end
##
# @param region [String] API Region
# @return {PlayableClass}
def self.playable_class
BlizzardApi::Wow::PlayableClass.new
def self.playable_class(region = BlizzardApi.region)
BlizzardApi::Wow::PlayableClass.new(region)
end
##
# @param region [String] API Region
# @return {Race}
def self.playable_race
BlizzardApi::Wow::PlayableRace.new
def self.playable_race(region = BlizzardApi.region)
BlizzardApi::Wow::PlayableRace.new(region)
end
##
# @param region [String] API Region
# @return {PlayableSpecialization}
def self.playable_specialization
BlizzardApi::Wow::PlayableSpecialization.new
def self.playable_specialization(region = BlizzardApi.region)
BlizzardApi::Wow::PlayableSpecialization.new(region)
end
##
# @param region [String] API Region
# @return {PowerType}
def self.power_type
BlizzardApi::Wow::PowerType.new
def self.power_type(region = BlizzardApi.region)
BlizzardApi::Wow::PowerType.new(region)
end
##
# @param region [String] API Region
# @return {PvpSeason}
def self.pvp_season
BlizzardApi::Wow::PvpSeason.new
def self.pvp_season(region = BlizzardApi.region)
BlizzardApi::Wow::PvpSeason.new(region)
end
##
# @param region [String] API Region
# @return {PvpTier}
def self.pvp_tier
BlizzardApi::Wow::PvpTier.new
def self.pvp_tier(region = BlizzardApi.region)
BlizzardApi::Wow::PvpTier.new(region)
end
##
# @param region [String] API Region
# @return {Quest}
def self.quest
BlizzardApi::Wow::Quest.new
def self.quest(region = BlizzardApi.region)
BlizzardApi::Wow::Quest.new(region)
end
##
# @param region [String] API Region
# @return {Realm}
def self.realm
BlizzardApi::Wow::Realm.new
def self.realm(region = BlizzardApi.region)
BlizzardApi::Wow::Realm.new(region)
end
##
# @param region [String] API Region
# @return {Region}
def self.region
BlizzardApi::Wow::Region.new
def self.region(region = BlizzardApi.region)
BlizzardApi::Wow::Region.new(region)
end
##
# @param region [String] API Region
# @return {Reputation}
def self.reputation
BlizzardApi::Wow::Reputation.new
def self.reputation(region = BlizzardApi.region)
BlizzardApi::Wow::Reputation.new(region)
end
##
# @param region [String] API Region
# @return {Spell}
def self.spell
BlizzardApi::Wow::Spell.new
def self.spell(region = BlizzardApi.region)
BlizzardApi::Wow::Spell.new(region)
end
##
# @param region [String] API Region
# @return {Talent}
def self.talent
BlizzardApi::Wow::Talent.new
def self.talent(region = BlizzardApi.region)
BlizzardApi::Wow::Talent.new(region)
end
##
# @param region [String] API Region
# @return {Title}
def self.title
BlizzardApi::Wow::Title.new
def self.title(region = BlizzardApi.region)
BlizzardApi::Wow::Title.new(region)
end
##
# @param region [String] API Region
# @return {WowToken}
def self.wow_token
BlizzardApi::Wow::WowToken.new
end
##
# @return {Boss}
def self.boss
BlizzardApi::Wow::Boss.new
end
##
# @return {Challenge}
def self.challenge
BlizzardApi::Wow::Challenge.new
def self.wow_token(region = BlizzardApi.region)
BlizzardApi::Wow::WowToken.new(region)
end
##
# @param region [String] API Region
# @return {Character}
def self.character
BlizzardApi::Wow::Character.new
end
##
# @return {PvP}
def self.pvp
BlizzardApi::Wow::PvP.new
end
##
# @return {Recipe}
def self.recipe
BlizzardApi::Wow::Recipe.new
end
##
# @return {Zone}
def self.zone
BlizzardApi::Wow::Zone.new
def self.character(region = BlizzardApi.region)
BlizzardApi::Wow::Character.new(region)
end
require_relative 'wow/profile/profile'
......@@ -246,24 +245,25 @@ module BlizzardApi
##
# @param token [String] A token obtained using the authorization_code flow
#
# @!macro request_options
# @param region [String] API Region
#
# @return {Profile}
def self.profile(token)
BlizzardApi::Wow::AccountProfile.new(token)
def self.profile(token, region = BlizzardApi.region)
BlizzardApi::Wow::AccountProfile.new(token, region)
end
##
# @param region [String] API Region
# @return {Guild}
def self.guild
BlizzardApi::Wow::Guild.new
def self.guild(region = BlizzardApi.region)
BlizzardApi::Wow::Guild.new(region)
end
##
# @param region [String] API Region
# @return {CharacterProfile}
def self.character_profile
BlizzardApi::Wow::CharacterProfile.new
def self.character_profile(region = BlizzardApi.region)
BlizzardApi::Wow::CharacterProfile.new(region)
end
end
end
......@@ -7,15 +7,17 @@ require 'test_helper'
module BlizzardApi
module Diablo
class ActTest < Minitest::Test
def setup
@act = BlizzardApi::Diablo.act
end
def test_act_index
act = BlizzardApi::Diablo::Act.new
act_data = act.index
act_data = @act.index
assert act_data[:acts]
end
def test_act_get
act = BlizzardApi::Diablo::Act.new
act_data = act.get 1
act_data = @act.get 1
assert act_data[:quests]
end
end
......
......@@ -7,15 +7,17 @@ require 'test_helper'
module BlizzardApi
module Diablo
class ArtisanTest < Minitest::Test
def setup
@artisan = BlizzardApi::Diablo.artisan
end
def test_artisan_index
artisan = BlizzardApi::Diablo::Artisan.new
artisan_data = artisan.get 'blacksmith'
artisan_data = @artisan.get 'blacksmith'
assert artisan_data[:training]
end
def test_artisan_get