paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

Matchlist not found. #86

Closed savisaar2 closed 9 years ago

savisaar2 commented 9 years ago

When i try to retrieve matchlist i get this error: The api class "LeagueWrap\Api\Matchlist" was not found.

this is the function:

public function matchHistory(Request $request)
{
    $api = new Api(env('LOL_API_KEY'));
    $matchlist = $api->matchList($request->summoner_id);
}
dnlbauer commented 9 years ago

You are missing one call to get the right api object. It might be a bit confusing because the names are identical but what you want to do is this:

public function matchHistory(Request $request)
{
    $api = new Api(env('LOL_API_KEY'));
    $matchlistEndpoint = $api->matchlist(); 
    $matchlistt = $matchlistEndpoint->matchlist($request->summoner_id);
}

the reason is that the api class hosts multiple services (one per endpoint from https://developer.riotgames.com/api/methods). Api#matchlist() will return you the correct endpoint object for doing matchlist requests. This matchlist object has a method to do actual calls to the matchlist api Matchlist#matchlist($summonerid, other params...)