| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,315 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Resources; |
|
| 4 |
+ |
|
| 5 |
+ |
|
| 6 |
+use Plivo\Http\PlivoRequest; |
|
| 7 |
+use Plivo\Http\PlivoResponse; |
|
| 8 |
+use Plivo\Tests\BaseTestCase; |
|
| 9 |
+ |
|
| 10 |
+class MultiPartyCallTest extends BaseTestCase{
|
|
| 11 |
+ function testMPCList(){
|
|
| 12 |
+ $request = new PlivoRequest( |
|
| 13 |
+ 'GET', |
|
| 14 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/', |
|
| 15 |
+ [] |
|
| 16 |
+ ); |
|
| 17 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsListResponse.json'); |
|
| 18 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 19 |
+ $actual = $this->client->multipartyCalls->list(); |
|
| 20 |
+ |
|
| 21 |
+ $this->assertRequest($request); |
|
| 22 |
+ |
|
| 23 |
+ self::assertNotNull($actual); |
|
| 24 |
+ } |
|
| 25 |
+ |
|
| 26 |
+ function testMPCGet(){
|
|
| 27 |
+ $request = new PlivoRequest( |
|
| 28 |
+ 'GET', |
|
| 29 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_ca8e8a44-48e1-445d-afd5-1fcccdbccd9d/', |
|
| 30 |
+ [] |
|
| 31 |
+ ); |
|
| 32 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsGetResponse.json'); |
|
| 33 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 34 |
+ |
|
| 35 |
+ $actual = $this->client->multipartyCalls->get(['uuid' => 'ca8e8a44-48e1-445d-afd5-1fcccdbccd9d']); |
|
| 36 |
+ $this->assertRequest($request); |
|
| 37 |
+ |
|
| 38 |
+ self::assertNotNull($actual); |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 41 |
+ function testMPCAddParticipant(){
|
|
| 42 |
+ $request = new PlivoRequest( |
|
| 43 |
+ 'POST', |
|
| 44 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/Participant/', |
|
| 45 |
+ [ |
|
| 46 |
+ 'role'=> 'Agent', |
|
| 47 |
+ 'call_uuid'=> '1234-5678-4321-0987', |
|
| 48 |
+ 'call_status_callback_method'=> 'POST', |
|
| 49 |
+ 'confirm_key_sound_method'=> 'GET', |
|
| 50 |
+ 'dial_music'=> 'Real', |
|
| 51 |
+ 'ring_timeout'=> 45, |
|
| 52 |
+ 'delay_dial'=> 0, |
|
| 53 |
+ 'max_duration'=> 14400, |
|
| 54 |
+ 'max_participants'=> 10, |
|
| 55 |
+ 'record_min_member_count'=> 1, |
|
| 56 |
+ 'wait_music_method'=> 'GET', |
|
| 57 |
+ 'agent_hold_music_method'=> 'GET', |
|
| 58 |
+ 'customer_hold_music_method'=> 'GET', |
|
| 59 |
+ 'recording_callback_method'=> 'GET', |
|
| 60 |
+ 'status_callback_method'=> 'GET', |
|
| 61 |
+ 'on_exit_action_method'=> 'POST', |
|
| 62 |
+ 'record'=> false, |
|
| 63 |
+ 'record_file_format'=> 'mp3', |
|
| 64 |
+ 'status_callback_events'=> 'mpc-state-changes,participant-state-changes', |
|
| 65 |
+ 'stay_alone'=> false, |
|
| 66 |
+ 'coach_mode'=> true, |
|
| 67 |
+ 'mute'=> false, |
|
| 68 |
+ 'hold'=> false, |
|
| 69 |
+ 'start_mpc_on_enter'=> true, |
|
| 70 |
+ 'end_mpc_on_exit'=> false, |
|
| 71 |
+ 'relay_dtmf_inputs'=> false, |
|
| 72 |
+ 'enter_sound'=> 'beep:1', |
|
| 73 |
+ 'enter_sound_method'=> 'GET', |
|
| 74 |
+ 'exit_sound'=> 'beep:2', |
|
| 75 |
+ 'exit_sound_method'=> 'GET', |
|
| 76 |
+ 'start_recording_audio_method'=> 'GET', |
|
| 77 |
+ 'stop_recording_audio_method'=> 'GET' |
|
| 78 |
+ ]); |
|
| 79 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsAddParticipantResponse.json'); |
|
| 80 |
+ |
|
| 81 |
+ $this->mock(new PlivoResponse($request,201, $body)); |
|
| 82 |
+ $actual = $this->client->multiPartyCalls->addParticipant('Agent', ['friendly_name' => 'Voice', 'call_uuid' => '1234-5678-4321-0987']);
|
|
| 83 |
+ |
|
| 84 |
+ $this->assertRequest($request); |
|
| 85 |
+ self::assertNotNull($actual); |
|
| 86 |
+ self::assertNotNull($actual['calls']); |
|
| 87 |
+ self::assertEquals($actual['message'], "add participant action initiated"); |
|
| 88 |
+ } |
|
| 89 |
+ |
|
| 90 |
+ function testMPCStart(){
|
|
| 91 |
+ $request = new PlivoRequest( |
|
| 92 |
+ 'POST', |
|
| 93 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/', |
|
| 94 |
+ ['status' => 'active'] |
|
| 95 |
+ ); |
|
| 96 |
+ |
|
| 97 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 98 |
+ $actual = $this->client->multiPartyCalls->start(['friendly_name' => 'Voice']); |
|
| 99 |
+ |
|
| 100 |
+ $this->assertRequest($request); |
|
| 101 |
+ |
|
| 102 |
+ self::assertNull($actual['error']); |
|
| 103 |
+ } |
|
| 104 |
+ |
|
| 105 |
+ function testMPCEnd(){
|
|
| 106 |
+ $request = new PlivoRequest( |
|
| 107 |
+ 'DELETE', |
|
| 108 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/', |
|
| 109 |
+ [] |
|
| 110 |
+ ); |
|
| 111 |
+ |
|
| 112 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 113 |
+ $actual = $this->client->multiPartyCalls->stop(['friendly_name' => 'Voice']); |
|
| 114 |
+ |
|
| 115 |
+ $this->assertRequest($request); |
|
| 116 |
+ self::assertNull($actual['error']); |
|
| 117 |
+ } |
|
| 118 |
+ |
|
| 119 |
+ function testMPCStartRecording(){
|
|
| 120 |
+ $request = new PlivoRequest( |
|
| 121 |
+ 'POST', |
|
| 122 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/Record/', |
|
| 123 |
+ ['file_format'=> 'wav', |
|
| 124 |
+ 'recording_callback_url'=> 'https://plivo.com/status', |
|
| 125 |
+ 'recording_callback_method'=> 'POST'] |
|
| 126 |
+ ); |
|
| 127 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsStartRecordingResponse.json'); |
|
| 128 |
+ |
|
| 129 |
+ $this->mock(new PlivoResponse($request,202, $body)); |
|
| 130 |
+ $actual = $this->client->multiPartyCalls->startRecording(['friendly_name' => 'Voice', 'file_format' => 'wav', |
|
| 131 |
+ 'recording_callback_url'=> 'https://plivo.com/status', |
|
| 132 |
+ 'recording_callback_method'=> 'POST'] |
|
| 133 |
+ ); |
|
| 134 |
+ $this->assertRequest($request); |
|
| 135 |
+ self::assertNotNull($actual); |
|
| 136 |
+ } |
|
| 137 |
+ |
|
| 138 |
+ function testMPCStopRecording(){
|
|
| 139 |
+ $request = new PlivoRequest( |
|
| 140 |
+ 'DELETE', |
|
| 141 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/Record/', |
|
| 142 |
+ [] |
|
| 143 |
+ ); |
|
| 144 |
+ |
|
| 145 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 146 |
+ $actual = $this->client->multiPartyCalls->stopRecording(['friendly_name' => 'Voice']); |
|
| 147 |
+ $this->assertRequest($request); |
|
| 148 |
+ self::assertNull($actual['error']); |
|
| 149 |
+ } |
|
| 150 |
+ |
|
| 151 |
+ function testMPCPauseRecording(){
|
|
| 152 |
+ $request = new PlivoRequest( |
|
| 153 |
+ 'POST', |
|
| 154 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/Record/Pause/', |
|
| 155 |
+ [] |
|
| 156 |
+ ); |
|
| 157 |
+ |
|
| 158 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 159 |
+ $actual = $this->client->multiPartyCalls->pauseRecording(['friendly_name' => 'Voice']); |
|
| 160 |
+ $this->assertRequest($request); |
|
| 161 |
+ self::assertNull($actual['error']); |
|
| 162 |
+ } |
|
| 163 |
+ |
|
| 164 |
+ function testMPCResumeRecording(){
|
|
| 165 |
+ $request = new PlivoRequest( |
|
| 166 |
+ 'POST', |
|
| 167 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/name_Voice/Record/Resume/', |
|
| 168 |
+ [] |
|
| 169 |
+ ); |
|
| 170 |
+ |
|
| 171 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 172 |
+ $actual = $this->client->multiPartyCalls->resumeRecording(['friendly_name' => 'Voice']); |
|
| 173 |
+ $this->assertRequest($request); |
|
| 174 |
+ self::assertNull($actual['error']); |
|
| 175 |
+ } |
|
| 176 |
+ |
|
| 177 |
+ function testMPCListParticipants(){
|
|
| 178 |
+ $request = new PlivoRequest( |
|
| 179 |
+ 'GET', |
|
| 180 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/', |
|
| 181 |
+ [] |
|
| 182 |
+ ); |
|
| 183 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsListParticipantsResponse.json'); |
|
| 184 |
+ |
|
| 185 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 186 |
+ $actual = $this->client->multiPartyCalls->listParticipants(['uuid' => '12345678-90123456']); |
|
| 187 |
+ $this->assertRequest($request); |
|
| 188 |
+ self::assertNotNull($actual); |
|
| 189 |
+ } |
|
| 190 |
+ |
|
| 191 |
+ function testMPCUpdateParticipant(){
|
|
| 192 |
+ $request = new PlivoRequest( |
|
| 193 |
+ 'POST', |
|
| 194 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/', |
|
| 195 |
+ ['hold'=>false, 'mute'=> false] |
|
| 196 |
+ ); |
|
| 197 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsUpdateParticipantResponse.json'); |
|
| 198 |
+ |
|
| 199 |
+ $this->mock(new PlivoResponse($request,202, $body)); |
|
| 200 |
+ $actual = $this->client->multiPartyCalls->updateParticipant(10, ['uuid' => '12345678-90123456', 'hold'=>false, 'mute'=> false]); |
|
| 201 |
+ $this->assertRequest($request); |
|
| 202 |
+ self::assertNotNull($actual); |
|
| 203 |
+ } |
|
| 204 |
+ |
|
| 205 |
+ function testMPCKickParticipant(){
|
|
| 206 |
+ $request = new PlivoRequest( |
|
| 207 |
+ 'DELETE', |
|
| 208 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/', |
|
| 209 |
+ [] |
|
| 210 |
+ ); |
|
| 211 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 212 |
+ $actual = $this->client->multiPartyCalls->kickParticipant(10, ['uuid' => '12345678-90123456']); |
|
| 213 |
+ $this->assertRequest($request); |
|
| 214 |
+ self::assertNull($actual['error']); |
|
| 215 |
+ } |
|
| 216 |
+ |
|
| 217 |
+ function testMPCGetParticipant(){
|
|
| 218 |
+ $request = new PlivoRequest( |
|
| 219 |
+ 'GET', |
|
| 220 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/', |
|
| 221 |
+ [] |
|
| 222 |
+ ); |
|
| 223 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsGetParticipantResponse.json'); |
|
| 224 |
+ |
|
| 225 |
+ $this->mock(new PlivoResponse($request,200, $body)); |
|
| 226 |
+ $actual = $this->client->multiPartyCalls->getParticipant(10, ['uuid' => '12345678-90123456']); |
|
| 227 |
+ $this->assertRequest($request); |
|
| 228 |
+ self::assertNotNull($actual); |
|
| 229 |
+ } |
|
| 230 |
+ |
|
| 231 |
+ function testMPCStartParticipantRecording(){
|
|
| 232 |
+ $request = new PlivoRequest( |
|
| 233 |
+ 'POST', |
|
| 234 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/Record/', |
|
| 235 |
+ ['file_format'=> 'wav', |
|
| 236 |
+ 'recording_callback_url'=> 'https://plivo.com/status', |
|
| 237 |
+ 'recording_callback_method'=> 'POST'] |
|
| 238 |
+ ); |
|
| 239 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsStartParticipantRecordingResponse.json'); |
|
| 240 |
+ |
|
| 241 |
+ $this->mock(new PlivoResponse($request,200)); |
|
| 242 |
+ $actual = $this->client->multiPartyCalls->startParticipantRecording(10, ['uuid' => '12345678-90123456', |
|
| 243 |
+ 'file_format'=> 'wav', |
|
| 244 |
+ 'recording_callback_url'=> 'https://plivo.com/status', |
|
| 245 |
+ 'recording_callback_method'=> 'POST']); |
|
| 246 |
+ $this->assertRequest($request); |
|
| 247 |
+ self::assertNotNull($actual); |
|
| 248 |
+ } |
|
| 249 |
+ |
|
| 250 |
+ function testMPCStopParticipantRecording(){
|
|
| 251 |
+ $request = new PlivoRequest( |
|
| 252 |
+ 'DELETE', |
|
| 253 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/Record/', |
|
| 254 |
+ [] |
|
| 255 |
+ ); |
|
| 256 |
+ |
|
| 257 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 258 |
+ $actual = $this->client->multiPartyCalls->stopParticipantRecording(10, ['uuid' => '12345678-90123456']); |
|
| 259 |
+ $this->assertRequest($request); |
|
| 260 |
+ self::assertNotNull($actual); |
|
| 261 |
+ } |
|
| 262 |
+ |
|
| 263 |
+ function testMPCPauseParticipantRecording(){
|
|
| 264 |
+ $request = new PlivoRequest( |
|
| 265 |
+ 'POST', |
|
| 266 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/Record/Pause/', |
|
| 267 |
+ [] |
|
| 268 |
+ ); |
|
| 269 |
+ |
|
| 270 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 271 |
+ $actual = $this->client->multiPartyCalls->pauseParticipantRecording(10, ['uuid' => '12345678-90123456']); |
|
| 272 |
+ $this->assertRequest($request); |
|
| 273 |
+ self::assertNotNull($actual); |
|
| 274 |
+ } |
|
| 275 |
+ |
|
| 276 |
+ function testMPCResumeParticipantRecording(){
|
|
| 277 |
+ $request = new PlivoRequest( |
|
| 278 |
+ 'POST', |
|
| 279 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Participant/10/Record/Resume/', |
|
| 280 |
+ [] |
|
| 281 |
+ ); |
|
| 282 |
+ |
|
| 283 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 284 |
+ $actual = $this->client->multiPartyCalls->resumeParticipantRecording(10, ['uuid' => '12345678-90123456']); |
|
| 285 |
+ $this->assertRequest($request); |
|
| 286 |
+ self::assertNotNull($actual); |
|
| 287 |
+ } |
|
| 288 |
+ |
|
| 289 |
+ function testMPCStartPlayAudio(){
|
|
| 290 |
+ $request = new PlivoRequest( |
|
| 291 |
+ 'POST', |
|
| 292 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Member/10/Play/', |
|
| 293 |
+ ['url' => 'https://s3.amazonaws.com/XXX/XXX.mp3'] |
|
| 294 |
+ ); |
|
| 295 |
+ $body = file_get_contents(__DIR__ . '/../Mocks/multiPartyCallsStartPlayAudioResponse.json'); |
|
| 296 |
+ |
|
| 297 |
+ $this->mock(new PlivoResponse($request,202, $body)); |
|
| 298 |
+ $actual = $this->client->multiPartyCalls->startPlayAudio(10, "https://s3.amazonaws.com/XXX/XXX.mp3", ['uuid' => '12345678-90123456']); |
|
| 299 |
+ $this->assertRequest($request); |
|
| 300 |
+ self::assertNotNull($actual); |
|
| 301 |
+ } |
|
| 302 |
+ |
|
| 303 |
+ function testMPCStopPlayAudio(){
|
|
| 304 |
+ $request = new PlivoRequest( |
|
| 305 |
+ 'DELETE', |
|
| 306 |
+ 'Account/MAXXXXXXXXXXXXXXXXXX/MultiPartyCall/uuid_12345678-90123456/Member/10/Play/', |
|
| 307 |
+ [] |
|
| 308 |
+ ); |
|
| 309 |
+ |
|
| 310 |
+ $this->mock(new PlivoResponse($request,204)); |
|
| 311 |
+ $actual = $this->client->multiPartyCalls->stopPlayAudio(10, ['uuid' => '12345678-90123456']); |
|
| 312 |
+ $this->assertRequest($request); |
|
| 313 |
+ self::assertNotNull($actual); |
|
| 314 |
+ } |
|
| 315 |
+} |
|
| 0 | 316 |
\ No newline at end of file |