From a2aadbb12c56e9fa41eb8cc62ae8b51b0e982574 Mon Sep 17 00:00:00 2001 From: Francis Schiavo Date: Tue, 17 Nov 2020 23:13:52 -0300 Subject: [PATCH] Shadowlands covenant endpoints --- CHANGELOG.md | 4 + lib/blizzard_api/version.rb | 2 +- lib/blizzard_api/wow.rb | 16 ++++ lib/blizzard_api/wow/game_data/covenant.rb | 79 +++++++++++++++++++ lib/blizzard_api/wow/game_data/tech_talent.rb | 57 +++++++++++++ .../wow/profile/character_profile.rb | 14 ++++ .../wow/game_data/achievement_test.rb | 2 +- test/blizzard/wow/game_data/covenant_test.rb | 48 +++++++++++ test/blizzard/wow/game_data/pets_test.rb | 4 +- .../blizzard/wow/game_data/reputation_test.rb | 2 +- test/blizzard/wow/game_data/talent_test.rb | 4 +- .../wow/game_data/tech_talent_test.rb | 38 +++++++++ test/blizzard/wow/profile/character_test.rb | 4 +- 13 files changed, 265 insertions(+), 9 deletions(-) create mode 100644 lib/blizzard_api/wow/game_data/covenant.rb create mode 100644 lib/blizzard_api/wow/game_data/tech_talent.rb create mode 100644 test/blizzard/wow/game_data/covenant_test.rb create mode 100644 test/blizzard/wow/game_data/tech_talent_test.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 582add2..ec2aa12 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 d91e847..df9b29f 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 62cabb3..23cbf21 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 0000000..56cc345 --- /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 0000000..44ee09e --- /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 7319c47..c014a50 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 753e0cf..1f0b22c 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 0000000..a2021ce --- /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 bb9df2d..5b6aa50 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 d4b36a5..7538d44 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 03a8442..d1be5b0 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 0000000..f257395 --- /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 d11481c..f8c1826 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 -- GitLab