|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright 2014 Brian Smith <[email protected]>. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace phparia\Api; |
|
20
|
|
|
|
|
21
|
|
|
use GuzzleHttp\Exception\RequestException; |
|
22
|
|
|
use phparia\Client\AriClientAware; |
|
23
|
|
|
use phparia\Exception\ConflictException; |
|
24
|
|
|
use phparia\Exception\NotFoundException; |
|
25
|
|
|
use phparia\Resources\LiveRecording; |
|
26
|
|
|
use phparia\Resources\StoredRecording; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Recordings API |
|
30
|
|
|
* |
|
31
|
|
|
* @author Brian Smith <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class Recordings extends AriClientAware |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* List recordings that are complete. |
|
37
|
|
|
* |
|
38
|
|
|
* @return StoredRecording[] |
|
39
|
|
|
*/ |
|
40
|
1 |
View Code Duplication |
public function getRecordings() |
|
41
|
|
|
{ |
|
42
|
1 |
|
$uri = 'recordings/stored'; |
|
43
|
1 |
|
$response = $this->client->getEndpoint()->get($uri); |
|
44
|
|
|
|
|
45
|
|
|
$recordings = []; |
|
46
|
|
|
foreach (\GuzzleHttp\json_decode($response->getBody()) as $recording) { |
|
47
|
|
|
$recordings[] = new StoredRecording($recording); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return $recordings; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get a stored recording's details. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $recordingName The name of the recording |
|
57
|
|
|
* @return StoredRecording |
|
58
|
|
|
* @throws NotFoundException |
|
59
|
|
|
*/ |
|
60
|
1 |
View Code Duplication |
public function getRecording($recordingName) |
|
61
|
|
|
{ |
|
62
|
1 |
|
$uri = "recordings/stored/$recordingName"; |
|
63
|
|
|
try { |
|
64
|
1 |
|
$response = $this->client->getEndpoint()->get($uri); |
|
65
|
1 |
|
} catch (RequestException $e) { |
|
66
|
1 |
|
$this->processRequestException($e); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return new StoredRecording(\GuzzleHttp\json_decode($response->getBody())); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Delete a stored recording. |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $recordingName The name of the recording |
|
76
|
|
|
* @return StoredRecording |
|
77
|
|
|
* @throws NotFoundException |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function deleteRecording($recordingName) |
|
80
|
|
|
{ |
|
81
|
1 |
|
$uri = "recordings/stored/$recordingName"; |
|
82
|
|
|
try { |
|
83
|
1 |
|
$this->client->getEndpoint()->delete($uri); |
|
84
|
1 |
|
} catch (RequestException $e) { |
|
85
|
1 |
|
$this->processRequestException($e); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Copy a stored recording. |
|
91
|
|
|
* |
|
92
|
|
|
* @param string $recordingName The name of the recording to copy |
|
93
|
|
|
* @param string $destinationRecordingName (required) The destination name of the recording |
|
94
|
|
|
* @return StoredRecording |
|
95
|
|
|
* @throws ConflictException |
|
96
|
|
|
* @throws NotFoundException |
|
97
|
|
|
*/ |
|
98
|
1 |
|
public function copyRecording($recordingName, $destinationRecordingName) |
|
99
|
|
|
{ |
|
100
|
1 |
|
$uri = "recordings/stored/$recordingName/copy"; |
|
101
|
|
|
try { |
|
102
|
1 |
|
$response = $this->client->getEndpoint()->post($uri, [ |
|
103
|
|
|
'form_params' => [ |
|
104
|
1 |
|
'destinationRecordingName' => $destinationRecordingName, |
|
105
|
|
|
] |
|
106
|
1 |
|
]); |
|
107
|
1 |
|
} catch (RequestException $e) { |
|
108
|
1 |
|
$this->processRequestException($e); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
return new StoredRecording(\GuzzleHttp\json_decode($response->getBody())); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Get live recording |
|
116
|
|
|
* |
|
117
|
|
|
* @param string $recordingName The name of the recording |
|
118
|
|
|
* @return LiveRecording |
|
119
|
|
|
* @throws NotFoundException |
|
120
|
|
|
*/ |
|
121
|
|
View Code Duplication |
public function getLiveRecording($recordingName) |
|
122
|
|
|
{ |
|
123
|
|
|
$uri = "recordings/live/$recordingName"; |
|
124
|
|
|
try { |
|
125
|
|
|
$response = $this->client->getEndpoint()->get($uri); |
|
126
|
|
|
} catch (RequestException $e) { |
|
127
|
|
|
$this->processRequestException($e); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
return new LiveRecording($this->client, \GuzzleHttp\json_decode($response->getBody())); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Stop a live recording and discard it. |
|
135
|
|
|
* |
|
136
|
|
|
* @param string $recordingName The name of the recording |
|
137
|
|
|
* @throws NotFoundException |
|
138
|
|
|
*/ |
|
139
|
|
|
public function deleteLiveRecording($recordingName) |
|
140
|
|
|
{ |
|
141
|
|
|
$uri = "recordings/live/$recordingName"; |
|
142
|
|
|
try { |
|
143
|
|
|
$this->client->getEndpoint()->delete($uri); |
|
144
|
|
|
} catch (RequestException $e) { |
|
145
|
|
|
$this->processRequestException($e); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Stop a live recording and discard it. |
|
151
|
|
|
* |
|
152
|
|
|
* @param string $recordingName The name of the recording |
|
153
|
|
|
* @throws NotFoundException |
|
154
|
|
|
*/ |
|
155
|
|
|
public function cancelLiveRecording($recordingName) |
|
156
|
|
|
{ |
|
157
|
|
|
$uri = "recordings/live/$recordingName"; |
|
158
|
|
|
try { |
|
159
|
|
|
$this->client->getEndpoint()->delete($uri); |
|
160
|
|
|
} catch (RequestException $e) { |
|
161
|
|
|
$this->processRequestException($e); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Stop a live recording and store it. |
|
167
|
|
|
* |
|
168
|
|
|
* @param string $recordingName The name of the recording |
|
169
|
|
|
* @throws NotFoundException |
|
170
|
|
|
*/ |
|
171
|
|
|
public function stopLiveRecording($recordingName) |
|
172
|
|
|
{ |
|
173
|
|
|
$uri = "recordings/live/$recordingName/stop"; |
|
174
|
|
|
try { |
|
175
|
|
|
$this->client->getEndpoint()->post($uri); |
|
176
|
|
|
} catch (RequestException $e) { |
|
177
|
|
|
$this->processRequestException($e); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Pause a live recording. Pausing a recording suspends silence detection, which will be restarted |
|
183
|
|
|
* when the recording is unpaused. Paused time is not included in the accounting for |
|
184
|
|
|
* maxDurationSeconds. |
|
185
|
|
|
* |
|
186
|
|
|
* @param string $recordingName The name of the recording |
|
187
|
|
|
* @throws ConflictException |
|
188
|
|
|
* @throws NotFoundException |
|
189
|
|
|
*/ |
|
190
|
|
|
public function pauseLiveRecording($recordingName) |
|
191
|
|
|
{ |
|
192
|
|
|
$uri = "recordings/live/$recordingName/pause"; |
|
193
|
|
|
try { |
|
194
|
|
|
$this->client->getEndpoint()->post($uri); |
|
195
|
|
|
} catch (RequestException $e) { |
|
196
|
|
|
$this->processRequestException($e); |
|
197
|
|
|
} |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Unause a live recording. |
|
202
|
|
|
* |
|
203
|
|
|
* @param string $recordingName The name of the recording |
|
204
|
|
|
* @throws ConflictException |
|
205
|
|
|
* @throws NotFoundException |
|
206
|
|
|
*/ |
|
207
|
|
|
public function unpauseLiveRecording($recordingName) |
|
208
|
|
|
{ |
|
209
|
|
|
$uri = "recordings/live/$recordingName/pause"; |
|
210
|
|
|
try { |
|
211
|
|
|
$this->client->getEndpoint()->delete($uri); |
|
212
|
|
|
} catch (RequestException $e) { |
|
213
|
|
|
$this->processRequestException($e); |
|
214
|
|
|
} |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Mute a live recording. Muting a recording suspends silence detection, which will be restarted when the recording is unmuted. |
|
219
|
|
|
* |
|
220
|
|
|
* @param string $recordingName The name of the recording |
|
221
|
|
|
* @throws ConflictException |
|
222
|
|
|
* @throws NotFoundException |
|
223
|
|
|
*/ |
|
224
|
|
|
public function muteLiveRecording($recordingName) |
|
225
|
|
|
{ |
|
226
|
|
|
$uri = "recordings/live/$recordingName/mute"; |
|
227
|
|
|
try { |
|
228
|
|
|
$this->client->getEndpoint()->post($uri); |
|
229
|
|
|
} catch (RequestException $e) { |
|
230
|
|
|
$this->processRequestException($e); |
|
231
|
|
|
} |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* Unmute a live recording. |
|
236
|
|
|
* |
|
237
|
|
|
* @param string $recordingName The name of the recording |
|
238
|
|
|
* @throws ConflictException |
|
239
|
|
|
* @throws NotFoundException |
|
240
|
|
|
*/ |
|
241
|
|
|
public function unmuteLiveRecording($recordingName) |
|
242
|
|
|
{ |
|
243
|
|
|
$uri = "recordings/live/$recordingName/mute"; |
|
244
|
|
|
try { |
|
245
|
|
|
$this->client->getEndpoint()->delete($uri); |
|
246
|
|
|
} catch (RequestException $e) { |
|
247
|
|
|
$this->processRequestException($e); |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
} |
|
251
|
|
|
|