Skip to content

Commit e634660

Browse files
authored
DX-2471 Add priority to createCallRequest (#48)
* DX-2471 Add `priority` to `createCallRequest` * assertTrue * actually set priority * add sleep
1 parent 069b0d5 commit e634660

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/Voice/Models/CreateCallRequest.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,18 @@ class CreateCallRequest implements \JsonSerializable
127127
*/
128128
public $machineDetection;
129129

130+
/**
131+
* The priority of this call over other calls from
132+
* @var int $priority public property
133+
*/
134+
public $priority;
135+
130136
/**
131137
* Constructor to set initial or default values of member properties
132138
*/
133139
public function __construct()
134140
{
135-
if (18 == func_num_args()) {
141+
if (19 == func_num_args()) {
136142
$this->from = func_get_arg(0);
137143
$this->to = func_get_arg(1);
138144
$this->uui = func_get_arg(2);
@@ -151,6 +157,7 @@ public function __construct()
151157
$this->tag = func_get_arg(15);
152158
$this->applicationId = func_get_arg(16);
153159
$this->machineDetection = func_get_arg(17);
160+
$this->priority = func_get_arg(18);
154161
}
155162
}
156163

@@ -178,6 +185,7 @@ public function jsonSerialize()
178185
$json['tag'] = $this->tag;
179186
$json['applicationId'] = $this->applicationId;
180187
$json['machineDetection'] = $this->machineDetection;
188+
$json['priority'] = $this->priority;
181189

182190
return array_filter($json);
183191
}

src/Voice/Models/CreateCallResponse.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ class CreateCallResponse implements \JsonSerializable
144144
*/
145145
public $tag;
146146

147+
/**
148+
* The priority of this call over other calls from
149+
* @var int $priority public property
150+
*/
151+
public $priority;
152+
147153
/**
148154
* Constructor to set initial or default values of member properties
149155
*/
150156
public function __construct()
151157
{
152-
if (20 == func_num_args()) {
158+
if (21 == func_num_args()) {
153159
$this->accountId = func_get_arg(0);
154160
$this->callId = func_get_arg(1);
155161
$this->applicationId = func_get_arg(2);
@@ -170,6 +176,7 @@ public function __construct()
170176
$this->fallbackUsername = func_get_arg(17);
171177
$this->fallbackPassword = func_get_arg(18);
172178
$this->tag = func_get_arg(19);
179+
$this->priority = func_get_arg(20);
173180
}
174181
}
175182

@@ -201,6 +208,7 @@ public function jsonSerialize()
201208
$json['fallbackUsername'] = $this->fallbackUsername;
202209
$json['fallbackPassword'] = $this->fallbackPassword;
203210
$json['tag'] = $this->tag;
211+
$json['priority'] = $this->priority;
204212

205213
return array_filter($json);
206214
}

tests/ApiTest.php

+17
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function testCreateCallAndGetCallState() {
8585
$response = $this->bandwidthClient->getVoice()->getClient()->createCall(getenv("BW_ACCOUNT_ID"), $body);
8686
$callId = $response->getResult()->callId;
8787
$this->assertTrue(strlen($callId) > 0);
88+
89+
sleep(1);
8890

8991
//get phone call information
9092
$response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId);
@@ -113,11 +115,26 @@ public function testCreateCallWithAmdAndGetCallState() {
113115
$callId = $response->getResult()->callId;
114116
$this->assertTrue(strlen($callId) > 0);
115117

118+
sleep(1);
119+
116120
//get phone call information
117121
$response = $this->bandwidthClient->getVoice()->getClient()->getCall(getenv("BW_ACCOUNT_ID"), $callId);
118122
$this->assertTrue(strlen($response->getResult()->state) > 0);
119123
}
120124

125+
public function testCreateCallWithPriority() {
126+
$body = new BandwidthLib\Voice\Models\CreateCallRequest();
127+
$body->from = getenv("BW_NUMBER");
128+
$body->to = getenv("USER_NUMBER");
129+
$body->applicationId = getenv("BW_VOICE_APPLICATION_ID");
130+
$body->answerUrl = getenv("BASE_CALLBACK_URL");
131+
$body->priority = 1;
132+
$response = $this->bandwidthClient->getVoice()->getClient()->createCall(getenv("BW_ACCOUNT_ID"), $body);
133+
$callId = $response->getResult()->callId;
134+
$this->assertTrue(strlen($callId) > 0);
135+
$this->assertTrue($response->getResult()->priority == $body->priority);
136+
}
137+
121138
public function testCreateCallInvalidPhoneNumber() {
122139
$body = new BandwidthLib\Voice\Models\CreateCallRequest();
123140
$body->from = getenv("BW_NUMBER");

0 commit comments

Comments
 (0)