GitLab's annual major release is around the corner, along with a lot of new and exciting features, there will be a few breaking changes, learn more here.

Commit f13e2849 authored by Francis's avatar Francis
Browse files

New and undocummented endpoints

parent bb8814bf
Pipeline #68728766 passed with stages
in 4 minutes and 19 seconds
Please view this file on the master branch, otherwise it may be outdated
**Version 0.2.3**
* Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20772337044
**Version 0.2.2**
* Added new api endpoints listed here: https://us.battle.net/forums/en/bnet/topic/20771546990
......
PATH
remote: .
specs:
blizzard_api (0.2.2)
blizzard_api (0.2.3)
redis (~> 4.1, >= 4.1.0)
GEM
......
......@@ -177,7 +177,18 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
- index
- get :id
- complete
* Blizzard::Wow::Title
- index
- get :id
* Blizzard::Wow::Item
- get :id
- item_set :id
- classes
- class :id
- subclass :class_id, :subclass_id
* Blizzard::Wow::AzeriteEssence
- index
- get :id
* Blizzard::Wow::Auction
- get :realm
......@@ -195,9 +206,6 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
- get :relam, :name, :fields
- rewards
- perks
* Blizzard::Wow::Item
- get :id
- item_set :setId
* Blizzard::Wow::PvP
- get :bracket
* Blizzard::Wow::Quest
......
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.2.2'
VERSION = '0.2.3'
end
......@@ -27,6 +27,9 @@ module BlizzardApi
require_relative 'wow/game_data/region'
require_relative 'wow/game_data/wow_token'
require_relative 'wow/game_data/race'
require_relative 'wow/game_data/title'
require_relative 'wow/game_data/item'
require_relative 'wow/game_data/azerite_essence'
##
# @return {Achievement}
......@@ -148,12 +151,29 @@ module BlizzardApi
BlizzardApi::Wow::Race.new
end
##
# @return {Title}
def self.title
BlizzardApi::Wow::Title.new
end
##
# @return {Item}
def self.item
BlizzardApi::Wow::Item.new
end
##
# @return {AzeriteEssence}
def self.azerite_essence
BlizzardApi::Wow::AzeriteEssence.new
end
# Wow community api
require_relative 'wow/community/auction'
require_relative 'wow/community/boss'
require_relative 'wow/community/challenge'
require_relative 'wow/community/character'
require_relative 'wow/community/item'
require_relative 'wow/community/pvp'
require_relative 'wow/community/quest'
require_relative 'wow/community/recipe'
......@@ -184,12 +204,6 @@ module BlizzardApi
BlizzardApi::Wow::Character.new
end
##
# @return {Item}
def self.item
BlizzardApi::Wow::Item.new
end
##
# @return {PvP}
def self.pvp
......
# 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 AzeriteEssence < Wow::GenericDataEndpoint
protected
def endpoint_setup
@endpoint = 'azerite-essence'
@namespace = endpoint_namespace :static
@collection = 'azerite_essences'
@ttl = CACHE_TRIMESTER
end
end
end
end
......@@ -9,15 +9,35 @@ module BlizzardApi
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.item
class Item < Wow::Request
class Item < Wow::GenericDataEndpoint
##
# This method overrides the inherited default behavior to prevent high server load and fetch time
#
# @!macro response
def index
raise BlizzardApi::ApiException, 'This endpoint does not have a index method'
end
##
# This method overrides the inherited default behavior to prevent high server load and fetch time
#
# @!macro response
def complete
raise BlizzardApi::ApiException, 'This endpoint does not have a complete method'
end
##
# Return complete data of an item by id
#
# @param id [Integer] Item id
# @!macro request_options
# @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
# instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @!macro response
def get(id, options = {})
return super id, options unless options.include? :use_community_endpoint
api_request "#{base_url(:community)}/item/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
end
......@@ -36,10 +56,48 @@ module BlizzardApi
# Return a list of item classes
#
# @!macro request_options
# @option options [Boolean] :use_community_endpoint If set to true, this method will call the community endpoint
# instead of the data endpoint https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @!macro response
def classes(options = {})
api_request "#{base_url(:community)}/data/item/classes", { ttl: CACHE_TRIMESTER }.merge(options)
if options.include? :use_community_endpoint
return api_request "#{base_url(:community)}/data/item/classes", { ttl: CACHE_TRIMESTER }.merge(options)
end
api_request "#{endpoint_uri('class')}/index", default_options.merge(options)
end
##
# Return data about an item class
#
# @param id [Integer] Item class id
# @!macro request_options
#
# @!macro response
def class(id, options = {})
api_request "#{endpoint_uri('class')}/#{id}", default_options.merge(options)
end
##
# Return all subclasses of a given class
#
# @param id [Integer] Item class id
# @param subclass_id [Integer] Item subclass id
# @!macro request_options
#
# @!macro response
def subclass(id, subclass_id, options = {})
api_request "#{endpoint_uri('class')}/#{id}/item-subclass/#{subclass_id}", default_options.merge(options)
end
protected
def endpoint_setup
@endpoint = 'item'
@namespace = endpoint_namespace :static
@collection = 'items'
@ttl = CACHE_TRIMESTER
end
end
end
......
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft titles
#
# @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.title
class Title < Wow::GenericDataEndpoint
##
# This method overrides the inherited default behavior to prevent high server load and fetch time
#
# @!macro response
def complete
raise BlizzardApi::ApiException, 'There are too many achievements to fetch complete data'
end
protected
def endpoint_setup
@endpoint = 'title'
@namespace = endpoint_namespace :static
@collection = 'titles'
@ttl = CACHE_TRIMESTER
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class AzeriteEssenceTest < Minitest::Test
def setup
@azerite_essence = BlizzardApi::Wow::AzeriteEssence.new
end
def test_azerite_essence_index
title_data = @azerite_essence.index
assert_equal 21, title_data[:azerite_essences].count
end
def test_azerite_essence_get
title_data = @azerite_essence.get 2
assert_equal 'Azeroth\'s Undying Gift', title_data[:name][:en_US]
end
end
end
end
......@@ -5,22 +5,39 @@ require 'test_helper'
module BlizzardApi
module Wow
class ItemTest < Minitest::Test
def setup
@item = BlizzardApi::Wow::Item.new
end
def test_item_get
item = BlizzardApi::Wow::Item.new
item_data = item.get 18_803
item_data = @item.get 35_000
assert_equal 'Brutal Gladiator\'s Dragonhide Legguards', item_data[:name][:en_US]
item_data = @item.get 18_803, use_community_endpoint: true
assert_equal 'inv_gizmo_02', item_data[:icon]
end
def test_item_set
item = BlizzardApi::Wow::Item.new
item_data = item.item_set 1060
item_data = @item.item_set 1060
assert_equal 76_749, item_data[:items][0]
end
def test_item_classes
item = BlizzardApi::Wow::Item.new
item_data = item.classes
assert item_data[:classes]
item_data = @item.classes
assert_equal 17, item_data[:item_classes].count
item_data = @item.classes use_community_endpoint: true
assert_equal 16, item_data[:classes].count
end
def test_item_class
item_data = @item.class 1
assert_equal 11, item_data[:item_subclasses].count
end
def test_subclass
item_data = @item.subclass 1, 1
assert_equal 'Soul Bag', item_data[:display_name][:en_US]
end
end
end
......
......@@ -4,7 +4,7 @@ require 'test_helper'
module BlizzardApi
module Wow
class PlayableClassTest < Minitest::Test
class PlayableSpecializationTest < Minitest::Test
def test_specialization_index
specs = BlizzardApi::Wow::PlayableSpecialization.new
specs_data = specs.index
......
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class TitleTest < Minitest::Test
def setup
@title = BlizzardApi::Wow::Title.new
end
def test_title_index
title_data = @title.index
assert_equal 365, title_data[:titles].count
end
def test_title_get
title_data = @title.get 10
assert_equal 'Lieutenant Commander', title_data[:name][:en_US]
end
end
end
end
......@@ -4,7 +4,7 @@ require 'test_helper'
module BlizzardApi
module Wow
class RegionTest < Minitest::Test
class WowTokenTest < Minitest::Test
def test_wow_token
token = BlizzardApi::Wow::WowToken.new
token_data = token.get
......
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