Commit ab098955 authored by Francis's avatar Francis
Browse files

New retail and classic endpoints for WoW

parent aabf8403
Pipeline #154589941 passed with stage
in 5 minutes and 17 seconds
Please view this file on the master branch, otherwise it may be outdated
**Version 0.4.1**
Added new retail and classic endpoints described here: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-patch-notes-20200609/8902
**Version 0.4.0**
Added support to searchable endpoints
......
......@@ -88,7 +88,7 @@ module BlizzardApi
def endpoint_namespace(options)
case options[:namespace]
when :dynamic
"dynamic-#{region}"
options.include?(:classic) ? "dynamic-classic-#{region}" : "dynamic-#{region}"
when :static
options.include?(:classic) ? "static-classic-#{region}" : "static-#{region}"
when :profile
......
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.4.0'
VERSION = '0.4.1'
end
......@@ -10,6 +10,52 @@ module BlizzardApi
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.pet
class Pet < Wow::GenericDataEndpoint
##
# Fetch media for one of the pets listed by the {#index} using its *id*
#
# @param id [Integer] Pet id
#
# @!macro request_options
#
# @!macro response
def media(id, options = {})
api_request "#{base_url(:media)}/pet/#{id}", default_options.merge(options)
end
##
# Fetch all pet abilities
#
# @!macro request_options
#
# @!macro response
def abilities(options = {})
api_request "#{endpoint_uri('ability')}/index", default_options.merge(options)
end
##
# Fetch a pet ability
#
# @param id [Integer] Pet id
#
# @!macro request_options
#
# @!macro response
def ability(id, options = {})
api_request "#{endpoint_uri('ability')}/#{id}", default_options.merge(options)
end
##
# Fetch media for one of the pet abilities listed by the {#abilities} using its *id*
#
# @param id [Integer] Pet ability id
#
# @!macro request_options
#
# @!macro response
def ability_media(id, options = {})
api_request "#{base_url(:media)}/pet-ability/#{id}", default_options.merge(options)
end
protected
def endpoint_setup
......
......@@ -18,6 +18,26 @@ module BlizzardApi
pet_data = @pet.get 39
assert_equal 'Mechanical Squirrel', pet_data[:name][:en_US]
end
def test_pet_media
pet_data = @pet.media 39
assert_equal 'https://render-us.worldofwarcraft.com/icons/56/inv_pet_mechanicalsquirrel.jpg', pet_data[:assets][0][:value]
end
def test_pet_ability_index
pet_data = @pet.abilities
assert_equal 656, pet_data[:abilities].count
end
def test_pet_ability_get
pet_data = @pet.ability 110
assert_equal 'Bite', pet_data[:name][:en_US]
end
def test_pet_ability_media
pet_data = @pet.ability_media 110
assert_equal 'https://render-us.worldofwarcraft.com/icons/56/ability_druid_ferociousbite.jpg', pet_data[:assets][0][:value]
end
end
end
end
......@@ -12,16 +12,25 @@ module BlizzardApi
def test_realm_index
realm_data = @realm.index
assert realm_data[:realms]
realm_data = @realm.index classic: true
assert realm_data[:realms]
end
def test_realm_get
realm_data = @realm.get 'azralon'
assert_equal 'azralon', realm_data[:slug]
realm_data = @realm.get 'atiesh', classic: true
assert_equal 'atiesh', realm_data[:slug]
end
def test_realm_complete
realm_data = @realm.complete
assert_equal 'lightbringer', realm_data[0][:slug]
realm_data = @realm.complete classic: true
assert_equal 'atiesh', realm_data[0][:slug]
end
def test_realm_search
......@@ -29,6 +38,11 @@ module BlizzardApi
options.where 'name.en_US', %w[Azralon Nemesis]
end
assert_equal 2, realm_data[:results].size
realm_data = @realm.search(1, 100, classic: true) do |options|
options.where 'name.en_US', %w[Mankrik Pagle]
end
assert_equal 2, realm_data[:results].size
end
end
end
......
......@@ -5,22 +5,32 @@ require 'test_helper'
module BlizzardApi
module Wow
class RegionTest < Minitest::Test
def setup
@region = BlizzardApi::Wow.region
end
def test_region_index
region = BlizzardApi::Wow.region
region_data = region.index
region_data = @region.index
assert_equal 1, region_data[:regions].count
region_data = @region.index classic: true
assert_equal 1, region_data[:regions].count
end
def test_region_get
region = BlizzardApi::Wow::Region.new
region_data = region.get 1
region_data = @region.get 1
assert_equal 'US', region_data[:tag]
region_data = @region.get 41, classic: true
assert_equal 'US', region_data[:tag]
end
def test_region_complete
region = BlizzardApi::Wow::Region.new
region_data = region.complete
region_data = @region.complete
assert_equal 'North America', region_data[0][:name][:en_US]
region_data = @region.complete classic: true
assert_equal 'Classic North America', region_data[0][:name][:en_US]
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