-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from php-api-clients/app
Support for getting current app
- Loading branch information
Showing
11 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |
Oops, something went wrong.