Commit 0e06046c authored by Francis's avatar Francis
Browse files

Removal of discontinued SC II api

parent 64d747d2
Pipeline #107655220 failed with stage
in 4 minutes and 44 seconds
---
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.3
before_install: gem install bundler -v 1.17.3
Please view this file on the master branch, otherwise it may be outdated
**Version 0.3.0**
https://us.forums.blizzard.com/en/blizzard/t/starcraft-ii-community-api-update/2652
Removed all Starcraft II related code.
**Version 0.2.9**
https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-update-collections-hunter-pets-and-reputations/757
* Added new character endpoints:
* reputations
......
PATH
remote: .
specs:
blizzard_api (0.2.9)
blizzard_api (0.3.0)
redis (~> 4.1, >= 4.1.0)
GEM
......
......@@ -15,8 +15,7 @@ This gem allow you to interface with the new blizzard api (2018) using the OAuth
4. [Available endpoints](#4-available-endpoints)
- 4.1. [World of Warcraft endpoints](#41-world-of-warcraft-endpoints)
- 4.2. [Diablo III endpoints](#42-diablo-iii-endpoints)
- 4.3. [Starcraft II endpoints](#43-starcraft-ii-endpoints)
- 4.4. [Hearthstone endpoints](#44-hearthstone-endpoints)
- 4.3. [Hearthstone endpoints](#43-hearthstone-endpoints)
## 1. Installation
......@@ -273,26 +272,8 @@ Most **data** endpoints will have always 3 methods available `index`, `get` and
- hero :battletag, :oauth_token, :hero_id
- hero_items :battletag, :oauth_token, :hero_id
- hero_follower_items :battletag, :oauth_token, :hero_id
### 4.3. Starcraft II endpoints
Every endpoint requiring a *region_id* parameter will accepts either the integer representation of the region described in the api docs or a symbol: `:US`, `:EU`, `:KO` or `:TW`
* BlizzardApi::Starcraft::League
- get :season_id, :queue_id, :team_type, :league_id
* BlizzardApi::Starcraft::Profile
- static :region_id
- metadata :region_id, :realm_id, :profile_id
- profile :region_id, :realm_id, :profile_id
- ladder_summary :region_id, :realm_id, :profile_id
- ladder :region_id, :realm_id, :profile_id, :ladder_id
* BlizzardApi::Starcraft::Ladder
- grandmaster :region_id, :options
- season :region_id
* BlizzardApi::Starcraft::Account
- player :account_id
### 4.4. Hearthstone endpoints
### 4.3. Hearthstone endpoints
* BlizzardApi::Hearthstone::Card
- index
......
......@@ -6,7 +6,6 @@ require_relative 'blizzard_api/exception'
require_relative 'blizzard_api/version'
require_relative 'blizzard_api/wow'
require_relative 'blizzard_api/diablo'
require_relative 'blizzard_api/starcraft'
require_relative 'blizzard_api/hearthstone'
# Blizzard namespace
......
# frozen_string_literal: true
module BlizzardApi
# Starcraft II related classes
module Starcraft
require_relative 'starcraft/request'
# Starcraft II data api
require_relative 'starcraft/game_data/league'
##
# @return {League}
def league
BlizzardApi::Starcraft::League.new
end
# Starcraft community api
require_relative 'starcraft/community/profile'
require_relative 'starcraft/community/ladder'
require_relative 'starcraft/community/account'
##
# @return {Profile}
def profile
BlizzardApi::Starcraft::Profile.new
end
##
# @return {Ladder}
def ladder
BlizzardApi::Starcraft::Ladder.new
end
##
# @return {Account}
def account
BlizzardApi::Starcraft::Account.new
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Starcraft
##
# This class allows access to Starcraft II league data
#
# @see https://develop.battle.net/documentation/api-reference/starcraft-2-game-data-api
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Starcraft.account
class Account < Starcraft::Request
##
# Returns information about a player account
#
# @param [Integer] account_id Account ID
# @!macro request_options
def player(account_id, options = {})
api_request "#{base_url(:community)}/player/#{account_id}", { ttl: CACHE_DAY }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Starcraft
##
# This class allows access to Starcraft II ladder data
#
# @see https://develop.battle.net/documentation/api-reference/starcraft-2-game-data-api
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Starcraft.ladder
class Ladder < Starcraft::Request
##
# Grandmaster endpoint
#
# @!macro sc2_regions
# @!macro request_options
def grandmaster(region_id, options = {})
reg = resolve_region(region_id)
api_request "#{base_url(:community)}/ladder/grandmaster/#{reg}", { ttl: CACHE_DAY }.merge(options)
end
##
# Season endpoint
#
# @!macro sc2_regions
# @!macro request_options
def season(region_id, options = {})
reg = resolve_region(region_id)
api_request "#{base_url(:community)}/ladder/season/#{reg}", { ttl: CACHE_DAY }.merge(options)
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Starcraft
##
# This class allows access to Starcraft II profile data
#
# @see https://develop.battle.net/documentation/api-reference/starcraft-2-game-data-api
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Starcraft.profile
class Profile < Starcraft::Request
##
# Static profile data
#
# @!macro sc2_regions
# @!macro request_options
def static(region_id, options = {})
reg = resolve_region(region_id)
api_request "#{base_url(:community)}/static/profile/#{reg}", { ttl: CACHE_DAY }.merge(options)
end
##
# Metadata
#
# @!macro sc2_regions
# @param [Integer] realm_id Realm ID
# @param [Integer] profile_id Profile ID
# @!macro request_options
def metadata(region_id, realm_id, profile_id, options = {})
reg = resolve_region(region_id)
opts = { ttl: CACHE_DAY }.merge(options)
api_request "#{base_url(:community)}/metadata/profile/#{reg}/#{realm_id}/#{profile_id}", opts
end
##
# Profile data
#
# @!macro sc2_regions
# @param [Integer] realm_id Realm ID
# @param [Integer] profile_id Profile ID
# @!macro request_options
def profile(region_id, realm_id, profile_id, options = {})
reg = resolve_region(region_id)
opts = { ttl: CACHE_DAY }.merge(options)
api_request "#{base_url(:community)}/profile/#{reg}/#{realm_id}/#{profile_id}", opts
end
##
# Ladder summary
#
# @!macro sc2_regions
# @param [Integer] realm_id Realm ID
# @param [Integer] profile_id Profile ID
# @!macro request_options
def ladder_summary(region_id, realm_id, profile_id, options = {})
reg = resolve_region(region_id)
opts = { ttl: CACHE_DAY }.merge(options)
api_request "#{base_url(:community)}profile/#{reg}/#{realm_id}/#{profile_id}/ladder/summary ", opts
end
##
# Ladder data
#
# @!macro sc2_regions
# @param [Integer] realm_id Realm ID
# @param [Integer] profile_id Profile ID
# @!macro request_options
def ladder(region_id, realm_id, profile_id, ladder_id, options = {})
reg = resolve_region(region_id)
opts = { ttl: CACHE_DAY }.merge(options)
api_request "#{base_url(:community)}/profile/#{reg}/#{realm_id}/#{profile_id}/ladder/#{ladder_id}", opts
end
end
end
end
# frozen_string_literal: true
module BlizzardApi
module Starcraft
##
# This class allows access to Starcraft II league data
#
# @see https://develop.battle.net/documentation/api-reference/starcraft-2-game-data-api
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Starcraft.league
class League < Starcraft::Request
##
# Return information about league
#
# @param [Integer] season_id Season id
# @param [Integer] queue_id Queue id
# @param [Integer] team_type Team type
# @param [Integer] league_id League id
# @!macro request_options
def get(season_id, queue_id, team_type, league_id, options = {})
opts = { ttl: CACHE_DAY }.merge(options)
api_request "#{base_url(:game_data)}/league/#{season_id}/#{queue_id}/#{team_type}/#{league_id}", opts
end
end
end
end
# frozen_string_literal: true
##
# @!macro [new] sc2_regions
# @param {Symbol} region_id One of the valid Starcraft II regions *:US*, *:EU*, *:KO*, and *:TW*
# @note This gem do not support nor will support China endpoints
module BlizzardApi
module Starcraft
##
# Starcraft requests
class Request < BlizzardApi::Request
# Possible regions for the SC II API (Except China)
SC_REGION = { US: 1, EU: 2, KO: 3, TW: 3 }.freeze
##
# @!macro regions
def initialize(region = nil)
super region
@game = 'sc2'
end
private
##
# Helper method to find a region_id by its symbol
def resolve_region(region_arg)
return region_arg if region_arg.is_a? Integer
return SC_REGION[region_arg] if region_arg.is_a? Symbol
raise ArgumentError, 'Invalid region, please read the documentation'
end
end
end
end
......@@ -2,5 +2,5 @@
module BlizzardApi
# Gem version
VERSION = '0.2.9'
VERSION = '0.3.0'
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Starcraft
class LadderTest < Minitest::Test
def test_ladder_grandmaster
ladder = BlizzardApi::Starcraft::Ladder.new
ladder_data = ladder.grandmaster :US
assert ladder_data[:ladderTeams]
end
def test_ladder_season
ladder = BlizzardApi::Starcraft::Ladder.new
ladder_data = ladder.season :US
assert ladder_data[:year]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Starcraft
class ProfileTest < Minitest::Test
def test_profile_static
profile = BlizzardApi::Starcraft::Profile.new
profile_data = profile.static :US
assert profile_data[:achievements]
end
end
end
end
# frozen_string_literal: true
require 'test_helper'
module BlizzardApi
module Starcraft
class LeagueTest < Minitest::Test
def test_league_get
league = BlizzardApi::Starcraft::League.new
league_data = league.get 37, 201, 0, 6
assert league_data[:tier]
end
end
end
end
......@@ -8,7 +8,7 @@ module BlizzardApi
def test_achievement_index
achievement = BlizzardApi::Wow::Achievement.new
achievement_data = achievement.index
assert_equal 5033, achievement_data[:achievements].count
assert_equal 5034, achievement_data[:achievements].count
end
def test_achievement_get
......
......@@ -6,65 +6,65 @@ module BlizzardApi
module Wow
class CreatureTest < Minitest::Test
def setup
@mythic_keystone_leaderboard = BlizzardApi::Wow::Creature.new
@creature = BlizzardApi::Wow::Creature.new
end
def test_creature_get
creature_data = @mythic_keystone_leaderboard.get 42_722
creature_data = @creature.get 42_722
assert_equal 'Young Mastiff', creature_data[:name][:en_US]
creature_data = @mythic_keystone_leaderboard.get 107, classic: true
creature_data = @creature.get 107, classic: true
assert_equal 'Raptor', creature_data[:name][:en_US]
end
def test_creature_families
creature_families_data = @mythic_keystone_leaderboard.families
creature_families_data = @creature.families
assert_equal 78, creature_families_data[:creature_families].count
creature_families_data = @mythic_keystone_leaderboard.families classic: true
creature_families_data = @creature.families classic: true
assert_equal 23, creature_families_data[:creature_families].count
end
def test_creature_family
creature_family_data = @mythic_keystone_leaderboard.family 1
creature_family_data = @creature.family 1
assert_equal 'Wolf', creature_family_data[:name][:en_US]
creature_family_data = @mythic_keystone_leaderboard.family 1, classic: true
creature_family_data = @creature.family 1, classic: true
assert_equal 'Wolf', creature_family_data[:name][:en_US]
end
def test_creature_family_media
creature_family_media_data = @mythic_keystone_leaderboard.family_media 1
creature_family_media_data = @creature.family_media 1
assert_equal 'https://render-us.worldofwarcraft.com/icons/56/ability_hunter_pet_wolf.jpg',
creature_family_media_data[:assets][0][:value]
creature_family_media_data = @mythic_keystone_leaderboard.family_media 1, classic: true
creature_family_media_data = @creature.family_media 1, classic: true
assert_equal 'https://render-classic-us.worldofwarcraft.com/icons/56/ability_hunter_pet_wolf.jpg',
creature_family_media_data[:assets][0][:value]
end
def test_creature_types
creature_types_data = @mythic_keystone_leaderboard.types
creature_types_data = @creature.types
assert_equal 15, creature_types_data[:creature_types].count
creature_types_data = @mythic_keystone_leaderboard.types classic: true
creature_types_data = @creature.types classic: true
assert_equal 11, creature_types_data[:creature_types].count
end
def test_creature_type
creature_type_data = @mythic_keystone_leaderboard.type 1
creature_type_data = @creature.type 1
assert_equal 'Beast', creature_type_data[:name][:en_US]
creature_type_data = @mythic_keystone_leaderboard.type 1, classic: true
creature_type_data = @creature.type 1, classic: true
assert_equal 'Beast', creature_type_data[:name][:en_US]
end
def test_creature_display_media
creature_display_media_data = @mythic_keystone_leaderboard.display_media 30_221
creature_display_media_data = @creature.display_media 30_221
assert_equal 'https://render-us.worldofwarcraft.com/npcs/portrait/creature-display-30221.jpg',
creature_display_media_data[:assets][0][:value]
creature_display_media_data = @mythic_keystone_leaderboard.display_media 180, classic: true
creature_display_media_data = @creature.display_media 180, classic: true
assert_equal 'https://render-classic-us.worldofwarcraft.com/npcs/portrait/creature-display-180.jpg',
creature_display_media_data[:assets][0][:value]
end
......
......@@ -11,7 +11,7 @@ module BlizzardApi
def test_mount_index
mount_data = @mount.index
assert_equal 777, mount_data[:mounts].count
assert_equal 778, mount_data[:mounts].count
mount_data = @mount.index use_community_endpoint: true
assert_equal 930, mount_data[:mounts].count
......
......@@ -27,7 +27,7 @@ module BlizzardApi
def test_mythic_keystone_periods
mythic_keystone_periods = @mythic_keystone_leaderboard.periods
assert_equal 78, mythic_keystone_periods[:periods].count
assert_equal 89, mythic_keystone_periods[:periods].count
end
def test_mythic_keystone_period
......
......@@ -11,7 +11,7 @@ module BlizzardApi
def test_pet_index
pet_data = @pet.index
assert_equal 1244, pet_data[:pets].count
assert_equal 1248, pet_data[:pets].count
pet_data = @pet.index use_community_endpoint: true
assert_equal 1244, pet_data[:pets].count
......
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