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
ab098955
Commit
ab098955
authored
Jun 09, 2020
by
Francis
Browse files
New retail and classic endpoints for WoW
parent
aabf8403
Pipeline
#154589941
passed with stage
in 5 minutes and 17 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
8 deletions
+102
-8
CHANGELOG.md
CHANGELOG.md
+4
-0
lib/blizzard_api/request.rb
lib/blizzard_api/request.rb
+1
-1
lib/blizzard_api/version.rb
lib/blizzard_api/version.rb
+1
-1
lib/blizzard_api/wow/game_data/pet.rb
lib/blizzard_api/wow/game_data/pet.rb
+46
-0
test/blizzard/wow/game_data/pets_test.rb
test/blizzard/wow/game_data/pets_test.rb
+20
-0
test/blizzard/wow/game_data/realm_test.rb
test/blizzard/wow/game_data/realm_test.rb
+14
-0
test/blizzard/wow/game_data/region_test.rb
test/blizzard/wow/game_data/region_test.rb
+16
-6
No files found.
CHANGELOG.md
View file @
ab098955
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
...
...
lib/blizzard_api/request.rb
View file @
ab098955
...
...
@@ -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
...
...
lib/blizzard_api/version.rb
View file @
ab098955
...
...
@@ -2,5 +2,5 @@
module
BlizzardApi
# Gem version
VERSION
=
'0.4.
0
'
VERSION
=
'0.4.
1
'
end
lib/blizzard_api/wow/game_data/pet.rb
View file @
ab098955
...
...
@@ -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
...
...
test/blizzard/wow/game_data/pets_test.rb
View file @
ab098955
...
...
@@ -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
test/blizzard/wow/game_data/realm_test.rb
View file @
ab098955
...
...
@@ -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
...
...
test/blizzard/wow/game_data/region_test.rb
View file @
ab098955
...
...
@@ -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
...
...
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