Coder Social home page Coder Social logo

php-riotapi-request's Introduction

riotapi-request

Features

  • DTO Support
  • Batch calls (async request using guzzlehttp promise)
    • You can control concurrency sessions

Installation

composer require opgg/riotquest

Example

use RiotQuest\Dto\LolStaticData\Champion\ChampionListDto;
use RiotQuest\Dto\Summoner\SummonerDto;
use RiotQuest\RequestMethod;

function riotApi() {
    return new RiotQuest\AsyncRiotAPI('api_key');
}

/** @var SummonerDto $summonerDto */
$summonerDto = $this->riotApi()->call(new RequestMethod\Summoner\SummonerByName(OPServer::getCurrentPlatform(), "kargnas"));
$this->assertTrue($summonerDto instanceof SummonerDto);
$this->assertTrue($summonerDto->revisionDate instanceof \RiotQuest\Dto\DateTime);

$this->riotApi()
    ->add(new RequestMethod\Runes\RunesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id),
        function (\RiotQuest\Dto\Runes\RunePagesDto $runePagesDto) use ($summonerDto) {
            var_dump($runePagesDto->summonerId === $summonerDto->id);
            var_dump(array_first($runePagesDto->pages) instanceof \RiotQuest\Dto\Runes\RunePageDto);
        })
    ->add(new RequestMethod\Masteries\MasteriesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id),
        function (\RiotQuest\Dto\Masteries\MasteryPagesDto $masteryPagesDto) use ($summonerDto) {
            var_dump($masteryPagesDto->summonerId === $summonerDto->id);
            var_dump(array_first($masteryPagesDto->pages) instanceof \RiotQuest\Dto\Masteries\MasteryPageDto);
        })
    ->add(new RequestMethod\Match\MatchesByAccount(OPServer::getCurrentPlatform(), $summonerDto->accountId),
        function (\RiotQuest\Dto\Match\MatchlistDto $matchlist) {
            /** @var \RiotQuest\Dto\Match\MatchDto $match */
            $match = $this->riotApi()->call(new RequestMethod\Match\MatchById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId));
            var_dump($match instanceof \RiotQuest\Dto\Match\MatchDto);

            /** @var \RiotQuest\Dto\Match\Timeline\MatchTimelineDto $timeline */
            $timeline = $this->riotApi()->call(new RequestMethod\Match\TimelineById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId));
            var_dump($timeline instanceof \RiotQuest\Dto\Match\Timeline\MatchTimelineDto);
            var_dump($timeline->frames[0] instanceof \RiotQuest\Dto\Match\Timeline\MatchFrameDto);
        })
    ->exec();

TODO

  • Rate limit
  • PSR-6

php-riotapi-request's People

Contributors

kargnas avatar opgg-maxime avatar devimop avatar opgg-seokjunchoi avatar hellokiseokopgg avatar other-yuka avatar wildphs avatar

Stargazers

 avatar DarkIntaqt avatar Zeke Witter avatar Amar Gandhi avatar  avatar Initred avatar  avatar Maria Paula Sabogal Motta avatar PlanetBear avatar byzz avatar Danillo avatar 俞建安 avatar Matheus Gonçalves avatar  avatar  avatar kiseok kim avatar  avatar

Watchers

James Cloos avatar kiseok kim avatar  avatar Hello!! avatar Taesu Hyeon avatar EO avatar RIchg0ld avatar  avatar  avatar  avatar Initred avatar  avatar

php-riotapi-request's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.