| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,405 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * Class Call |
|
| 7 |
+ * |
|
| 8 |
+ * @package Telnyx |
|
| 9 |
+ */ |
|
| 10 |
+class Call extends ApiResource |
|
| 11 |
+{
|
|
| 12 |
+ const OBJECT_NAME = "call"; |
|
| 13 |
+ const OBJECT_ID = "call_control_id"; |
|
| 14 |
+ |
|
| 15 |
+ use ApiOperations\Create; |
|
| 16 |
+ use ApiOperations\Retrieve; |
|
| 17 |
+ use ApiOperations\NestedResource; // NOTE: This might be unused. |
|
| 18 |
+ |
|
| 19 |
+ /** |
|
| 20 |
+ * Answer an incoming call. |
|
| 21 |
+ * |
|
| 22 |
+ * @param array|null $params |
|
| 23 |
+ * @param array|string|null $options |
|
| 24 |
+ * |
|
| 25 |
+ * @return |
|
| 26 |
+ */ |
|
| 27 |
+ public function answer($params = null, $options = null) |
|
| 28 |
+ {
|
|
| 29 |
+ $url = $this->instanceUrl() . '/actions/answer'; |
|
| 30 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 31 |
+ $this->refreshFrom($response, $opts); |
|
| 32 |
+ return $this; |
|
| 33 |
+ } |
|
| 34 |
+ |
|
| 35 |
+ /** |
|
| 36 |
+ * Bridge two call control calls. |
|
| 37 |
+ * |
|
| 38 |
+ * @param array|null $params |
|
| 39 |
+ * @param array|string|null $options |
|
| 40 |
+ * |
|
| 41 |
+ * @return |
|
| 42 |
+ */ |
|
| 43 |
+ public function bridge($params = null, $options = null) |
|
| 44 |
+ {
|
|
| 45 |
+ $url = $this->instanceUrl() . '/actions/bridge'; |
|
| 46 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 47 |
+ $this->refreshFrom($response, $opts); |
|
| 48 |
+ return $this; |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ /** |
|
| 52 |
+ * @param array|null $params |
|
| 53 |
+ * @param array|string|null $options |
|
| 54 |
+ * |
|
| 55 |
+ * @return Forking start |
|
| 56 |
+ */ |
|
| 57 |
+ public function fork_start($params = null, $options = null) |
|
| 58 |
+ {
|
|
| 59 |
+ $url = $this->instanceUrl() . '/actions/fork_start'; |
|
| 60 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 61 |
+ $this->refreshFrom($response, $opts); |
|
| 62 |
+ return $this; |
|
| 63 |
+ } |
|
| 64 |
+ |
|
| 65 |
+ /** |
|
| 66 |
+ * Stop forking a call. |
|
| 67 |
+ * |
|
| 68 |
+ * @param array|null $params |
|
| 69 |
+ * @param array|string|null $options |
|
| 70 |
+ * |
|
| 71 |
+ * @return |
|
| 72 |
+ */ |
|
| 73 |
+ public function fork_stop($params = null, $options = null) |
|
| 74 |
+ {
|
|
| 75 |
+ $url = $this->instanceUrl() . '/actions/fork_stop'; |
|
| 76 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 77 |
+ $this->refreshFrom($response, $opts); |
|
| 78 |
+ return $this; |
|
| 79 |
+ } |
|
| 80 |
+ |
|
| 81 |
+ /** |
|
| 82 |
+ * Play an audio file on the call until the required DTMF signals are |
|
| 83 |
+ * gathered to build interactive menus. |
|
| 84 |
+ * |
|
| 85 |
+ * @param array|null $params |
|
| 86 |
+ * @param array|string|null $options |
|
| 87 |
+ * |
|
| 88 |
+ * @return |
|
| 89 |
+ */ |
|
| 90 |
+ public function gather_using_audio($params = null, $options = null) |
|
| 91 |
+ {
|
|
| 92 |
+ $url = $this->instanceUrl() . '/actions/gather_using_audio'; |
|
| 93 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 94 |
+ $this->refreshFrom($response, $opts); |
|
| 95 |
+ return $this; |
|
| 96 |
+ } |
|
| 97 |
+ |
|
| 98 |
+ /** |
|
| 99 |
+ * Convert text to speech and play it on the call until the required DTMF |
|
| 100 |
+ * signals are gathered to build interactive menus. |
|
| 101 |
+ * |
|
| 102 |
+ * @param array|null $params |
|
| 103 |
+ * @param array|string|null $options |
|
| 104 |
+ * |
|
| 105 |
+ * @return |
|
| 106 |
+ */ |
|
| 107 |
+ public function gather_using_speak($params = null, $options = null) |
|
| 108 |
+ {
|
|
| 109 |
+ $url = $this->instanceUrl() . '/actions/gather_using_speak'; |
|
| 110 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 111 |
+ $this->refreshFrom($response, $opts); |
|
| 112 |
+ return $this; |
|
| 113 |
+ } |
|
| 114 |
+ |
|
| 115 |
+ /** |
|
| 116 |
+ * Hang up the call. |
|
| 117 |
+ * |
|
| 118 |
+ * @param array|null $params |
|
| 119 |
+ * @param array|string|null $options |
|
| 120 |
+ * |
|
| 121 |
+ * @return |
|
| 122 |
+ */ |
|
| 123 |
+ public function hangup($params = null, $options = null) |
|
| 124 |
+ {
|
|
| 125 |
+ $url = $this->instanceUrl() . '/actions/hangup'; |
|
| 126 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 127 |
+ $this->refreshFrom($response, $opts); |
|
| 128 |
+ return $this; |
|
| 129 |
+ } |
|
| 130 |
+ |
|
| 131 |
+ /** |
|
| 132 |
+ * Play an audio file on the call. If multiple play audio commands are |
|
| 133 |
+ * issued consecutively, the audio files will be placed in a queue awaiting |
|
| 134 |
+ * playback. |
|
| 135 |
+ * |
|
| 136 |
+ * @param array|null $params |
|
| 137 |
+ * @param array|string|null $options |
|
| 138 |
+ * |
|
| 139 |
+ * @return |
|
| 140 |
+ */ |
|
| 141 |
+ public function playback_start($params = null, $options = null) |
|
| 142 |
+ {
|
|
| 143 |
+ $url = $this->instanceUrl() . '/actions/playback_start'; |
|
| 144 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 145 |
+ $this->refreshFrom($response, $opts); |
|
| 146 |
+ return $this; |
|
| 147 |
+ } |
|
| 148 |
+ |
|
| 149 |
+ /** |
|
| 150 |
+ * Stop audio being played on the call. |
|
| 151 |
+ * |
|
| 152 |
+ * @param array|null $params |
|
| 153 |
+ * @param array|string|null $options |
|
| 154 |
+ * |
|
| 155 |
+ * @return |
|
| 156 |
+ */ |
|
| 157 |
+ public function playback_stop($params = null, $options = null) |
|
| 158 |
+ {
|
|
| 159 |
+ $url = $this->instanceUrl() . '/actions/playback_stop'; |
|
| 160 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 161 |
+ $this->refreshFrom($response, $opts); |
|
| 162 |
+ return $this; |
|
| 163 |
+ } |
|
| 164 |
+ |
|
| 165 |
+ /** |
|
| 166 |
+ * Start recording the call. Recording will stop on call hang-up, or can be |
|
| 167 |
+ * initiated via the Stop Recording command. |
|
| 168 |
+ * |
|
| 169 |
+ * @param array|null $params |
|
| 170 |
+ * @param array|string|null $options |
|
| 171 |
+ * |
|
| 172 |
+ * @return |
|
| 173 |
+ */ |
|
| 174 |
+ public function record_start($params = null, $options = null) |
|
| 175 |
+ {
|
|
| 176 |
+ $url = $this->instanceUrl() . '/actions/record_start'; |
|
| 177 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 178 |
+ $this->refreshFrom($response, $opts); |
|
| 179 |
+ return $this; |
|
| 180 |
+ } |
|
| 181 |
+ |
|
| 182 |
+ /** |
|
| 183 |
+ * Stop recording the call. |
|
| 184 |
+ * |
|
| 185 |
+ * @param array|null $params |
|
| 186 |
+ * @param array|string|null $options |
|
| 187 |
+ * |
|
| 188 |
+ * @return |
|
| 189 |
+ */ |
|
| 190 |
+ public function record_stop($params = null, $options = null) |
|
| 191 |
+ {
|
|
| 192 |
+ $url = $this->instanceUrl() . '/actions/record_stop'; |
|
| 193 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 194 |
+ $this->refreshFrom($response, $opts); |
|
| 195 |
+ return $this; |
|
| 196 |
+ } |
|
| 197 |
+ |
|
| 198 |
+ /** |
|
| 199 |
+ * Reject an incoming call. |
|
| 200 |
+ * |
|
| 201 |
+ * @param array|null $params |
|
| 202 |
+ * @param array|string|null $options |
|
| 203 |
+ * |
|
| 204 |
+ * @return |
|
| 205 |
+ */ |
|
| 206 |
+ public function reject($params = null, $options = null) |
|
| 207 |
+ {
|
|
| 208 |
+ $url = $this->instanceUrl() . '/actions/reject'; |
|
| 209 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 210 |
+ $this->refreshFrom($response, $opts); |
|
| 211 |
+ return $this; |
|
| 212 |
+ } |
|
| 213 |
+ |
|
| 214 |
+ /** |
|
| 215 |
+ * Sends DTMF tones from this leg. DTMF tones will be heard by the other |
|
| 216 |
+ * end of the call. |
|
| 217 |
+ * |
|
| 218 |
+ * @param array|null $params |
|
| 219 |
+ * @param array|string|null $options |
|
| 220 |
+ * |
|
| 221 |
+ * @return |
|
| 222 |
+ */ |
|
| 223 |
+ public function send_dtmf($params = null, $options = null) |
|
| 224 |
+ {
|
|
| 225 |
+ $url = $this->instanceUrl() . '/actions/send_dtmf'; |
|
| 226 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 227 |
+ $this->refreshFrom($response, $opts); |
|
| 228 |
+ return $this; |
|
| 229 |
+ } |
|
| 230 |
+ |
|
| 231 |
+ /** |
|
| 232 |
+ * Convert text to speech and play it back on the call. If multiple speak |
|
| 233 |
+ * text commands are issued consecutively, the audio files will be placed |
|
| 234 |
+ * in a queue awaiting playback. |
|
| 235 |
+ * |
|
| 236 |
+ * @param array|null $params |
|
| 237 |
+ * @param array|string|null $options |
|
| 238 |
+ * |
|
| 239 |
+ * @return |
|
| 240 |
+ */ |
|
| 241 |
+ public function speak($params = null, $options = null) |
|
| 242 |
+ {
|
|
| 243 |
+ $url = $this->instanceUrl() . '/actions/speak'; |
|
| 244 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 245 |
+ $this->refreshFrom($response, $opts); |
|
| 246 |
+ return $this; |
|
| 247 |
+ } |
|
| 248 |
+ |
|
| 249 |
+ /** |
|
| 250 |
+ * Transfer a call to a new destination. If the transfer is unsuccessful, |
|
| 251 |
+ * a call.hangup webhook will be sent indicating that the transfer could |
|
| 252 |
+ * not be completed. The original call will remain active and may be issued |
|
| 253 |
+ * additional commands, potentially transfering the call to an alternate |
|
| 254 |
+ * destination. |
|
| 255 |
+ * |
|
| 256 |
+ * @param array|null $params |
|
| 257 |
+ * @param array|string|null $options |
|
| 258 |
+ * |
|
| 259 |
+ * @return |
|
| 260 |
+ */ |
|
| 261 |
+ public function transfer($params = null, $options = null) |
|
| 262 |
+ {
|
|
| 263 |
+ $url = $this->instanceUrl() . '/actions/transfer'; |
|
| 264 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 265 |
+ $this->refreshFrom($response, $opts); |
|
| 266 |
+ return $this; |
|
| 267 |
+ } |
|
| 268 |
+ |
|
| 269 |
+ /** |
|
| 270 |
+ * Start real-time transcription. Transcription will stop on call hang-up, |
|
| 271 |
+ * or can be initiated via the Transcription stop command. |
|
| 272 |
+ * |
|
| 273 |
+ * @param array|null $params |
|
| 274 |
+ * @param array|string|null $options |
|
| 275 |
+ * |
|
| 276 |
+ * @return |
|
| 277 |
+ */ |
|
| 278 |
+ public function transcription_start($params = null, $options = null) |
|
| 279 |
+ {
|
|
| 280 |
+ $url = $this->instanceUrl() . '/actions/transcription_start'; |
|
| 281 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 282 |
+ $this->refreshFrom($response, $opts); |
|
| 283 |
+ return $this; |
|
| 284 |
+ } |
|
| 285 |
+ |
|
| 286 |
+ /** |
|
| 287 |
+ * Stop real-time transcription. |
|
| 288 |
+ * |
|
| 289 |
+ * @param array|null $params |
|
| 290 |
+ * @param array|string|null $options |
|
| 291 |
+ * |
|
| 292 |
+ * @return |
|
| 293 |
+ */ |
|
| 294 |
+ public function transcription_stop($params = null, $options = null) |
|
| 295 |
+ {
|
|
| 296 |
+ $url = $this->instanceUrl() . '/actions/transcription_stop'; |
|
| 297 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 298 |
+ $this->refreshFrom($response, $opts); |
|
| 299 |
+ return $this; |
|
| 300 |
+ } |
|
| 301 |
+ |
|
| 302 |
+ /** |
|
| 303 |
+ * Pause recording the call. Recording can be resumed via Resume recording command. |
|
| 304 |
+ * |
|
| 305 |
+ * @param array|null $params |
|
| 306 |
+ * @param array|string|null $options |
|
| 307 |
+ * |
|
| 308 |
+ * @return |
|
| 309 |
+ */ |
|
| 310 |
+ public function record_pause($params = null, $options = null) |
|
| 311 |
+ {
|
|
| 312 |
+ $url = $this->instanceUrl() . '/actions/record_pause'; |
|
| 313 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 314 |
+ $this->refreshFrom($response, $opts); |
|
| 315 |
+ return $this; |
|
| 316 |
+ } |
|
| 317 |
+ |
|
| 318 |
+ /** |
|
| 319 |
+ * Resume recording the call. |
|
| 320 |
+ * |
|
| 321 |
+ * @param array|null $params |
|
| 322 |
+ * @param array|string|null $options |
|
| 323 |
+ * |
|
| 324 |
+ * @return |
|
| 325 |
+ */ |
|
| 326 |
+ public function record_resume($params = null, $options = null) |
|
| 327 |
+ {
|
|
| 328 |
+ $url = $this->instanceUrl() . '/actions/record_resume'; |
|
| 329 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 330 |
+ $this->refreshFrom($response, $opts); |
|
| 331 |
+ return $this; |
|
| 332 |
+ } |
|
| 333 |
+ |
|
| 334 |
+ /** |
|
| 335 |
+ * Stop current gather. |
|
| 336 |
+ * |
|
| 337 |
+ * @param array|null $params |
|
| 338 |
+ * @param array|string|null $options |
|
| 339 |
+ * |
|
| 340 |
+ * @return |
|
| 341 |
+ */ |
|
| 342 |
+ public function gather_stop($params = null, $options = null) |
|
| 343 |
+ {
|
|
| 344 |
+ $url = $this->instanceUrl() . '/actions/gather_stop'; |
|
| 345 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 346 |
+ $this->refreshFrom($response, $opts); |
|
| 347 |
+ return $this; |
|
| 348 |
+ } |
|
| 349 |
+ |
|
| 350 |
+ /** |
|
| 351 |
+ * SIP Refer a call |
|
| 352 |
+ * |
|
| 353 |
+ * Initiate a SIP Refer on a Call Control call. You can initiate a SIP Refer |
|
| 354 |
+ * at any point in the duration of a call. |
|
| 355 |
+ * |
|
| 356 |
+ * @param array|null $params |
|
| 357 |
+ * @param array|string|null $options |
|
| 358 |
+ * |
|
| 359 |
+ * @return |
|
| 360 |
+ */ |
|
| 361 |
+ public function refer($params = null, $options = null) |
|
| 362 |
+ {
|
|
| 363 |
+ $url = $this->instanceUrl() . '/actions/refer'; |
|
| 364 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 365 |
+ $this->refreshFrom($response, $opts); |
|
| 366 |
+ return $this; |
|
| 367 |
+ } |
|
| 368 |
+ |
|
| 369 |
+ /** |
|
| 370 |
+ * Enqueue call |
|
| 371 |
+ * |
|
| 372 |
+ * Put the call in a queue. |
|
| 373 |
+ * |
|
| 374 |
+ * @param array|null $params |
|
| 375 |
+ * @param array|string|null $options |
|
| 376 |
+ * |
|
| 377 |
+ * @return |
|
| 378 |
+ */ |
|
| 379 |
+ public function enqueue($params = null, $options = null) |
|
| 380 |
+ {
|
|
| 381 |
+ $url = $this->instanceUrl() . '/actions/enqueue'; |
|
| 382 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 383 |
+ $this->refreshFrom($response, $opts); |
|
| 384 |
+ return $this; |
|
| 385 |
+ } |
|
| 386 |
+ |
|
| 387 |
+ /** |
|
| 388 |
+ * Remove call from a queue |
|
| 389 |
+ * |
|
| 390 |
+ * Removes the call from a queue. |
|
| 391 |
+ * |
|
| 392 |
+ * @param array|null $params |
|
| 393 |
+ * @param array|string|null $options |
|
| 394 |
+ * |
|
| 395 |
+ * @return |
|
| 396 |
+ */ |
|
| 397 |
+ public function leave_queue($params = null, $options = null) |
|
| 398 |
+ {
|
|
| 399 |
+ $url = $this->instanceUrl() . '/actions/leave_queue'; |
|
| 400 |
+ list($response, $opts) = $this->_request('post', $url, $params, $options);
|
|
| 401 |
+ $this->refreshFrom($response, $opts); |
|
| 402 |
+ return $this; |
|
| 403 |
+ } |
|
| 404 |
+ |
|
| 405 |
+} |