Commit 28ce3e28 authored by Francis's avatar Francis
Browse files

Added profession endpoints

parent 84eb83c2
Pipeline #136998433 passed with stage
in 5 minutes and 9 seconds
Please view this file on the master branch, otherwise it may be outdated
**Version 0.3.8**
Added new profession endpoints.
https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200414/5680
**Version 0.3.7**
Automated test improvements
......
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.3.7'
VERSION = '0.3.8'
end
......@@ -25,6 +25,7 @@ module BlizzardApi
require_relative 'wow/game_data/playable_race'
require_relative 'wow/game_data/playable_specialization'
require_relative 'wow/game_data/power_type'
require_relative 'wow/game_data/profession'
require_relative 'wow/game_data/pvp_season'
require_relative 'wow/game_data/pvp_tier'
require_relative 'wow/game_data/quest'
......@@ -162,6 +163,13 @@ module BlizzardApi
BlizzardApi::Wow::PowerType.new(region)
end
##
# @param region [String] API Region
# @return {Profession}
def self.profession(region = BlizzardApi.region)
BlizzardApi::Wow::Profession.new(region)
end
##
# @param region [String] API Region
# @return {PvpSeason}
......
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft professions
#
# @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.profession
class Profession < Wow::GenericDataEndpoint
##
# Fetch media for a profession using its *id*
#
# @param id [Integer] Profession id
#
# @!macro request_options
#
# @!macro response
def media(id, options = {})
api_request "#{base_url(:media)}/profession/#{id}", default_options.merge(options)
end
##
# Fetch skill tier for a profession using its *ids*
#
# @param id [Integer] Profession id
# @param tier_id [Integer] Profession skill tier id
#
# @!macro request_options
#
# @!macro response
def skill_tier(id, tier_id, options = {})
api_request "#{base_url(:game_data)}/profession/#{id}/skill-tier/#{tier_id}", default_options.merge(options)
end
##
# Fetch data for a recipe using its *ids*
#
# @param id [Integer] Recipe id
#
# @!macro request_options
#
# @!macro response
def recipe(id, options = {})
api_request "#{base_url(:game_data)}/recipe/#{id}", default_options.merge(options)
end
##
# Fetch media for a recipe using its *ids*
#
# @param id [Integer] Recipe id
#
# @!macro request_options
#
# @!macro response
def recipe_media(id, options = {})
api_request "#{base_url(:media)}/recipe/#{id}", default_options.merge(options)
end
protected
def endpoint_setup
@endpoint = 'profession'
@namespace = :static
@collection = 'professions'
@ttl = CACHE_TRIMESTER
end
end
end
end
......@@ -221,6 +221,20 @@ module BlizzardApi
character_request realm, character, options, "mythic-keystone-profile/season/#{season}"
end
##
# Return professions from a character
#
# @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 professions(realm, character, options = {})
character_request realm, character, options, 'professions'
end
##
# Return character status
#
......
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class ProfessionTest < Minitest::Test
def setup
@profession = BlizzardApi::Wow.profession
end
def test_profession_index
profession_data = @profession.index
assert_equal 14, profession_data[:professions].count
end
def test_profession_get
profession_data = @profession.get 164
assert_equal 'Blacksmithing', profession_data[:name][:en_US]
end
def test_profession_media
profession_data = @profession.media 164
assert_equal 'https://render-us.worldofwarcraft.com/icons/56/trade_blacksmithing.jpg', profession_data[:assets][0][:value]
end
def test_profession_tier
profession_data = @profession.skill_tier 164, 2477
assert_equal 300, profession_data[:maximum_skill_level]
end
def test_recipe
recipe_data = @profession.recipe 1631
assert_equal 'Rough Sharpening Stone', recipe_data[:name][:en_US]
end
def test_recipe_media
recipe_data = @profession.recipe_media 1631
assert_equal 'https://render-us.worldofwarcraft.com/icons/56/inv_stone_sharpeningstone_01.jpg', recipe_data[:assets][0][:value]
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment