From df99fd767b47a280dbb79ecb3e21a76be7ab6473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Dolej=C5=A1ka?= Date: Wed, 19 May 2021 22:11:25 +0200 Subject: [PATCH] fix(api): fix spectator endpoint function name to match the docs --- .../Spectator/getCurrentGameInfo.php | 2 +- src/LeagueAPI/LeagueAPI.php | 19 ++++++++----------- .../SpectatorEndpointObjectIntegrityTest.php | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/LeagueAPI/Spectator/getCurrentGameInfo.php b/examples/LeagueAPI/Spectator/getCurrentGameInfo.php index f84e3fa..f126db5 100644 --- a/examples/LeagueAPI/Spectator/getCurrentGameInfo.php +++ b/examples/LeagueAPI/Spectator/getCurrentGameInfo.php @@ -13,7 +13,7 @@ try { $summoner = $api->getSummonerByName($id); // summonerIds are unique per API key, getByName first is necessary - $g = $api->getCurrentGameInfo($summoner->id); + $g = $api->getCurrentGameInfoBySummoner($summoner->id); } catch (RequestException $ex) { diff --git a/src/LeagueAPI/LeagueAPI.php b/src/LeagueAPI/LeagueAPI.php index 98b181e..37bf1d8 100644 --- a/src/LeagueAPI/LeagueAPI.php +++ b/src/LeagueAPI/LeagueAPI.php @@ -41,15 +41,6 @@ */ class LeagueAPI extends BaseAPI { - /** - * Constants for cURL requests. - */ - const - METHOD_GET = 'GET', - METHOD_POST = 'POST', - METHOD_PUT = 'PUT', - METHOD_DELETE = 'DELETE'; - /** * Settings constants. */ @@ -354,6 +345,12 @@ public function getChampionMasteryScore( string $encrypted_summoner_id ) const RESOURCE_SPECTATOR = '1419:spectator'; const RESOURCE_SPECTATOR_VERSION = 'v4'; + public function getCurrentGameInfo(string $encrypted_summoner_id) + { + user_error("The LeagueAPI::getCurrentGameInfo will be soon removed in favour of LeagueAPI::getCurrentGameInfoBySummoner.", E_USER_DEPRECATED); + return $this->getCurrentGameInfoBySummoner($encrypted_summoner_id); + } + /** * Get current game information for the given summoner ID. * @@ -362,7 +359,7 @@ public function getChampionMasteryScore( string $encrypted_summoner_id ) * * @param string $encrypted_summoner_id * - * @return Objects\CurrentGameInfo + * @return Objects\CurrentGameInfo|null * * @throws SettingsException * @throws RequestException @@ -372,7 +369,7 @@ public function getChampionMasteryScore( string $encrypted_summoner_id ) * * @link https://developer.riotgames.com/apis#spectator-v4/GET_getCurrentGameInfoBySummoner */ - public function getCurrentGameInfo( string $encrypted_summoner_id ) + public function getCurrentGameInfoBySummoner(string $encrypted_summoner_id) { $resultPromise = $this->setEndpoint("/lol/spectator/" . self::RESOURCE_SPECTATOR_VERSION . "/active-games/by-summoner/{$encrypted_summoner_id}") ->setResource(self::RESOURCE_SPECTATOR, "/active-games/by-summoner/%s") diff --git a/tests/LeagueAPI/EndpointObjectIntegrity/SpectatorEndpointObjectIntegrityTest.php b/tests/LeagueAPI/EndpointObjectIntegrity/SpectatorEndpointObjectIntegrityTest.php index 4109ec3..1d7500e 100644 --- a/tests/LeagueAPI/EndpointObjectIntegrity/SpectatorEndpointObjectIntegrityTest.php +++ b/tests/LeagueAPI/EndpointObjectIntegrity/SpectatorEndpointObjectIntegrityTest.php @@ -51,7 +51,7 @@ public function testGetCurrentGame(LeagueAPI $api ) $summonerId = "KnNZNuEVZ5rZry3IyWwYSVuikRe0y3qTWSkr1wxcmV5CLJ8"; // Get library processed results /** @var Objects\CurrentGameInfo $result */ - $result = $api->getCurrentGameInfo($summonerId); + $result = $api->getCurrentGameInfoBySummoner($summonerId); // Get raw result $rawResult = $api->getResult();