22
33namespace OpenTok \Util ;
44
5+ use Exception as GlobalException ;
56use OpenTok \Layout ;
67use Firebase \JWT \JWT ;
78use OpenTok \MediaMode ;
1314use Psr \Http \Message \RequestInterface ;
1415use OpenTok \Exception \ArchiveException ;
1516use GuzzleHttp \Exception \ClientException ;
17+ use GuzzleHttp \Exception \GuzzleException ;
1618use GuzzleHttp \Exception \ServerException ;
1719use OpenTok \Exception \BroadcastException ;
1820use GuzzleHttp \Exception \RequestException ;
@@ -475,7 +477,18 @@ public function setStreamClassLists($sessionId, $payload)
475477 }
476478 }
477479
478-
480+ /**
481+ * @param string $sessionId
482+ * @param string $token
483+ * @param string $sipUri
484+ * @param array{secure: bool, headers?: array<string, string>, auth?: array{username: string, password: string}, from?: string, video?: boolean} $options
485+ * @return array{id: string, streamId: string, connectId: string}
486+ * @throws AuthenticationException
487+ * @throws DomainException
488+ * @throws UnexpectedValueException
489+ * @throws GlobalException
490+ * @throws GuzzleException
491+ */
479492 public function dial ($ sessionId , $ token , $ sipUri , $ options )
480493 {
481494 $ body = array (
@@ -487,17 +500,22 @@ public function dial($sessionId, $token, $sipUri, $options)
487500 )
488501 );
489502
490- if (isset ( $ options ) && array_key_exists ('headers ' , $ options ) && count ($ options ['headers ' ]) > 0 ) {
503+ if (array_key_exists ('headers ' , $ options ) && count ($ options ['headers ' ]) > 0 ) {
491504 $ body ['sip ' ]['headers ' ] = $ options ['headers ' ];
492505 }
493506
494- if (isset ( $ options ) && array_key_exists ('auth ' , $ options )) {
507+ if (array_key_exists ('auth ' , $ options )) {
495508 $ body ['sip ' ]['auth ' ] = $ options ['auth ' ];
496509 }
497- if (isset ($ options ) && array_key_exists ('from ' , $ options )) {
510+
511+ if (array_key_exists ('from ' , $ options )) {
498512 $ body ['sip ' ]['from ' ] = $ options ['from ' ];
499513 }
500514
515+ if (array_key_exists ('video ' , $ options )) {
516+ $ body ['sip ' ]['video ' ] = (bool ) $ options ['video ' ];
517+ }
518+
501519 // set up the request
502520 $ request = new Request ('POST ' , '/v2/project/ ' . $ this ->apiKey . '/call ' );
503521
@@ -510,6 +528,7 @@ public function dial($sessionId, $token, $sipUri, $options)
510528 } catch (\Exception $ e ) {
511529 $ this ->handleException ($ e );
512530 }
531+
513532 return $ sipJson ;
514533 }
515534
0 commit comments