Skip to content

Commit

Permalink
feat(match): add queue and type parameters to getMatchIdsByPUUID API …
Browse files Browse the repository at this point in the history
…method (#1)
  • Loading branch information
dolejska-daniel committed Aug 24, 2021
1 parent 7df5969 commit c7706e6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/LeagueAPI/LeagueAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ class LeagueAPI extends BaseAPI
SPECTATOR_LOBBY_ONLY = 'LOBBYONLY',
SPECTATOR_ALL = 'ALL';

const
MATCH_ALLOWED_TYPES = [
"ranked",
"normal",
"tourney",
"tutorial",
];

/**
* Constants required for tournament API calls.
*/
Expand Down Expand Up @@ -1323,9 +1331,11 @@ public function getMatchTimeline( $match_id )
* @cli-name get-ids-by-puuid
* @cli-namespace match
*
* @param string $puuid
* @param int|null $start
* @param int|null $count
* @param string $puuid
* @param int|null $queue Filter the list of match ids by a specific queue id. This filter is mutually inclusive of the type filter meaning any match ids returned must match both the queue and type filters.
* @param string|null $type Filter the list of match ids by the type of match. This filter is mutually inclusive of the queue filter meaning any match ids returned must match both the queue and type filters.
* @param int|null $start Start index.
* @param int|null $count Valid values: 0 to 100. Number of match ids to return.
*
* @return string[]
*
Expand All @@ -1337,8 +1347,11 @@ public function getMatchTimeline( $match_id )
*
* @link https://developer.riotgames.com/apis#match-v5/GET_getMatchIdsByPUUID
*/
public function getMatchIdsByPUUID(string $puuid, int $start = null, int $count = null)
public function getMatchIdsByPUUID(string $puuid, int $queue = null, string $type = null, int $start = null, int $count = null)
{
if ($type && !in_array($type, self::MATCH_ALLOWED_TYPES))
throw new RequestParameterException('Value of match type (type) is invalid. Allowed values: ' . implode(', ', self::MATCH_ALLOWED_TYPES));

if ($start && $start < 0)
throw new RequestParameterException('Start index (start) must be greater than or equal to 0.');

Expand All @@ -1349,6 +1362,8 @@ public function getMatchIdsByPUUID(string $puuid, int $start = null, int $count

$resultPromise = $this->setEndpoint("/lol/match/" . self::RESOURCE_MATCH_VERSION . "/matches/by-puuid/{$puuid}/ids")
->setResource(self::RESOURCE_MATCH, "/matches/by-puuid/%s/ids")
->addQuery("queue", $queue)
->addQuery("type", $type)
->addQuery("start", $start)
->addQuery("count", $count)
->makeCall($continent_region);
Expand Down

0 comments on commit c7706e6

Please sign in to comment.