Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ environment:
## Cache composer, chocolatey and php bits
cache:
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
- composer.phar
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
- c:\tools\php -> .appveyor.yml

## Set up environment varriables
init:
Expand Down
104 changes: 52 additions & 52 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions examples/rate-limit-state-async.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use ApiClients\Client\Github\AsyncClient;
use ApiClients\Client\Github\Resource\Async\RateLimit;
use React\EventLoop\Factory;
use function ApiClients\Foundation\resource_pretty_print;

require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';

$loop = Factory::create();
$client = AsyncClient::create($loop, require 'resolve_token.php');

$client->rateLimit()->done(function (RateLimit $rateLimit) {
resource_pretty_print($rateLimit);
}, 'display_throwable');

$loop->run();

displayState($client->getRateLimitState());
5 changes: 5 additions & 0 deletions src/AsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,9 @@ public function getRateLimitState(): RateLimitState
{
return clone $this->rateLimitState;
}

public function rateLimit(): PromiseInterface
{
return $this->client->handle(new Command\RateLimitCommand());
}
}
2 changes: 2 additions & 0 deletions src/AsyncClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public function myOrganizations(): Observable;
public function licenses(): Observable;

public function getRateLimitState(): RateLimitState;

public function rateLimit(): PromiseInterface;
}
12 changes: 12 additions & 0 deletions src/CommandBus/Command/RateLimitCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\CommandBus\Command;

use WyriHaximus\Tactician\CommandHandler\Annotations\Handler;

/**
* @Handler("ApiClients\Client\Github\CommandBus\Handler\RateLimitHandler")
*/
final class RateLimitCommand
{
}
41 changes: 41 additions & 0 deletions src/CommandBus/Handler/RateLimitHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\CommandBus\Handler;

use ApiClients\Client\Github\CommandBus\Command\RateLimitCommand;
use ApiClients\Client\Github\Resource\RateLimitInterface;
use ApiClients\Tools\Services\Client\FetchAndHydrateService;
use React\Promise\PromiseInterface;
use function React\Promise\resolve;

final class RateLimitHandler
{
/**
* @var FetchAndHydrateService
*/
private $service;

/**
* RateLimitHandler constructor.
* @param FetchAndHydrateService $service
*/
public function __construct(FetchAndHydrateService $service)
{
$this->service = $service;
}

/**
* @param RateLimitCommand $command
* @return PromiseInterface
*/
public function handle(RateLimitCommand $command): PromiseInterface
{
return resolve(
$this->service->fetch(
'rate_limit',
'',
RateLimitInterface::HYDRATE_CLASS
)
);
}
}
Loading