diff --git a/CHANGELOG.md b/CHANGELOG.md index 582add2dfad2557a5733ae1e30f1a0adf2b8abd9..ec2aa12b16ac75b39b75a43ce5e5dc3d14e1b788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Please view this file on the master branch, otherwise it may be outdated +**Version 0.5.2** + +Added new endpoints: https://us.forums.blizzard.com/en/blizzard/t/wow-shadowlands-api-update-covenenats-soulbinds-more/13385 + **Version 0.5.1** Added new endpoints: https://us.forums.blizzard.com/en/blizzard/t/wow-game-data-api-modified-crafting-support/12727 diff --git a/lib/blizzard_api/version.rb b/lib/blizzard_api/version.rb index d91e847e0f9a55331a105b59af51fd136510729a..df9b29f7a5b0a232e06a5ebe295f17e7e716b91d 100644 --- a/lib/blizzard_api/version.rb +++ b/lib/blizzard_api/version.rb @@ -2,5 +2,5 @@ module BlizzardApi # Gem version - VERSION = '0.5.1' + VERSION = '0.5.2' end diff --git a/lib/blizzard_api/wow.rb b/lib/blizzard_api/wow.rb index 62cabb3769a697784916e3d9c4b19eb18b49ba5b..23cbf2191ba80401b0ca6371a1b9263f3c057205 100644 --- a/lib/blizzard_api/wow.rb +++ b/lib/blizzard_api/wow.rb @@ -14,6 +14,7 @@ module BlizzardApi require_relative 'wow/game_data/auction' require_relative 'wow/game_data/azerite_essence' require_relative 'wow/game_data/connected_realm' + require_relative 'wow/game_data/covenant' require_relative 'wow/game_data/creature' require_relative 'wow/game_data/guild_crest' require_relative 'wow/game_data/item' @@ -39,6 +40,7 @@ module BlizzardApi require_relative 'wow/game_data/reputation' require_relative 'wow/game_data/spell' require_relative 'wow/game_data/talent' + require_relative 'wow/game_data/tech_talent' require_relative 'wow/game_data/title' require_relative 'wow/game_data/wow_token' @@ -70,6 +72,13 @@ module BlizzardApi BlizzardApi::Wow::ConnectedRealm.new(region) end + ## + # @param region [String] API Region + # @return {Covenant} + def self.covenant(region = BlizzardApi.region) + BlizzardApi::Wow::Covenant.new(region) + end + ## # @param region [String] API Region # @return {Creature} @@ -245,6 +254,13 @@ module BlizzardApi BlizzardApi::Wow::Talent.new(region) end + ## + # @param region [String] API Region + # @return {TechTalent} + def self.tech_talent(region = BlizzardApi.region) + BlizzardApi::Wow::TechTalent.new(region) + end + ## # @param region [String] API Region # @return {Title} diff --git a/lib/blizzard_api/wow/game_data/covenant.rb b/lib/blizzard_api/wow/game_data/covenant.rb new file mode 100644 index 0000000000000000000000000000000000000000..56cc34598297265c3ae11bf0f20260ecba081c38 --- /dev/null +++ b/lib/blizzard_api/wow/game_data/covenant.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +module BlizzardApi + module Wow + ## + # This class allows access to World of Warcraft azerite essences + # + # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-game-data-api + # + # You can get an instance of this class using the default region as follows: + # api_instance = BlizzardApi::Wow.azerite_essence + class Covenant < Wow::GenericDataEndpoint + ## + # Fetch media for one of the covenants listed by the {#index} using its *id* + # + # @param id [Integer] Covenant id + # + # @!macro request_options + # + # @!macro response + def media(id, options = {}) + api_request "#{base_url(:media)}/covenant/#{id}", default_options.merge(options) + end + + ## + # Fetch all soulbinds + # + # @!macro request_options + # + # @!macro response + def soulbinds(options = {}) + api_request "#{base_url(:game_data)}/covenant/soulbind/index", default_options.merge(options) + end + + ## + # Fetch a soulbind by its id + # + # @param id Soulbind id + # + # @!macro request_options + # + # @!macro response + def soulbind(id, options = {}) + api_request "#{base_url(:game_data)}/covenant/soulbind/#{id}", default_options.merge(options) + end + + ## + # Fetch all conduits + # + # @!macro request_options + # + # @!macro response + def conduits(options = {}) + api_request "#{base_url(:game_data)}/covenant/conduit/index", default_options.merge(options) + end + + ## + # Fetch a conduit by its id + # + # @param id Conduit id + # + # @!macro request_options + # + # @!macro response + def conduit(id, options = {}) + api_request "#{base_url(:game_data)}/covenant/conduit/#{id}", default_options.merge(options) + end + + protected + + def endpoint_setup + @endpoint = 'covenant' + @namespace = :static + @collection = 'covenants' + @ttl = CACHE_TRIMESTER + end + end + end +end diff --git a/lib/blizzard_api/wow/game_data/tech_talent.rb b/lib/blizzard_api/wow/game_data/tech_talent.rb new file mode 100644 index 0000000000000000000000000000000000000000..44ee09e50b6584d4f7f0b2de92d3660c858f85d5 --- /dev/null +++ b/lib/blizzard_api/wow/game_data/tech_talent.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +module BlizzardApi + module Wow + ## + # This class allows access to World of Warcraft talent data + # + # @see https://develop.battle.net/documentation/world-of-warcraft/game-data-apis + # + # You can get an instance of this class using the default region as follows: + # api_instance = BlizzardApi::Wow.talent + class TechTalent < Wow::GenericDataEndpoint + ## + # Fetch tech talent trees + # + # @!macro request_options + # + # @!macro response + def tech_talent_trees(options = {}) + api_request "#{base_url(:game_data)}/tech-talent-tree/index", default_options.merge(options) + end + + ## + # Fetch a tech talent tree + # + # @param id [Integer] Tech talent id + # + # @!macro request_options + # + # @!macro response + def tech_talent_tree(id, options = {}) + api_request "#{base_url(:game_data)}/tech-talent-tree/#{id}", default_options.merge(options) + end + + ## + # Fetch a tech talent media + # + # @param id [Integer] Tech talent id + # + # @!macro request_options + # + # @!macro response + def media(id, options = {}) + api_request "#{base_url(:media)}/tech-talent/#{id}", default_options.merge(options) + end + + protected + + def endpoint_setup + @endpoint = 'tech-talent' + @namespace = :static + @collection = 'tech-talents' + @ttl = CACHE_TRIMESTER + end + end + end +end diff --git a/lib/blizzard_api/wow/profile/character_profile.rb b/lib/blizzard_api/wow/profile/character_profile.rb index 7319c470400b3829280f0b04d5dcf9c7e7cdf121..c014a506ab07d07820fbadf13aa5f9a167ffb5ec 100644 --- a/lib/blizzard_api/wow/profile/character_profile.rb +++ b/lib/blizzard_api/wow/profile/character_profile.rb @@ -313,6 +313,20 @@ module BlizzardApi character_request realm, character, options, 'reputations' end + ## + # Return a character's soulbinds + # + # @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-profile-api + # + # @param realm [String] The character realm's slug + # @param character [String] The character name + # @!macro request_options + # + # @!macro response + def soulbinds(realm, character, options = {}) + character_request realm, character, options, 'soulbinds' + end + ## # Return a character's specialization # diff --git a/test/blizzard/wow/game_data/achievement_test.rb b/test/blizzard/wow/game_data/achievement_test.rb index 753e0cf17db0205bd0f1da0f98f951f11170d53f..1f0b22c5df68c42169deeb939e8c58702d27d0f2 100644 --- a/test/blizzard/wow/game_data/achievement_test.rb +++ b/test/blizzard/wow/game_data/achievement_test.rb @@ -11,7 +11,7 @@ module BlizzardApi def test_achievement_index achievement_data = @achievement.index - assert_equal 5418, achievement_data[:achievements].count + assert achievement_data.key? :achievements end def test_achievement_get diff --git a/test/blizzard/wow/game_data/covenant_test.rb b/test/blizzard/wow/game_data/covenant_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..a2021ce9afc645b00a54685ff7d4ba1d1728cecd --- /dev/null +++ b/test/blizzard/wow/game_data/covenant_test.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'test_helper' + +module BlizzardApi + module Wow + class CovenantTest < Minitest::Test + def setup + @covenant = BlizzardApi::Wow.covenant + end + + def test_covenant_index + data = @covenant.index + assert_equal 4, data[:covenants].count + end + + def test_covenant_get + data = @covenant.get 3 + assert_equal 'Night Fae', data[:name][:en_US] + end + + def test_covenant_media + data = @covenant.media 3 + assert data.key? :assets + end + + def test_soulbind_index + data = @covenant.soulbinds + assert data.key? :soulbinds + end + + def test_soulbind_get + data = @covenant.soulbind 1 + assert_equal 'Niya', data[:name][:en_US] + end + + def test_conduit_index + data = @covenant.conduits + assert data.key? :conduits + end + + def test_conduit_get + data = @covenant.conduit 10 + assert_equal 'Fueled by Violence', data[:name][:en_US] + end + end + end +end diff --git a/test/blizzard/wow/game_data/pets_test.rb b/test/blizzard/wow/game_data/pets_test.rb index bb9df2d143f811197b13e866c67f0cb3881b8ac8..5b6aa501258b8561b9d735921d348b69c67ba373 100644 --- a/test/blizzard/wow/game_data/pets_test.rb +++ b/test/blizzard/wow/game_data/pets_test.rb @@ -11,7 +11,7 @@ module BlizzardApi def test_pet_index pet_data = @pet.index - assert_equal 1365, pet_data[:pets].count + assert pet_data.key? :pets end def test_pet_get @@ -26,7 +26,7 @@ module BlizzardApi def test_pet_ability_index pet_data = @pet.abilities - assert_equal 669, pet_data[:abilities].count + assert pet_data.key? :abilities end def test_pet_ability_get diff --git a/test/blizzard/wow/game_data/reputation_test.rb b/test/blizzard/wow/game_data/reputation_test.rb index d4b36a58dcbd4bea6495c0e3e0027c9fdf3045ba..7538d44fbf19ee6fbc2492b6fb865c0170ad6ed2 100644 --- a/test/blizzard/wow/game_data/reputation_test.rb +++ b/test/blizzard/wow/game_data/reputation_test.rb @@ -21,7 +21,7 @@ module BlizzardApi def test_reputation_tier_index reputation_data = @reputation.tiers - assert_equal 53, reputation_data[:reputation_tiers].count + assert_equal 55, reputation_data[:reputation_tiers].count end def test_reputation_tier_get diff --git a/test/blizzard/wow/game_data/talent_test.rb b/test/blizzard/wow/game_data/talent_test.rb index 03a84427c66e3c87f6c0c028d390e437d9b4bff1..d1be5b007747ea19ace8a2d3fb347d2601a5044b 100644 --- a/test/blizzard/wow/game_data/talent_test.rb +++ b/test/blizzard/wow/game_data/talent_test.rb @@ -11,7 +11,7 @@ module BlizzardApi def test_talent_index talent_data = @talent.index - assert_equal 636, talent_data[:talents].count + assert talent_data.key? :talents end def test_talent_get @@ -21,7 +21,7 @@ module BlizzardApi def test_pvp_talent_index talent_data = @talent.pvp_talents - assert_equal 389, talent_data[:pvp_talents].count + assert_equal 390, talent_data[:pvp_talents].count end def test_pvp_talent_get diff --git a/test/blizzard/wow/game_data/tech_talent_test.rb b/test/blizzard/wow/game_data/tech_talent_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..f2573950a5b4f234db46d7c0426000a7d00b5204 --- /dev/null +++ b/test/blizzard/wow/game_data/tech_talent_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'test_helper' + +module BlizzardApi + module Wow + class TechTalentTest < Minitest::Test + def setup + @talent = BlizzardApi::Wow.tech_talent + end + + def test_tech_talent_index + talent_data = @talent.index + assert talent_data.key? :talents + end + + def test_tech_talent_get + talent_data = @talent.get 807 + assert_equal 'Skillful Duelist', talent_data[:name][:en_US] + end + + def test_tech_talent_media + talent_data = @talent.media 807 + assert_equal 'https://render-us.worldofwarcraft.com/icons/56/inv_tabard_duelersguild.jpg', talent_data[:assets][0][:value] + end + + def test_tech_talent_tree_index + talent_data = @talent.tech_talent_trees + assert talent_data.key? :talent_trees + end + + def test_tech_talent_tree + talent_data = @talent.tech_talent_tree 272 + assert_equal 5, talent_data[:max_tiers] + end + end + end +end diff --git a/test/blizzard/wow/profile/character_test.rb b/test/blizzard/wow/profile/character_test.rb index d11481caaf737e0c5e2b1cc8420ed5b6e32293ad..f8c18269435b4cf957dcb68f5b85f2d5260f3865 100644 --- a/test/blizzard/wow/profile/character_test.rb +++ b/test/blizzard/wow/profile/character_test.rb @@ -26,7 +26,7 @@ module BlizzardApi def test_character_appearance character_data = @character.appearance 'Azralon', 'Schiller' - assert_equal 4, character_data[:appearance][:face_variation] + assert character_data.key? :customizations end def test_character_encounters @@ -52,7 +52,7 @@ module BlizzardApi def test_character_media character_data = @character.media 'Azralon', 'Schiller' - assert character_data.key? :avatar_url + assert character_data[:assets].map { |item| item[:key] }.include?('avatar') end def test_character_pvp_summary