1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace ApiClients\Client\Github\Resource\Async; |
4
|
|
|
|
5
|
|
|
use ApiClients\Client\Github\CommandBus\Command\RefreshCommand; |
6
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\AddLabelCommand; |
7
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand; |
8
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand; |
9
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand; |
10
|
|
|
use ApiClients\Client\Github\Resource\Repository as BaseRepository; |
11
|
|
|
use ApiClients\Foundation\Transport\Response; |
12
|
|
|
use React\Promise\PromiseInterface; |
13
|
|
|
use Rx\Observable; |
14
|
|
|
use Rx\ObservableInterface; |
15
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
16
|
|
|
use function React\Promise\resolve; |
17
|
|
|
|
18
|
|
|
class Repository extends BaseRepository |
19
|
|
|
{ |
20
|
|
|
public function refresh() : PromiseInterface |
21
|
|
|
{ |
22
|
|
|
return $this->handleCommand( |
23
|
|
|
new RefreshCommand($this) |
24
|
|
|
); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function branches(): ObservableInterface |
28
|
|
|
{ |
29
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
30
|
|
|
new BranchesCommand($this->fullName()) |
31
|
|
|
)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function labels(): ObservableInterface |
35
|
|
|
{ |
36
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
37
|
|
|
new LabelsCommand($this->fullName()) |
38
|
|
|
)); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function addLabel(string $name, string $colour): PromiseInterface |
42
|
|
|
{ |
43
|
|
|
return $this->handleCommand( |
44
|
|
|
new AddLabelCommand($this->fullName(), $name, $colour) |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function contents(): Observable |
49
|
|
|
{ |
50
|
|
|
return unwrapObservableFromPromise( |
51
|
|
|
$this->handleCommand( |
52
|
|
|
new ContentsCommand($this->fullName()) |
53
|
|
|
) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|