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\AddWebHookCommand; |
8
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\AppVeyorCommand; |
9
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand; |
10
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\CommitsCommand; |
11
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\CommunityHealthCommand; |
12
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileUploadCommand; |
13
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ContentsCommand; |
14
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LabelsCommand; |
15
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\LanguagesCommand; |
16
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ReleasesCommand; |
17
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ReplaceTopicsCommand; |
18
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\ScrutinizerCommand; |
19
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\SubscribeCommand; |
20
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\TagsCommand; |
21
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\TravisCommand; |
22
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\UnSubscribeCommand; |
23
|
|
|
use ApiClients\Client\Github\CommandBus\Command\Repository\UpdateSettingsCommand; |
24
|
|
|
use ApiClients\Client\Github\CommandBus\Command\WebHooksCommand; |
25
|
|
|
use ApiClients\Client\Github\Resource\Repository as BaseRepository; |
26
|
|
|
use React\Promise\PromiseInterface; |
27
|
|
|
use React\Stream\ReadableStreamInterface; |
28
|
|
|
use Rx\Observable; |
29
|
|
|
use Rx\ObservableInterface; |
30
|
|
|
use function ApiClients\Tools\Rx\unwrapObservableFromPromise; |
31
|
|
|
|
32
|
|
|
class Repository extends BaseRepository |
33
|
|
|
{ |
34
|
|
|
public function refresh(): PromiseInterface |
35
|
|
|
{ |
36
|
|
|
return $this->handleCommand( |
37
|
|
|
new RefreshCommand($this) |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function branches(): ObservableInterface |
42
|
|
|
{ |
43
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
44
|
|
|
new BranchesCommand($this->fullName()) |
45
|
|
|
)); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function commits(): ObservableInterface |
49
|
|
|
{ |
50
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
51
|
|
|
new CommitsCommand($this->fullName()) |
52
|
|
|
)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function labels(): ObservableInterface |
56
|
|
|
{ |
57
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
58
|
|
|
new LabelsCommand($this->fullName()) |
59
|
|
|
)); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function addLabel(string $name, string $colour): PromiseInterface |
63
|
|
|
{ |
64
|
|
|
return $this->handleCommand( |
65
|
|
|
new AddLabelCommand($this->fullName(), $name, $colour) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function contents(string $path = '/'): Observable |
70
|
|
|
{ |
71
|
|
|
return unwrapObservableFromPromise( |
72
|
|
|
$this->handleCommand( |
73
|
|
|
new ContentsCommand($this->fullName(), $path) |
74
|
|
|
) |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function communityHealth(): PromiseInterface |
79
|
|
|
{ |
80
|
|
|
return $this->handleCommand( |
81
|
|
|
new CommunityHealthCommand($this->fullName()) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function tags(): ObservableInterface |
86
|
|
|
{ |
87
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
88
|
|
|
new TagsCommand($this->fullName()) |
89
|
|
|
)); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function releases(): ObservableInterface |
93
|
|
|
{ |
94
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
95
|
|
|
new ReleasesCommand($this->fullName()) |
96
|
|
|
)); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function languages(): PromiseInterface |
100
|
|
|
{ |
101
|
|
|
return $this->handleCommand( |
102
|
|
|
new LanguagesCommand($this->fullName()) |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function webHooks(): ObservableInterface |
107
|
|
|
{ |
108
|
|
|
return unwrapObservableFromPromise($this->handleCommand( |
109
|
|
|
new WebHooksCommand($this->fullName(), 'repos') |
110
|
|
|
)); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function addWebHook( |
114
|
|
|
string $name, |
115
|
|
|
array $config, |
116
|
|
|
array $events, |
117
|
|
|
bool $active |
118
|
|
|
): PromiseInterface { |
119
|
|
|
return $this->handleCommand( |
120
|
|
|
new AddWebHookCommand( |
121
|
|
|
$this->fullName(), |
122
|
|
|
$name, |
123
|
|
|
$config, |
124
|
|
|
$events, |
125
|
|
|
$active |
126
|
|
|
) |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function addFile( |
131
|
|
|
string $filename, |
132
|
|
|
ReadableStreamInterface $stream, |
133
|
|
|
string $commitMessage = '', |
134
|
|
|
string $branch = '' |
135
|
|
|
): PromiseInterface { |
136
|
|
|
if ($commitMessage === '') { |
137
|
|
|
$commitMessage = 'Update ' . $this->name; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
return $this->handleCommand(new FileUploadCommand( |
141
|
|
|
$this->full_name, |
142
|
|
|
$commitMessage, |
143
|
|
|
'/repos/' . $this->full_name . '/contents/' . $filename, |
144
|
|
|
'', |
145
|
|
|
$branch, |
146
|
|
|
$stream |
147
|
|
|
)); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function subscribe(bool $subscribed = true, bool $ignored = false): PromiseInterface |
151
|
|
|
{ |
152
|
|
|
return $this->handleCommand( |
153
|
|
|
new SubscribeCommand($this->fullName(), $subscribed, $ignored) |
154
|
|
|
); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function unSubscribe(): PromiseInterface |
158
|
|
|
{ |
159
|
|
|
return $this->handleCommand( |
160
|
|
|
new UnSubscribeCommand($this->fullName()) |
161
|
|
|
); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function replaceTopics(string ...$topics): PromiseInterface |
165
|
|
|
{ |
166
|
|
|
return $this->handleCommand( |
167
|
|
|
new ReplaceTopicsCommand($this->fullName(), ...$topics) |
168
|
|
|
); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function travisRepository(): PromiseInterface |
172
|
|
|
{ |
173
|
|
|
return $this->handleCommand(new TravisCommand($this->fullName())); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function appVeyorRepository(): PromiseInterface |
177
|
|
|
{ |
178
|
|
|
return $this->handleCommand(new AppVeyorCommand($this->fullName())); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function scrutinizerRepository(): PromiseInterface |
182
|
|
|
{ |
183
|
|
|
return $this->handleCommand(new ScrutinizerCommand(...explode('/', $this->fullName()))); |
|
|
|
|
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function updateSettings(array $settings): PromiseInterface |
187
|
|
|
{ |
188
|
|
|
if (!isset($settings['name'])) { |
189
|
|
|
$settings['name'] = $this->name(); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
return $this->handleCommand(new UpdateSettingsCommand($this->fullName(), $settings)); |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|
This check looks for function calls that miss required arguments.