dolejska-daniel / riot-api

Riot League of Legends & DataDragon API wrappers for PHP7 and PHP8.
GNU General Public License v3.0
112 stars 25 forks source link

Tournament API, requesting tourney codes for anyone #44

Closed Lagily closed 5 years ago

Lagily commented 5 years ago

Hello I am using the v4 Tournament Code endpoint to generate tourney codes for a tournament and I receive the following error when trying to request tournament codes:

Fatal error: Uncaught RiotAPI\LeagueAPI\Exceptions\RequestParameterException: List of participants (allowedSummonerIds) may not be empty. If you wish to allow anyone, fill it with 0, 1, 2, 3, etc. in vendor\dolejska-daniel\riot-api\src\LeagueAPI\LeagueAPI.php on line 2744

First off all I don't quite understand the error, what am I supposed to fill in in order to allow all users? Second, if I fill the array with 0 - 9 I receive an Error from Riot stating that '0 cannot be decrypted', this is because the Riot API tries to decrypt the userids sent, so that error message makes even less sense.

Is there a good way to allow all users to use the tourney code using this API?

Lagily commented 5 years ago

For me personally I fixed this by removing the lines 2743 - 2747 from LeagueAPI.php:

        /*if (empty($parameters->allowedSummonerIds))
            throw new RequestParameterException('List of participants (allowedSummonerIds) may not be empty. If you wish to allow anyone, fill it with 0, 1, 2, 3, etc.');

        if ($parameters->teamSize * 2 > count($parameters->allowedSummonerIds))
            throw new RequestParameterException('Not enough players to fill teams (more participants required).');*/

And removing the line 66 in TournamentCodeParameters.php

public $allowedSummonerIds;

But there should be a way to not send any allowedSummonerIds in the body of the request, when sending an empty array the Riot API also answers with an error, that there should be no allowedSummonerIds array in the body if it is empty.

Lagily commented 5 years ago

Hey, any chance for a fix on this anytime soon, so we can use the library without modifying the code?

dolejska-daniel commented 5 years ago

Hello @Lagily, I've already fixed this issue i just forgot to commit and push it, so thanks for reminding me 😅! Sorry about that 😸.