1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace ApiClients\Client\Github\Resource\Async; |
4
|
|
|
|
5
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Organization\AddWebHookCommand; |
6
|
|
|
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand; |
7
|
|
|
use ApiClients\Client\Github\CommandBus\Command\User\OrganizationsCommand; |
8
|
|
|
use ApiClients\Client\Github\CommandBus\Command\User\RepositoriesCommand; |
9
|
|
|
use ApiClients\Client\Github\CommandBus\Command\User\RepositoryCommand; |
10
|
|
|
use ApiClients\Client\Github\CommandBus\Command\WebHooksCommand; |
11
|
|
|
use ApiClients\Client\Github\Resource\Organization as BaseOrganization; |
12
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
13
|
|
|
use React\Promise\PromiseInterface; |
14
|
|
|
use Rx\ObservableInterface; |
15
|
|
|
|
16
|
|
|
class Organization extends BaseOrganization |
17
|
|
|
{ |
18
|
|
|
public function refresh(): PromiseInterface |
19
|
|
|
{ |
20
|
|
|
return $this->handleCommand( |
21
|
|
|
new RefreshCommand($this) |
22
|
|
|
); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function repository(string $repository): PromiseInterface |
26
|
|
|
{ |
27
|
|
|
return $this->handleCommand( |
28
|
|
|
new RepositoryCommand($this->login(), $repository) |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function repositories(): ObservableInterface |
33
|
|
|
{ |
34
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
35
|
|
|
new RepositoriesCommand($this->login()) |
36
|
|
|
)); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function organizations(): ObservableInterface |
40
|
|
|
{ |
41
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
42
|
|
|
new OrganizationsCommand($this->login()) |
43
|
|
|
)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function addWebHook( |
47
|
|
|
string $name, |
48
|
|
|
array $config, |
49
|
|
|
array $events, |
50
|
|
|
bool $active |
51
|
|
|
): PromiseInterface { |
52
|
|
|
return $this->handleCommand( |
53
|
|
|
new AddWebHookCommand( |
54
|
|
|
$this->login(), |
55
|
|
|
$name, |
56
|
|
|
$config, |
57
|
|
|
$events, |
58
|
|
|
$active |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function webHooks(): ObservableInterface |
64
|
|
|
{ |
65
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
66
|
|
|
new WebHooksCommand($this->login(), 'orgs') |
67
|
|
|
)); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|