public function testFeaturedGames()
 {
     $this->client->shouldReceive('baseUrl')->once()->with('https://na.api.pvp.net/observer-mode/rest/');
     $this->client->shouldReceive('request')->with('featured', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/featuredgames.na.json'));
     $api = new Api('key', $this->client);
     $featuredGames = $api->featuredGames()->featuredGames();
     $this->assertEquals(1718765493, $featuredGames[0]->gameId);
 }
예제 #2
0
 public function testParticipantIdentity()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v2.2/matchhistory/74602', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/matchhistory.74602.json'));
     $api = new Api('key', $this->client);
     $matches = $api->matchHistory()->history(74602);
     $this->assertEquals(0, $matches->match(0)->identity(0)->participantId);
 }
예제 #3
0
 public function testGetRealmKR()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once();
     $this->client->shouldReceive('request')->with('v1.2/realm', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/realm.kr.json'));
     $api = new Api('key', $this->client);
     $kr = $api->setRegion('kr')->staticData()->getRealm();
     $this->assertEquals('ko_KR', $kr->l);
 }
예제 #4
0
 public function testGetRuneAll()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/rune', ['api_key' => 'key', 'runeListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/rune.all.json'));
     $api = new Api('key', $this->client);
     $runes = $api->staticData()->getRunes('all');
     $rune = $runes->getRune(5001);
     $this->assertEquals('0.525', $rune->stats->FlatPhysicalDamageMod);
 }
예제 #5
0
 public function testGetShardStatus()
 {
     $this->client->shouldReceive('baseUrl')->with('http://status.leagueoflegends.com/')->once();
     $this->client->shouldReceive('request')->with('shards/euw', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/shardstatus.euw.json'));
     $api = new Api('key', $this->client);
     $api->setRegion('euw');
     $shardStatus = $api->status()->shardStatus();
     $this->assertTrue($shardStatus instanceof \LeagueWrap\Dto\ShardStatus);
 }
예제 #6
0
 public function testGetItemArray()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/item', ['api_key' => 'key', 'itemListData' => 'gold,image'])->once()->andReturn(file_get_contents('tests/Json/Static/items.gold.image.json'));
     $api = new Api('key', $this->client);
     $items = $api->staticData()->getItems(array("gold", "image"));
     $item = $items->getItem(1042);
     $this->assertEquals(450, $item->gold->total);
 }
예제 #7
0
 public function testGetChampionAll()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['api_key' => 'key', 'dataById' => 'true', 'champData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/champion.all.json'));
     $api = new Api('key', $this->client);
     $champions = $api->staticData()->getChampions('all');
     $champion = $champions->getChampion(412);
     $this->assertEquals('beginner_Starter', $champion->recommended[0]->blocks[0]->type);
 }
예제 #8
0
 public function testGetMasteryAll()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v1.2/mastery', ['api_key' => 'key', 'masteryListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.all.json'));
     $api = new Api('key', $this->client);
     $masteries = $api->staticData()->getMasteries('all');
     $mastery = $masteries->getMastery(4322);
     $this->assertEquals('Reduces the cooldown of Summoner Spells by 10%', $mastery->description[2]);
 }
예제 #9
0
 public function testGetSummonerSpellAll()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once();
     $this->client->shouldReceive('request')->with('v1.2/summoner-spell', ['api_key' => 'key', 'dataById' => 'true', 'spellData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/summonerspell.all.json'));
     $api = new Api('key', $this->client);
     $spells = $api->staticData()->getSummonerSpells('all');
     $spell = $spells->getSpell(7);
     $this->assertEquals('f1', $spell->vars[0]->key);
 }
예제 #10
0
 public function testListWithParams()
 {
     $startTime = 1283846202;
     $endTime = 1283846202 + 1000;
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v2.2/matchlist/by-summoner/74602', ['api_key' => 'key', 'rankedQueues' => 'RANKED_SOLO_5x5', 'seasons' => 'SEASON2015', 'championIds' => '1,2,3', 'beginIndex' => 1, 'endIndex' => 4, 'beginTime' => $startTime, 'endTime' => $endTime])->once()->andReturn(file_get_contents('tests/Json/matchlist.74602.json'));
     $api = new Api('key', $this->client);
     $matchList = $api->matchlist()->matchlist(74602, 'RANKED_SOLO_5x5', 'SEASON2015', [1, 2, 3], 1, 4, $startTime, $endTime);
     $this->assertTrue($matchList->match(0) instanceof LeagueWrap\Dto\MatchReference);
 }
예제 #11
0
 public function testRankedArrayAccessSeason()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('request')->with('v1.3/stats/by-summoner/74602/ranked', ['api_key' => 'key', 'season' => 3])->once()->andReturn(file_get_contents('tests/Json/stats.ranked.74602.season4.json'));
     $api = new Api('key', $this->client);
     $stats = $api->stats();
     $stats->setSeason(3);
     $stats = $stats->ranked(74602);
     $this->assertTrue($stats[0] instanceof LeagueWrap\Dto\ChampionStats);
 }
예제 #12
0
 public function testTeamSummonerMultiple()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->twice();
     $this->client->shouldReceive('request')->with('v1.4/summoner/18991200,492066', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.18991200.492066.json'));
     $this->client->shouldReceive('request')->with('v2.4/team/by-summoner/492066,18991200', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/team.18991200.492066.json'));
     $api = new Api('key', $this->client);
     $summoners = $api->summoner()->info([18991200, 492066]);
     $api->team()->team($summoners);
     $team = $summoners['C9 Hai']->teams['TEAM-9baaf74e-ea61-4ebc-82d9-b013d29399fa'];
     $this->assertEquals('C9', $team->tag);
 }
예제 #13
0
 public function testChampionsAttachResponse()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/championmastery/location/NA1/')->once();
     $this->client->shouldReceive('request')->with('player/74602/champions', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/championmastery.30447079.topcount3.json'));
     $this->client->shouldReceive('request')->with('v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.bakasan.json'));
     $api = new Api('key', $this->client);
     $bakasan = $api->summoner()->info('bakasan');
     $api->championMastery()->champions($bakasan);
     $this->assertTrue($bakasan->championmastery instanceof \LeagueWrap\Dto\ChampionMasteryList);
 }
예제 #14
0
 public function testCurrentGameParticipantRunes()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('consumer/getSpectatorGameInfo/EUW1/30447079', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/currentgame.30447079.json'));
     $api = new Api('key', $this->client);
     $api->setRegion('euw');
     $game = $api->currentGame()->currentGame(30447079);
     $participant = $game->participant(28882300);
     $this->assertTrue($participant->rune(5253) instanceof \LeagueWrap\Dto\Rune);
     $this->assertTrue($participant->rune(5253)->count == 9);
 }
예제 #15
0
 public function testTimelineFrame()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v2.2/match/1399898747', ['api_key' => 'key', 'includeTimeline' => true])->once()->andReturn(file_get_contents('tests/Json/matchhistory.match.1399898747.timeline.json'));
     $api = new Api('key', $this->client);
     $match = $api->match()->match(1399898747, true);
     $frame = $match->timeline->frames[1];
     $this->assertTrue($frame instanceof LeagueWrap\Dto\TimelineFrame);
     $this->assertTrue($frame->participantFrame(1) instanceof LeagueWrap\Dto\TimelineParticipantFrame);
     $this->assertTrue($frame->events[0] instanceof LeagueWrap\Dto\TimelineFrameEvent);
 }
예제 #16
0
 public function testRecentStatsSummonerRaw()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->twice();
     $this->client->shouldReceive('request')->with('v1.3/game/by-summoner/74602/recent', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/game.recent.74602.json'));
     $this->client->shouldReceive('request')->with('v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/summoner.bakasan.json'));
     $api = new Api('key', $this->client);
     $bakasan = $api->summoner()->info('bakasan');
     $games = $api->game()->recent($bakasan);
     $game = $bakasan->recentGame(0)->raw();
     $this->assertEquals(13, $game['stats']['level']);
 }
예제 #17
0
 public function testGetMasteryAsTreeLegacy()
 {
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->once();
     $this->client->shouldReceive('request')->with('v1.2/mastery', ['api_key' => 'key', 'masteryListData' => 'all'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.2015.all.json'));
     $api = new Api('key', $this->client);
     $masteries = $api->staticData()->getMasteries('all');
     $tree = $masteries->tree;
     $this->assertInstanceOf('\\LeagueWrap\\Dto\\StaticData\\MasteryTree', $tree);
     $defenseTree = $tree->Defense;
     $this->assertTrue(is_array($defenseTree));
     $this->assertInstanceOf('\\LeagueWrap\\Dto\\StaticData\\MasteryTreeList', $defenseTree[0]);
 }
예제 #18
0
 public function testUnderlyingServiceExceptionContainsResponse()
 {
     try {
         $this->simulateWithResponse(new Response('', 429, []));
         $api = new Api('key', $this->client);
         $api->champion()->all();
     } catch (ResponseException $e) {
         $this->assertTrue($e->hasResponse());
         $this->assertInstanceOf(UnderlyingServiceRateLimitReached::class, $e);
         $this->assertInstanceOf(Response::class, $e->getResponse());
         $this->assertFalse($e->getResponse()->hasHeader('Retry-After'));
         $this->assertFalse($e->getResponse()->hasHeader('X-Rate-Limit-Type'));
         $this->assertCount(0, $e->getResponse()->getHeaders());
         $this->assertEquals([], $e->getResponse()->getHeaders());
         $this->assertNull($e->getResponse()->getHeader('Retry-After'));
         $this->assertNull($e->getResponse()->getHeader('X-Rate-Limit-Type'));
     }
 }
 public function updateAction()
 {
     // Connect to Riot Api and get champion data
     $key = '';
     $api = new Api($key);
     $champions = $api->staticData()->getChampions();
     // Create transaction
     $manager = new \Phalcon\Mvc\Model\Transaction\Manager();
     $transaction = $manager->get();
     // Insert champion id and champion name into MySQL
     foreach ($champions as $champion) {
         // Remove spaces, periods, and apostrophes from names to better correspond with img names
         $to_remove = array("'", ".", " ");
         $to_replace = array("", "", "");
         $champion_name = $champion->name;
         $champion_name = str_replace($to_remove, $to_replace, $champion_name);
         // Insert champion id and name
         $new_champion = new Champion();
         $new_champion->setTransaction($transaction);
         $new_champion->save(array("champion_id" => $champion->id, "champion_name" => $champion_name));
         print "Inserted: " . $champion->id . " " . $champion_name . "<br>";
     }
     $transaction->commit();
 }
예제 #20
0
<?php

require 'vendor/autoload.php';
use LeagueWrap\Api;
$api = new Api('67ec97d4-97e6-4db2-8102-92ac79eae66e');
$api->setRegion('euw');
$summoner = $api->summoner();
$info = $summoner->info('stahp fgt');
echo '<pre>', print_r($info, true);
예제 #21
0
 /**
  * @expectedException LeagueWrap\Response\Http404
  */
 public function testInfoSummonerNotFound()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v1.4/summoner/by-name/bakasan', ['api_key' => 'key'])->once()->andReturn(new LeagueWrap\Response('', 404));
     $api = new Api('key', $this->client);
     $bakasan = $api->summoner()->info('bakasan');
 }
예제 #22
0
 public function testGetLimitsOneRegion()
 {
     $api = new Api('key');
     $api->limit(5, 5, 'na');
     $this->assertEquals(1, sizeof($api->getLimits()));
 }
예제 #23
0
 /**
  * @expectedException LeagueWrap\Response\Http400
  * @expectedExceptionMessage Bad request.
  */
 public function testAllBadRquest()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'false', 'api_key' => 'key'])->once()->andReturn(new LeagueWrap\Response('', 400));
     $api = new Api('key', $this->client);
     $champion = $api->champion();
     $champions = $champion->all();
 }
예제 #24
0
<?php

header("Access-Control-Allow-Origin: *");
include_once './vendor/autoload.php';
include_once './dataFiltering.php';
use LeagueWrap\Api;
$platformID = "";
if (isset($_REQUEST['server'])) {
    $platformID = $_REQUEST['server'];
} else {
    $platformID = 'garena';
    // TODO: other regions that are not provided by RIOT Servers will count as 'garena' too (China / Korea)
}
include_once 'riot-api-key.php';
// own file with RIOT API key stored to $RIOT_API_KEY variable
$api = new Api($RIOT_API_KEY);
// Load up the API
// TODO: remove jp condition when implemented by RIOT (https://developer.riotgames.com/discussion/announcements/show/9iYdLpZZ)
if (strtolower($platformID) !== 'garena' && strtolower($platformID) !== 'jp') {
    $api->setRegion(mapPlatformIDToRegion($platformID));
} else {
    $api->setRegion('na');
    // TODO: This might lead to differences in data if garena servers are not up to date
}
$allChamps = $api->staticData()->getChampions(['allytips', 'enemytips', 'image', 'spells', 'passive'])->raw()['data'];
/** lower case without spaces */
$allChampsByName = array();
foreach ($allChamps as $champ) {
    $allChampsByName[normalizeChampName($champ['name'])] = $champ;
}
$championNames = explode(',', $_REQUEST['championNames']);
 public function testLanguage()
 {
     $method = $this->getMethod('LeagueWrap\\Api\\Staticdata', 'setUpParams');
     $api = new Api('key', $this->client);
     $staticData = $api->staticData();
     $staticData->setLocale('fr_FR');
     $params = $method->invoke($staticData, 'champion', 266, 'tags', 'champData', 'champData');
     $expected = ['locale' => 'fr_FR', 'champData' => 'tags'];
     $this->assertEquals($expected, $params);
 }
예제 #26
0
 public function testAttachStaticData()
 {
     $this->client->shouldReceive('baseUrl')->with('https://euw.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo/EUW1/')->once();
     $this->client->shouldReceive('baseUrl')->with('https://global.api.pvp.net/api/lol/static-data/')->times(4);
     $this->client->shouldReceive('request')->with('30447079', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/currentgame.30447079.json'));
     $this->client->shouldReceive('request')->with('v1.2/champion', ['api_key' => 'key', 'dataById' => 'true'])->once()->andReturn(file_get_contents('tests/Json/Static/champion.euw.json'));
     $this->client->shouldReceive('request')->with('v1.2/summoner-spell', ['api_key' => 'key', 'dataById' => 'true'])->once()->andReturn(file_get_contents('tests/Json/Static/summonerspell.euw.json'));
     $this->client->shouldReceive('request')->with('v1.2/mastery', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/mastery.euw.json'));
     $this->client->shouldReceive('request')->with('v1.2/rune', ['api_key' => 'key'])->once()->andReturn(file_get_contents('tests/Json/Static/rune.euw.json'));
     $api = new Api('key', $this->client);
     $api->setRegion('euw');
     $api->attachStaticData(true);
     $game = $api->currentGame()->currentGame(30447079);
     $participant = $game->participant(28882300);
     $rune = $participant->rune(5253);
     $this->assertTrue($rune->runeStaticData instanceof LeagueWrap\Dto\StaticData\Rune);
     $masteries = $participant->masteries;
     $this->assertTrue($masteries[6111]->masteryStaticData instanceof LeagueWrap\Dto\StaticData\Mastery);
 }
예제 #27
0
<?php

require __DIR__ . '/vendor/autoload.php';
use LeagueWrap\Api;
$myKey = 'YOUR-DEVELOPER-RIOT-API-KEY';
$api = new Api($myKey);
$game = $api->game();
$games = $game->recent(74602);
$matchlistapi = $api->matchlist();
$matchlist = $matchlistapi->matchlist(74602);
$numberOfplayedGames = $matchlist->totalGames;
$roleInGame = $matchlist->match(0)->role;
print_r($matchlist);
예제 #28
0
<?php

require 'vendor/autoload.php';
use LeagueWrap\Api;
$myKey = '59492bcc-6875-4422-81a5-57e2ca069696';
$api = new Api($myKey);
$summoner = $api->summoner();
$wins = 0;
$kills = 0;
$deaths = 0;
$assists = 0;
$dealt = 0;
$taken = 0;
$array = array("kills" => "0", "deaths" => "0", "assists" => "0", "dealt" => "0", "taken" => "0", "wins" => "0");
$data = $_GET['data'];
$summ = $summoner->info($data);
$id = $summ->id;
$matchHistory = $api->matchHistory();
$matches = $matchHistory->history($id);
foreach ($matches as $summary) {
    $temp2 = $summary->participants[0]->stats->kills;
    $kills = $kills + $temp2;
    $temp3 = $summary->participants[0]->stats->deaths;
    $deaths = $deaths + $temp3;
    $temp4 = $summary->participants[0]->stats->assists;
    $assists = $assists + $temp4;
    $temp5 = $summary->participants[0]->stats->totalDamageDealt;
    $dealt = $dealt + $temp5;
    $temp6 = $summary->participants[0]->stats->totalDamageTaken;
    $taken = $taken + $temp6;
    $temp1 = $summary->participants[0]->stats->winner;
예제 #29
0
 /**
  * @expectedException LeagueWrap\Response\Http429
  * @expectedExceptionMessage Rate limit exceeded.
  */
 public function testNormalRateLimitReached()
 {
     $this->client->shouldReceive('baseUrl')->with('https://na.api.pvp.net/api/lol/na/')->once();
     $this->client->shouldReceive('request')->with('v1.2/champion', ['freeToPlay' => 'false', 'api_key' => 'key'])->once()->andReturn(new LeagueWrap\Response('', 429, ['Retry-After' => 123, 'X-Rate-Limit-Type' => 'user']));
     $api = new Api('key', $this->client);
     $champion = $api->champion();
     $champions = $champion->all();
 }
예제 #30
0
 public function testChallenger()
 {
     $this->client->shouldReceive('baseUrl')->once();
     $this->client->shouldReceive('request')->with('na/v2.5/league/challenger', ['api_key' => 'key', 'type' => 'RANKED_SOLO_5x5'])->once()->andReturn(file_get_contents('tests/Json/league.challenger.json'));
     $api = new Api('key', $this->client);
     $league = $api->league()->challenger();
     $this->assertEquals(799, $league->entry('C9 Hai')->leaguePoints);
 }