Skip to content

Support for getting current app #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2020
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
5 changes: 5 additions & 0 deletions src/AsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public function rateLimit(): PromiseInterface
return $this->client->handle(new Command\RateLimitCommand());
}

public function app(): PromiseInterface
{
return $this->client->handle(new Command\AppCommand());
}

public function renderMarkdown(
ReadableStreamInterface $stream,
string $mode = 'markdown',
Expand Down
12 changes: 12 additions & 0 deletions src/CommandBus/Command/AppCommand.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\AppHandler")
*/
final class AppCommand
{
}
41 changes: 41 additions & 0 deletions src/CommandBus/Handler/AppHandler.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\AppCommand;
use ApiClients\Client\Github\Resource\AppInterface;
use ApiClients\Tools\Services\Client\FetchAndHydrateService;
use React\Promise\PromiseInterface;
use function React\Promise\resolve;

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

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

/**
* @param AppCommand $command
* @return PromiseInterface
*/
public function handle(AppCommand $command): PromiseInterface
{
return resolve(
$this->service->fetch(
'app',
'',
AppInterface::HYDRATE_CLASS
)
);
}
}
173 changes: 173 additions & 0 deletions src/Resource/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\Resource;

use ApiClients\Foundation\Hydrator\Annotation\EmptyResource;
use ApiClients\Foundation\Hydrator\Annotation\Nested;
use ApiClients\Foundation\Resource\AbstractResource;
use DateTimeInterface;

/**
* @Nested(
* owner="User"
* )
* @EmptyResource("EmptyApp")
*/
abstract class App extends AbstractResource implements AppInterface
{
/**
* @var int
*/
protected $id;

/**
* @var string
*/
protected $slug;

/**
* @var User
*/
protected $owner;

/**
* @var string
*/
protected $name;

/**
* @var string
*/
protected $description;

/**
* @var string
*/
protected $external_url;

/**
* @var string
*/
protected $html_url;

/**
* @var DateTimeInterface
*/
protected $created_at;

/**
* @var DateTimeInterface
*/
protected $updated_at;

/**
* @var array
*/
protected $permissions;

/**
* @var array
*/
protected $events;

/**
* @var int
*/
protected $installations_count;

/**
* @return int
*/
public function id(): int
{
return $this->id;
}

/**
* @return string
*/
public function slug(): string
{
return $this->slug;
}

/**
* @return User
*/
public function owner(): User
{
return $this->owner;
}

/**
* @return string
*/
public function name(): string
{
return $this->name;
}

/**
* @return string
*/
public function description(): string
{
return $this->description;
}

/**
* @return string
*/
public function externalUrl(): string
{
return $this->external_url;
}

/**
* @return string
*/
public function htmlUrl(): string
{
return $this->html_url;
}

/**
* @return DateTimeInterface
*/
public function createdAt(): DateTimeInterface
{
return $this->created_at;
}

/**
* @return DateTimeInterface
*/
public function updatedAt(): DateTimeInterface
{
return $this->updated_at;
}

/**
* @return array
*/
public function permissions(): array
{
return $this->permissions;
}

/**
* @return array
*/
public function events(): array
{
return $this->events;
}

/**
* @return int
*/
public function installationsCount(): int
{
return $this->installations_count;
}
}
71 changes: 71 additions & 0 deletions src/Resource/AppInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\Resource;

use ApiClients\Foundation\Resource\ResourceInterface;
use DateTimeInterface;

interface AppInterface extends ResourceInterface
{
const HYDRATE_CLASS = 'App';

/**
* @return int
*/
public function id(): int;

/**
* @return string
*/
public function slug(): string;

/**
* @return User
*/
public function owner(): User;

/**
* @return string
*/
public function name(): string;

/**
* @return string
*/
public function description(): string;

/**
* @return string
*/
public function externalUrl(): string;

/**
* @return string
*/
public function htmlUrl(): string;

/**
* @return DateTimeInterface
*/
public function createdAt(): DateTimeInterface;

/**
* @return DateTimeInterface
*/
public function updatedAt(): DateTimeInterface;

/**
* @return array
*/
public function permissions(): array;

/**
* @return array
*/
public function events(): array;

/**
* @return int
*/
public function installationsCount(): int;
}
13 changes: 13 additions & 0 deletions src/Resource/Async/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\Resource\Async;

use ApiClients\Client\Github\Resource\App as BaseApp;

class App extends BaseApp
{
public function refresh(): App
{
throw new \Exception('TODO: create refresh method!');
}
}
9 changes: 9 additions & 0 deletions src/Resource/Async/EmptyApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\Resource\Async;

use ApiClients\Client\Github\Resource\EmptyApp as BaseEmptyApp;

class EmptyApp extends BaseEmptyApp
{
}
Loading