Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Francis
Blizzard api
Commits
186f7dfe
Commit
186f7dfe
authored
Jan 17, 2020
by
Francis
Browse files
Hearthstone update
parent
a919ac03
Pipeline
#110334354
passed with stage
in 4 minutes and 42 seconds
Changes
22
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
142 additions
and
24 deletions
+142
-24
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
CHANGELOG.md
CHANGELOG.md
+9
-0
Gemfile.lock
Gemfile.lock
+3
-3
lib/blizzard_api/hearthstone.rb
lib/blizzard_api/hearthstone.rb
+7
-0
lib/blizzard_api/hearthstone/game_data/back.rb
lib/blizzard_api/hearthstone/game_data/back.rb
+59
-0
lib/blizzard_api/hearthstone/game_data/card.rb
lib/blizzard_api/hearthstone/game_data/card.rb
+20
-0
lib/blizzard_api/hearthstone/game_data/deck.rb
lib/blizzard_api/hearthstone/game_data/deck.rb
+1
-0
lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb
...izzard_api/hearthstone/game_data/generic_data_endpoint.rb
+1
-1
lib/blizzard_api/hearthstone/game_data/metadata.rb
lib/blizzard_api/hearthstone/game_data/metadata.rb
+1
-0
lib/blizzard_api/version.rb
lib/blizzard_api/version.rb
+1
-1
test/blizzard/hearthstone/game_data/back_test.rb
test/blizzard/hearthstone/game_data/back_test.rb
+21
-0
test/blizzard/wow/game_data/achievement_test.rb
test/blizzard/wow/game_data/achievement_test.rb
+3
-3
test/blizzard/wow/game_data/azerite_essence_test.rb
test/blizzard/wow/game_data/azerite_essence_test.rb
+1
-1
test/blizzard/wow/game_data/creature_test.rb
test/blizzard/wow/game_data/creature_test.rb
+1
-1
test/blizzard/wow/game_data/guild_crest_test.rb
test/blizzard/wow/game_data/guild_crest_test.rb
+2
-2
test/blizzard/wow/game_data/mount_test.rb
test/blizzard/wow/game_data/mount_test.rb
+2
-2
test/blizzard/wow/game_data/mythic_keystone_leaderboard_test.rb
...lizzard/wow/game_data/mythic_keystone_leaderboard_test.rb
+1
-1
test/blizzard/wow/game_data/mythic_keystone_test.rb
test/blizzard/wow/game_data/mythic_keystone_test.rb
+2
-2
test/blizzard/wow/game_data/pets_test.rb
test/blizzard/wow/game_data/pets_test.rb
+2
-2
test/blizzard/wow/game_data/race_test.rb
test/blizzard/wow/game_data/race_test.rb
+2
-2
test/blizzard/wow/game_data/reputation_faction_test.rb
test/blizzard/wow/game_data/reputation_faction_test.rb
+1
-1
test/blizzard/wow/game_data/title_test.rb
test/blizzard/wow/game_data/title_test.rb
+1
-1
No files found.
.gitlab-ci.yml
View file @
186f7dfe
...
...
@@ -6,7 +6,7 @@ stages:
test
:
stage
:
test
script
:
-
gem install bundler -v
1
.1
7.3
-
gem install bundler -v
2
.1
.2
-
bundle install
-
rubocop
-
rake
\ No newline at end of file
CHANGELOG.md
View file @
186f7dfe
Please view this file on the master branch, otherwise it may be outdated
**Version 0.3.1**
https://us.forums.blizzard.com/en/blizzard/t/hearthstone-api-updates/2978
Hearthstone updates:
*
Added the new Cardback endpoint
*
Card endpoint now supports the new
`gameMode`
search option
**Version 0.3.0**
https://us.forums.blizzard.com/en/blizzard/t/starcraft-ii-community-api-update/2652
...
...
Gemfile.lock
View file @
186f7dfe
PATH
remote: .
specs:
blizzard_api (0.3.
0
)
blizzard_api (0.3.
1
)
redis (~> 4.1, >= 4.1.0)
GEM
...
...
@@ -15,7 +15,7 @@ GEM
ast (~> 2.4.0)
rainbow (3.0.0)
rake (10.5.0)
redis (4.1.
2
)
redis (4.1.
3
)
rubocop (0.74.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
...
...
@@ -36,4 +36,4 @@ DEPENDENCIES
rubocop (~> 0.61)
BUNDLED WITH
1
.1
7.3
2
.1
.2
lib/blizzard_api/hearthstone.rb
View file @
186f7dfe
...
...
@@ -8,6 +8,7 @@ module BlizzardApi
# Hearthstone data api
require_relative
'hearthstone/game_data/card'
require_relative
'hearthstone/game_data/back'
require_relative
'hearthstone/game_data/deck'
require_relative
'hearthstone/game_data/metadata'
...
...
@@ -17,6 +18,12 @@ module BlizzardApi
BlizzardApi
::
Hearthstone
::
Card
.
new
end
##
# @return {Back}
def
self
.
back
BlizzardApi
::
Hearthstone
::
Back
.
new
end
##
# @return {Deck}
def
self
.
deck
...
...
lib/blizzard_api/hearthstone/game_data/back.rb
0 → 100644
View file @
186f7dfe
# frozen_string_literal: true
module
BlizzardApi
module
Hearthstone
##
# This class allows access to Hearthstone card data
#
# @see https://develop.battle.net/documentation/api-reference/hearthstone-game-data-api
# @see https://develop.battle.net/documentation/hearthstone/guides/card-backs
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Hearthstone.card
class
Back
<
Hearthstone
::
GenericDataEndpoint
# Valid options for card search
VALID_SEARCH_OPTIONS
=
%i[
cardBackCategory
textFilter
sort
order
]
.
freeze
##
# Returns an up-to-date list of all card backs matching the search criteria. For more information about the
# search parameters, see the Card Backs Guide.
#
# @param search_options [Hash] Search options accepted by the endpoint
# @option search_options [String] :cardBackCategory A category of the card back. The category must match a valid category.
# @option search_options [String] :textFilter A text string used to filter cards.
# You must include a locale along with the textFilter parameter.
# @option search_options [String] :sort The field used to sort the results. Valid value include name.
# Results are sorted by date (desc) by default.
# @option search_options [String] :order The order in which to sort the results.
# Valid values are asc or desc. The default value is asc.
# @!macro request_options
# @option options [Boolean] :validate_fields If set to true, this method will throw an exception if nay search
# option is invalid
#
# @!macro response
def
search
(
search_options
=
{},
options
=
{})
validate_search_options
search_options
if
options
.
include?
:validate_fields
api_request
"
#{
base_url
(
:community
)
}
/cardbacks"
,
default_options
.
merge
(
options
).
merge
(
search_options
)
end
protected
def
validate_search_options
(
search_options
)
search_options
.
each
do
|
field
|
raise
ArgumentError
,
"Unrecognized search option
#{
field
}
"
unless
VALID_SEARCH_OPTIONS
.
include?
field
end
end
def
endpoint_setup
@endpoint
=
'cardbacks'
@ttl
=
CACHE_TRIMESTER
end
end
end
end
lib/blizzard_api/hearthstone/game_data/card.rb
View file @
186f7dfe
...
...
@@ -6,6 +6,7 @@ module BlizzardApi
# This class allows access to Hearthstone card data
#
# @see https://develop.battle.net/documentation/api-reference/hearthstone-game-data-api
# @see https://develop.battle.net/documentation/hearthstone/guides/card-search
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Hearthstone.card
...
...
@@ -23,6 +24,7 @@ module BlizzardApi
minionType
keyword
textFilter
gameMode
page
pageSize
sort
...
...
@@ -55,6 +57,8 @@ module BlizzardApi
# and so on). This value must match the keyword slugs found in metadata.
# @option search_options [String] :textFilter A text string used to filter cards.
# You must include a locale along with the textFilter parameter.
# @option search_options [String] :gameMode A recognized game mode (for example, battlegrounds or constructed).
# The default value is constructed. See the Game Modes Guide for more information.
# @option search_options [Integer] :page A page number.
# @option search_options [Integer] :pageSize The number of results to choose per page.
# A value will be selected automatically if you do not supply a pageSize or if the pageSize is higher than the
...
...
@@ -74,6 +78,22 @@ module BlizzardApi
api_request
"
#{
base_url
(
:community
)
}
/cards"
,
default_options
.
merge
(
options
).
merge
(
search_options
)
end
##
# Returns the card with an ID or slug that matches the one you specify. For more information, see the Card Search Guide.
#
# @see https://develop.battle.net/documentation/hearthstone/guides/card-search
# @see https://develop.battle.net/documentation/hearthstone/guides/game-modes
#
# @param id_or_slug [String] Card ID or slug
# @param game_mode [String] A recognized game mode (for example, battlegrounds or constructed).
# The default value is constructed. See the Game Modes Guide for more information.
# @!macro request_options
#
# @!macro response
def
get
(
id_or_slug
,
game_mode
=
'constructed'
,
options
=
{})
super
id_or_slug
,
{
gameMode:
game_mode
}.
merge
(
options
)
end
protected
def
validate_search_options
(
search_options
)
...
...
lib/blizzard_api/hearthstone/game_data/deck.rb
View file @
186f7dfe
...
...
@@ -6,6 +6,7 @@ module BlizzardApi
# This class allows access to Hearthstone deck data
#
# @see https://develop.battle.net/documentation/api-reference/hearthstone-game-data-api
# @see https://develop.battle.net/documentation/hearthstone/guides/decks
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Hearthstone.deck
...
...
lib/blizzard_api/hearthstone/game_data/generic_data_endpoint.rb
View file @
186f7dfe
...
...
@@ -27,7 +27,7 @@ module BlizzardApi
##
# Fetch all possible data for one of items listed by the {#index} using its *id*
#
# @param [Integer] id One of the IDs returned by the {#index}
# @param [Integer
|String
] id One of the IDs returned by the {#index}
# @!macro request_options
#
# @!macro response
...
...
lib/blizzard_api/hearthstone/game_data/metadata.rb
View file @
186f7dfe
...
...
@@ -6,6 +6,7 @@ module BlizzardApi
# This class allows access to Hearthstone metadata data
#
# @see https://develop.battle.net/documentation/api-reference/hearthstone-game-data-api
# https://develop.battle.net/documentation/hearthstone/guides/metadata
#
# You can get an instance of this class using the default region as follows:
# api_instance = BlizzardApi::Hearthstone.metadata
...
...
lib/blizzard_api/version.rb
View file @
186f7dfe
...
...
@@ -2,5 +2,5 @@
module
BlizzardApi
# Gem version
VERSION
=
'0.3.
0
'
VERSION
=
'0.3.
1
'
end
test/blizzard/hearthstone/game_data/back_test.rb
0 → 100644
View file @
186f7dfe
# frozen_string_literal: true
require
'test_helper'
module
BlizzardApi
module
Hearthstone
class
BackTest
<
Minitest
::
Test
def
test_back_index
back
=
BlizzardApi
::
Hearthstone
::
Back
.
new
back_data
=
back
.
index
assert
back_data
[
:cardBacks
]
end
def
test_back_get
back
=
BlizzardApi
::
Hearthstone
::
Back
.
new
back_data
=
back
.
get
1
assert
back_data
[
:slug
]
end
end
end
end
test/blizzard/wow/game_data/achievement_test.rb
View file @
186f7dfe
...
...
@@ -8,7 +8,7 @@ module BlizzardApi
def
test_achievement_index
achievement
=
BlizzardApi
::
Wow
::
Achievement
.
new
achievement_data
=
achievement
.
index
assert_equal
5
034
,
achievement_data
[
:achievements
].
count
assert_equal
5
131
,
achievement_data
[
:achievements
].
count
end
def
test_achievement_get
...
...
@@ -31,7 +31,7 @@ module BlizzardApi
achievement
=
BlizzardApi
::
Wow
::
Achievement
.
new
achievement_categories_data
=
achievement
.
categories
assert_equal
14
,
achievement_categories_data
[
:root_categories
].
count
assert_equal
11
3
,
achievement_categories_data
[
:categories
].
count
assert_equal
11
5
,
achievement_categories_data
[
:categories
].
count
assert_equal
24
,
achievement_categories_data
[
:guild_categories
].
count
end
...
...
@@ -39,7 +39,7 @@ module BlizzardApi
achievement
=
BlizzardApi
::
Wow
::
Achievement
.
new
achievement_categories_data
=
achievement
.
category
81
assert_equal
'Feats of Strength'
,
achievement_categories_data
[
:name
][
:en_US
]
assert_equal
10
8
,
achievement_categories_data
[
:achievements
].
count
assert_equal
10
9
,
achievement_categories_data
[
:achievements
].
count
end
def
test_achievement_media
...
...
test/blizzard/wow/game_data/azerite_essence_test.rb
View file @
186f7dfe
...
...
@@ -11,7 +11,7 @@ module BlizzardApi
def
test_azerite_essence_index
title_data
=
@azerite_essence
.
index
assert_equal
2
1
,
title_data
[
:azerite_essences
].
count
assert_equal
2
8
,
title_data
[
:azerite_essences
].
count
end
def
test_azerite_essence_get
...
...
test/blizzard/wow/game_data/creature_test.rb
View file @
186f7dfe
...
...
@@ -61,7 +61,7 @@ module BlizzardApi
def
test_creature_display_media
creature_display_media_data
=
@creature
.
display_media
30_221
assert_equal
'https://render-us.worldofwarcraft.com/npcs/
portrait
/creature-display-30221.jpg'
,
assert_equal
'https://render-us.worldofwarcraft.com/npcs/
zoom
/creature-display-30221.jpg'
,
creature_display_media_data
[
:assets
][
0
][
:value
]
creature_display_media_data
=
@creature
.
display_media
180
,
classic:
true
...
...
test/blizzard/wow/game_data/guild_crest_test.rb
View file @
186f7dfe
...
...
@@ -20,7 +20,7 @@ module BlizzardApi
def
test_guild_crest_border
guild_crest_data
=
@guild_crest
.
border_media
0
assert_equal
'https://
us.battle.net/wow/static/images
/guild/tabards/border_00.png'
,
assert_equal
'https://
render-us.worldofwarcraft.com
/guild/tabards/border_00.png'
,
guild_crest_data
[
:assets
][
0
][
:value
]
guild_crest_data
=
@guild_crest
.
border_media
0
,
classic:
true
...
...
@@ -30,7 +30,7 @@ module BlizzardApi
def
test_guild_crest_emblem
guild_crest_data
=
@guild_crest
.
emblem_media
0
assert_equal
'https://
us.battle.net/wow/static/images
/guild/tabards/emblem_00.png'
,
assert_equal
'https://
render-us.worldofwarcraft.com
/guild/tabards/emblem_00.png'
,
guild_crest_data
[
:assets
][
0
][
:value
]
guild_crest_data
=
@guild_crest
.
emblem_media
0
,
classic:
true
...
...
test/blizzard/wow/game_data/mount_test.rb
View file @
186f7dfe
...
...
@@ -11,10 +11,10 @@ module BlizzardApi
def
test_mount_index
mount_data
=
@mount
.
index
assert_equal
778
,
mount_data
[
:mounts
].
count
assert_equal
805
,
mount_data
[
:mounts
].
count
mount_data
=
@mount
.
index
use_community_endpoint:
true
assert_equal
9
30
,
mount_data
[
:mounts
].
count
assert_equal
9
52
,
mount_data
[
:mounts
].
count
end
def
test_mount_get
...
...
test/blizzard/wow/game_data/mythic_keystone_leaderboard_test.rb
View file @
186f7dfe
...
...
@@ -11,7 +11,7 @@ module BlizzardApi
def
test_mythic_keystone_dungeons
mythic_keystone_leaderboard_data
=
@mythic_keystone_leaderboard
.
index
11
assert_equal
1
0
,
mythic_keystone_leaderboard_data
[
:current_leaderboards
].
count
assert_equal
1
2
,
mythic_keystone_leaderboard_data
[
:current_leaderboards
].
count
end
def
test_mythic_keystone_dungeon
...
...
test/blizzard/wow/game_data/mythic_keystone_test.rb
View file @
186f7dfe
...
...
@@ -27,7 +27,7 @@ module BlizzardApi
def
test_mythic_keystone_periods
mythic_keystone_periods
=
@mythic_keystone_leaderboard
.
periods
assert_equal
9
2
,
mythic_keystone_periods
[
:periods
].
count
assert_equal
9
3
,
mythic_keystone_periods
[
:periods
].
count
end
def
test_mythic_keystone_period
...
...
@@ -37,7 +37,7 @@ module BlizzardApi
def
test_mythic_keystone_seasons
mythic_keystone_seasons_data
=
@mythic_keystone_leaderboard
.
seasons
assert_equal
4
,
mythic_keystone_seasons_data
[
:seasons
].
count
assert_equal
5
,
mythic_keystone_seasons_data
[
:seasons
].
count
end
def
test_mythic_keystone_season
...
...
test/blizzard/wow/game_data/pets_test.rb
View file @
186f7dfe
...
...
@@ -11,10 +11,10 @@ module BlizzardApi
def
test_pet_index
pet_data
=
@pet
.
index
assert_equal
12
4
8
,
pet_data
[
:pets
].
count
assert_equal
128
0
,
pet_data
[
:pets
].
count
pet_data
=
@pet
.
index
use_community_endpoint:
true
assert_equal
12
44
,
pet_data
[
:pets
].
count
assert_equal
12
80
,
pet_data
[
:pets
].
count
end
def
test_pet_get
...
...
test/blizzard/wow/game_data/race_test.rb
View file @
186f7dfe
...
...
@@ -8,10 +8,10 @@ module BlizzardApi
def
test_race_index
race
=
BlizzardApi
::
Wow
::
Race
.
new
race_data
=
race
.
index
assert_equal
2
3
,
race_data
[
:races
].
count
assert_equal
2
5
,
race_data
[
:races
].
count
race_data
=
race
.
index
assert_equal
2
3
,
race_data
[
:races
].
count
assert_equal
2
5
,
race_data
[
:races
].
count
end
def
test_race_get
...
...
test/blizzard/wow/game_data/reputation_faction_test.rb
View file @
186f7dfe
...
...
@@ -11,7 +11,7 @@ module BlizzardApi
def
test_reputation_tier_index
reputation_data
=
@reputation
.
index
assert_equal
19
6
,
reputation_data
[
:factions
].
count
assert_equal
19
9
,
reputation_data
[
:factions
].
count
end
def
test_reputation_tier_get
...
...
test/blizzard/wow/game_data/title_test.rb
View file @
186f7dfe
...
...
@@ -11,7 +11,7 @@ module BlizzardApi
def
test_title_index
title_data
=
@title
.
index
assert_equal
3
68
,
title_data
[
:titles
].
count
assert_equal
3
75
,
title_data
[
:titles
].
count
end
def
test_title_get
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment