Skip to content

Commit

Permalink
fix(api): fix spectator endpoint function name to match the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dolejska-daniel committed May 19, 2021
1 parent 5fc3951 commit df99fd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/LeagueAPI/Spectator/getCurrentGameInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
19 changes: 8 additions & 11 deletions src/LeagueAPI/LeagueAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit df99fd7

Please sign in to comment.