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\CommitsCommand; |
9
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand; |
10
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand; |
11
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand; |
12
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand; |
13
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand; |
14
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand; |
15
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand; |
16
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand; |
17
|
|
|
use ApiClients\Client\Github\Resource\Repository as BaseRepository; |
18
|
|
|
use React\Promise\PromiseInterface; |
19
|
|
|
use Rx\Observable; |
20
|
|
|
use Rx\ObservableInterface; |
21
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
22
|
|
|
|
23
|
|
|
class Repository extends BaseRepository |
24
|
|
|
{ |
25
|
|
|
public function refresh(): PromiseInterface |
26
|
|
|
{ |
27
|
|
|
return $this->handleCommand( |
28
|
|
|
new RefreshCommand($this) |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function branches(): ObservableInterface |
33
|
|
|
{ |
34
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
35
|
|
|
new BranchesCommand($this->fullName()) |
36
|
|
|
)); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function commits(): ObservableInterface |
40
|
|
|
{ |
41
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
42
|
|
|
new CommitsCommand($this->fullName()) |
43
|
|
|
)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function labels(): ObservableInterface |
47
|
|
|
{ |
48
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
49
|
|
|
new LabelsCommand($this->fullName()) |
50
|
|
|
)); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function addLabel(string $name, string $colour): PromiseInterface |
54
|
|
|
{ |
55
|
|
|
return $this->handleCommand( |
56
|
|
|
new AddLabelCommand($this->fullName(), $name, $colour) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function contents(string $path = '/'): Observable |
61
|
|
|
{ |
62
|
|
|
return unwrapObservableFromPromise( |
63
|
|
|
$this->handleCommand( |
64
|
|
|
new ContentsCommand($this->fullName(), $path) |
65
|
|
|
) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function communityHealth(): PromiseInterface |
70
|
|
|
{ |
71
|
|
|
return $this->handleCommand( |
72
|
|
|
new CommunityHealthCommand($this->fullName()) |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function tags(): ObservableInterface |
77
|
|
|
{ |
78
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
79
|
|
|
new TagsCommand($this->fullName()) |
80
|
|
|
)); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function releases(): ObservableInterface |
84
|
|
|
{ |
85
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
86
|
|
|
new ReleasesCommand($this->fullName()) |
87
|
|
|
)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function languages(): PromiseInterface |
91
|
|
|
{ |
92
|
|
|
return $this->handleCommand( |
93
|
|
|
new LanguagesCommand($this->fullName()) |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface |
98
|
|
|
{ |
99
|
|
|
return $this->handleCommand( |
100
|
|
|
new SubscribeCommand($this->fullName(), $subscribed, $ignored) |
101
|
|
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function unSubscribe(): PromiseInterface |
105
|
|
|
{ |
106
|
|
|
return $this->handleCommand( |
107
|
|
|
new UnSubscribeCommand($this->fullName()) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|