From e63466007aea9d34bfabbaa4092cf8a42bf93cf0 Mon Sep 17 00:00:00 2001 From: Cameron Koegel <53310569+ckoegel@users.noreply.github.com> Date: Mon, 21 Mar 2022 13:41:58 -0400 Subject: [PATCH] DX-2471 Add `priority` to `createCallRequest` (#48) * DX-2471 Add `priority` to `createCallRequest` * assertTrue * actually set priority * add sleep --- src/Voice/Models/CreateCallRequest.php | 10 +++++++++- src/Voice/Models/CreateCallResponse.php | 10 +++++++++- tests/ApiTest.php | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Voice/Models/CreateCallRequest.php b/src/Voice/Models/CreateCallRequest.php index fe85806..c58f660 100644 --- a/src/Voice/Models/CreateCallRequest.php +++ b/src/Voice/Models/CreateCallRequest.php @@ -127,12 +127,18 @@ class CreateCallRequest implements \JsonSerializable */ public $machineDetection; + /** + * The priority of this call over other calls from + * @var int $priority public property + */ + public $priority; + /** * Constructor to set initial or default values of member properties */ public function __construct() { - if (18 == func_num_args()) { + if (19 == func_num_args()) { $this->from = func_get_arg(0); $this->to = func_get_arg(1); $this->uui = func_get_arg(2); @@ -151,6 +157,7 @@ public function __construct() $this->tag = func_get_arg(15); $this->applicationId = func_get_arg(16); $this->machineDetection = func_get_arg(17); + $this->priority = func_get_arg(18); } } @@ -178,6 +185,7 @@ public function jsonSerialize() $json['tag'] = $this->tag; $json['applicationId'] = $this->applicationId; $json['machineDetection'] = $this->machineDetection; + $json['priority'] = $this->priority; return array_filter($json); } diff --git a/src/Voice/Models/CreateCallResponse.php b/src/Voice/Models/CreateCallResponse.php index 99d6c8d..3671e9c 100644 --- a/src/Voice/Models/CreateCallResponse.php +++ b/src/Voice/Models/CreateCallResponse.php @@ -144,12 +144,18 @@ class CreateCallResponse implements \JsonSerializable */ public $tag; + /** + * The priority of this call over other calls from + * @var int $priority public property + */ + public $priority; + /** * Constructor to set initial or default values of member properties */ public function __construct() { - if (20 == func_num_args()) { + if (21 == func_num_args()) { $this->accountId = func_get_arg(0); $this->callId = func_get_arg(1); $this->applicationId = func_get_arg(2); @@ -170,6 +176,7 @@ public function __construct() $this->fallbackUsername = func_get_arg(17); $this->fallbackPassword = func_get_arg(18); $this->tag = func_get_arg(19); + $this->priority = func_get_arg(20); } } @@ -201,6 +208,7 @@ public function jsonSerialize() $json['fallbackUsername'] = $this->fallbackUsername; $json['fallbackPassword'] = $this->fallbackPassword; $json['tag'] = $this->tag; + $json['priority'] = $this->priority; return array_filter($json); } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 0f0af7a..7b99400 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -85,6 +85,8 @@ public function testCreateCallAndGetCallState() { $response = $this->bandwidthClient->getVoice()->getClient()->createCall(getenv("BW_ACCOUNT_ID"), $body); $callId = $response->getResult()->callId; $this->assertTrue(strlen($callId) > 0); + + sleep(1); //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); @@ -113,11 +115,26 @@ public function testCreateCallWithAmdAndGetCallState() { $callId = $response->getResult()->callId; $this->assertTrue(strlen($callId) > 0); + sleep(1); + //get phone call information $response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId); $this->assertTrue(strlen($response->getResult()->state) > 0); } + public function testCreateCallWithPriority() { + $body = new BandwidthLib\Voice\Models\CreateCallRequest(); + $body->from = getenv("BW_NUMBER"); + $body->to = getenv("USER_NUMBER"); + $body->applicationId = getenv("BW_VOICE_APPLICATION_ID"); + $body->answerUrl = getenv("BASE_CALLBACK_URL"); + $body->priority = 1; + $response = $this->bandwidthClient->getVoice()->getClient()->createCall(getenv("BW_ACCOUNT_ID"), $body); + $callId = $response->getResult()->callId; + $this->assertTrue(strlen($callId) > 0); + $this->assertTrue($response->getResult()->priority == $body->priority); + } + public function testCreateCallInvalidPhoneNumber() { $body = new BandwidthLib\Voice\Models\CreateCallRequest(); $body->from = getenv("BW_NUMBER");