Commit da709909 authored by Francis's avatar Francis
Browse files

Removing old community endpoints

parent 064e61ee
Pipeline #128325358 passed with stage
in 5 minutes and 12 seconds
Please view this file on the master branch, otherwise it may be outdated
**Version 0.3.5**
Fixed a bug for generating slugs for Korean
Removed deprecated WoW community endpoints.
**Version 0.3.4**
Fixed account endpoints
......
PATH
remote: .
specs:
blizzard_api (0.3.4)
blizzard_api (0.3.5)
redis (~> 4.1, >= 4.1.0)
GEM
......
......@@ -99,7 +99,7 @@ module BlizzardApi
end
def string_to_slug(string)
string.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')
CGI.escape(string.downcase.tr(' ', '-'))
end
def create_access_token
......
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.3.4'
VERSION = '0.3.5'
end
......@@ -204,13 +204,6 @@ module BlizzardApi
BlizzardApi::Wow::WowToken.new
end
# Wow community api
require_relative 'wow/community/boss'
require_relative 'wow/community/challenge'
require_relative 'wow/community/pvp'
require_relative 'wow/community/recipe'
require_relative 'wow/community/zone'
##
# @return {Boss}
def self.boss
......
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft bosses
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @deprecated See https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.boss
class Boss < Wow::Request
##
# Return a list of every World of Warcraft boss currently in game
#
# @!macro request_options
#
# @!macro response
def index(options = {})
api_request "#{base_url(:community)}/boss/", { ttl: CACHE_TRIMESTER }.merge(options)
end
##
# Return detailed information about a boss by its ID
#
# @param id [Integer] Boss id
# @!macro request_options
#
# @!macro response
def get(id, options = {})
api_request "#{base_url(:community)}/boss/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft challenges
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @deprecated See https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.challenge
class Challenge < Wow::Request
##
# Most recent challenge leaderboard for the specified realm
#
# @param name [String] Realm's slug
# @!macro request_options
#
# @!macro response
def realm_index(name, options = {})
api_request "#{base_url(:community)}/challenge/#{name}", { ttl: CACHE_HOUR }.merge(options)
end
##
# Most recent challenge leaderboard for the entire region
#
# @!macro request_options
#
# @!macro response
def region_index(options = {})
api_request "#{base_url(:community)}/challenge/region", { ttl: CACHE_HOUR }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft PvP data
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @deprecated See https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.pvp
class PvP < Wow::Request
# Arena 2v2
BRACKET_2V2 = '2v2'
# Arena 3x3
BRACKET_3V3 = '3v3'
# Arena 5x5
BRACKET_5V5 = '5v5'
# Rated battlegrounds
BRACKET_RBG = 'rbg'
##
# Returns the current pvp leaderboard for the current region
#
# @param bracket [String] PvP leaderboard category. You can use the constants BRACKET_*
# @!macro request_options
#
# @!macro response
def get(bracket, options = {})
api_request "#{base_url(:community)}/leaderboard/#{bracket}", { ttl: CACHE_DAY }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft recipe data
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @deprecated See https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.recipe
class Recipe < Wow::Request
##
# Return information about a recipe by its id
#
# @param id [Integer] Recipe id
# @!macro request_options
#
# @!macro response
def get(id, options = {})
api_request "#{base_url(:community)}/recipe/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Wow
##
# This class allows access to World of Warcraft zone data
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @deprecated See https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-community-api-migration/767
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.zone
class Zone < Wow::Request
##
# Return a list of all zones
#
# @!macro request_options
#
# @!macro response
def index(options = {})
api_request "#{base_url(:community)}/zone/", { ttl: CACHE_TRIMESTER }.merge(options)
end
##
# Return complete information about a zone by its id
#
# @param id [Integer] Zone id
# @!macro request_options
#
# @!macro response
def get(id, options = {})
api_request "#{base_url(:community)}/zone/#{id}", { ttl: CACHE_TRIMESTER }.merge(options)
end
end
end
end
......@@ -5,7 +5,7 @@ module BlizzardApi
##
# This class allows access to World of Warcraft pet data
#
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
# @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.pet
......
......@@ -10,19 +10,6 @@ module BlizzardApi
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.realm
class Realm < Wow::GenericDataEndpoint
##
# This method is actually located at the community scope, but included here because of its relevance
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @param realms [Array<String>] An optional list of realm-slugs to filter results
# @!macro request_options
#
# @!macro response
def status(realms = [], options = {})
options[:realms] = realms.map(&:string_to_slug).join(',') if realms.count.positive?
api_request "#{base_url(:community)}/realm/status", { ttl: CACHE_MINUTE }.merge(options)
end
protected
def endpoint_setup
......
......@@ -10,19 +10,6 @@ module BlizzardApi
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.region
class Region < Wow::GenericDataEndpoint
##
# Returns data about region battlegroups
#
# This method is actually located at the community API, but it is included here due to its relevance.
# @see https://develop.battle.net/documentation/api-reference/world-of-warcraft-community-api
#
# @!macro request_options
#
# @!macro response
def battlegroups(options = {})
api_request "#{base_url(:community)}/data/battlegroups/", { ttl: CACHE_TRIMESTER }.merge(options)
end
protected
def endpoint_setup
......
......@@ -10,21 +10,6 @@ module BlizzardApi
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.achievement
class CharacterProfile < Wow::Request
##
# Return a list containing all WoW characters of a BNet account
#
# @note This endpoint requires a user token obtained through the user authorization flow
# @see https://develop.battle.net/documentation/guides/using-oauth/authorization-code-flow
#
# @param user_token [String] A token obtained by the authorization flow. See link below.
# @!macro request_options
#
# @!macro response
def get_user_characters(user_token, options = {})
opts = { ttl: CACHE_HOUR, access_token: user_token }.merge(options)
api_request "#{base_url(:community)}/user/characters", opts
end
##
# Return character achievements
#
......@@ -361,7 +346,7 @@ module BlizzardApi
end
def character_request(realm, character, options = {}, variant = nil)
uri = "#{base_url(:profile)}/character/#{CGI.escape(realm.downcase)}/#{CGI.escape(character.downcase)}"
uri = "#{base_url(:profile)}/character/#{string_to_slug(realm)}/#{string_to_slug(character)}"
uri += "/#{variant}" if variant
api_request uri, default_options.merge(options)
end
......
......@@ -10,26 +10,6 @@ module BlizzardApi
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Wow.guild
class Guild < Wow::Request
##
# Return a list with all possible rewards.
#
# @!macro request_options
#
# @!macro response
def rewards(options = {})
api_request "#{base_url(:community)}/data/guild/rewards", { ttl: CACHE_TRIMESTER }.merge(options)
end
##
# Return a list with all possible perks
#
# @!macro request_options
#
# @!macro response
def perks(options = {})
api_request "#{base_url(:community)}/data/guild/perks", { ttl: CACHE_TRIMESTER }.merge(options)
end
##
# Return data about the specified guild
#
......@@ -82,8 +62,8 @@ module BlizzardApi
private
def guild_request(realm, guild, options = {}, variant = nil)
realm = CGI.escape string_to_slug(realm)
guild = CGI.escape string_to_slug(guild)
realm = string_to_slug(realm)
guild = string_to_slug(guild)
url = "#{base_url(:game_data)}/guild/#{realm}/#{guild}"
url += "/#{variant}" if variant
api_request url, { ttl: CACHE_DAY, namespace: :profile }.merge(options)
......
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class BossTest < Minitest::Test
def test_boss_index
boss = BlizzardApi::Wow::Boss.new
boss_data = boss.index
assert_equal 46_962, boss_data[:bosses][0][:id]
end
def test_boss_get
boss = BlizzardApi::Wow::Boss.new
boss_data = boss.get 24_723
assert_equal 'selin-fireheart', boss_data[:urlSlug]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class ChallengeTest < Minitest::Test
def test_challenge_realm
challenge = BlizzardApi::Wow::Challenge.new
realm_data = challenge.realm_index 'medivh'
assert realm_data[:challenge]
end
def test_challenge_region
challenge = BlizzardApi::Wow::Challenge.new
region_data = challenge.region_index
assert region_data[:challenge]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class PvPTest < Minitest::Test
def test_pvp_index
pvp = BlizzardApi::Wow::PvP.new
pvp_data = pvp.get '2v2'
assert pvp_data[:rows]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class RecipeTest < Minitest::Test
def test_recipe_get
recipe = BlizzardApi::Wow::Recipe.new
recipe_data = recipe.get 33_994
assert_equal 'spell_holy_greaterheal', recipe_data[:icon]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Wow
class ZoneTest < Minitest::Test
def test_zone_index
zone = BlizzardApi::Wow::Zone.new
zone_data = zone.index
assert zone_data[:zones]
end
def test_zone_get
zone = BlizzardApi::Wow::Zone.new
zone_data = zone.get 4131
assert_equal 'magisters-terrace', zone_data[:urlSlug]
end
end
end
end
......@@ -22,12 +22,6 @@ module BlizzardApi
region_data = region.complete
assert_equal 'North America', region_data[0][:name][:en_US]
end
def test_battlegroups
region = BlizzardApi::Wow::Region.new
region_data = region.battlegroups
assert region_data[:battlegroups]
end
end
end
end
......@@ -9,16 +9,6 @@ module BlizzardApi
@guild = BlizzardApi::Wow::Guild.new
end
def test_guild_rewards
guild_data = @guild.rewards
assert guild_data[:rewards]
end
def test_guild_perks
guild_data = @guild.perks
assert guild_data[:perks]
end
def test_guild_get
guild_data = @guild.get 'Azralon', 'Mitocracia'
assert_equal 'Mitocracia', guild_data[:name]
......
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