diff --git a/src/Api/Meetings/MeetingParticipant.php b/src/Api/Meetings/MeetingParticipant.php index ed834b2..8e739c0 100644 --- a/src/Api/Meetings/MeetingParticipant.php +++ b/src/Api/Meetings/MeetingParticipant.php @@ -29,6 +29,25 @@ public function list( }, $meeting_participants->items); } + public function queryWIthEmail( + string $meetingId, + ?array $additional_data = [] + ) { + $additional_data = $this->data($additional_data, [ + 'meetingStartTimeFrom', 'meetingStartTimeTo', 'hostEmail', 'emails', 'joinTimeFrom', 'joinTimeTo', + ]); + + $response = $this->post('meetingParticipants/query', array_merge([ + 'meetingId' => $meetingId, + ], $additional_data)); + + if (! $response->success) { + return new Error($response->data); + } + + return new MeetingParticipantEntity($response->data); + } + public function detail( string $meetingParticipantId, ?array $additional_data = [] @@ -45,4 +64,39 @@ public function detail( return new MeetingParticipantEntity($response->data); } + + public function update( + string $participantId, + ?array $additional_data = [] + ) { + $additional_data = $this->data($additional_data, [ + 'muted', 'admit', 'expel', + ]); + + $response = $this->post('meetingParticipants/'.$participantId, $additional_data); + + if (! $response->success) { + return new Error($response->data); + } + + return new MeetingParticipantEntity($response->data); + } + + public function admit( + ?array $additional_data = [] + ) { + $additional_data = $this->data($additional_data, [ + 'items' => [ + 'participantId', + ], + ]); + + $response = $this->post('meetingParticipants/admit', $additional_data); + + if (! $response->success) { + return new Error($response->data); + } + + return new MeetingParticipantEntity($response->data); + } } diff --git a/tests/Fake/Meetings/MeetingParticipantsFakeResponse.php b/tests/Fake/Meetings/MeetingParticipantsFakeResponse.php index d4984ad..c975fb3 100644 --- a/tests/Fake/Meetings/MeetingParticipantsFakeResponse.php +++ b/tests/Fake/Meetings/MeetingParticipantsFakeResponse.php @@ -17,7 +17,28 @@ public function getMeetingParticipantsFakeList() public function getMeetingParticipantsFakeDetail() { return json_encode( - $this->fakeMeetingParticipant(), + $this->fakeMeetingParticipant() + ); + } + + public function getMeetingParticipantsFakeQueryWithEmail() + { + return json_encode( + $this->fakeMeetingParticipant() + ); + } + + public function getUpdatedMeetingParticipantsFakeDetail() + { + return json_encode( + $this->fakeMeetingParticipant() + ); + } + + public function getAdmittedMeetingParticipantsFakeDetail() + { + return json_encode( + $this->fakeMeetingParticipant() ); } @@ -27,4 +48,25 @@ public function getErrorOnMeetingsFakeList() $this->fakeError() ); } + + public function getErrorOnFakeQueryWithEmail() + { + return json_encode( + $this->fakeError() + ); + } + + public function getErrorOnFakeUpdate() + { + return json_encode( + $this->fakeError() + ); + } + + public function getErrorOnFakeAdmit() + { + return json_encode( + $this->fakeError() + ); + } } diff --git a/tests/Fake/Meetings/MeetingsFakeResponse.php b/tests/Fake/Meetings/MeetingsFakeResponse.php index 5431357..6367686 100644 --- a/tests/Fake/Meetings/MeetingsFakeResponse.php +++ b/tests/Fake/Meetings/MeetingsFakeResponse.php @@ -58,7 +58,7 @@ public function getDeleteMeetingFakeResponse() public function getErrorOnMeetingsFakeList() { return json_encode( - $this->fakeError() - ); + $this->fakeError() + ); } } diff --git a/tests/Unit/Meetings/MeetingParticipantsTest.php b/tests/Unit/Meetings/MeetingParticipantsTest.php index 4770353..1537623 100644 --- a/tests/Unit/Meetings/MeetingParticipantsTest.php +++ b/tests/Unit/Meetings/MeetingParticipantsTest.php @@ -94,4 +94,103 @@ public function test_meeting_participants_detail() $this->assertInstanceOf(MeetingParticipant::class, $meeting_participants_detail); $this->assertEquals('fake_id', $meeting_participants_detail->id); } + + public function test_meeting_participants_query_with_email() + { + Http::fake([ + 'meetingParticipants/query' => Http::response( + (new MeetingParticipantsFakeResponse())->getMeetingParticipantsFakeQueryWithEmail() + ), + ]); + + $laravel_webex = new LaravelWebex(); + $meeting_participants_detail = $laravel_webex->meeting_participants()->queryWIthEmail('fake_id'); + + $this->assertInstanceOf(MeetingParticipant::class, $meeting_participants_detail); + $this->assertEquals('fake_id', $meeting_participants_detail->id); + } + + public function test_meeting_participants_update() + { + Http::fake([ + 'meetingParticipants/fake_id' => Http::response( + (new MeetingParticipantsFakeResponse())->getUpdatedMeetingParticipantsFakeDetail() + ), + ]); + + $laravel_webex = new LaravelWebex(); + $meeting_participants_detail = $laravel_webex->meeting_participants()->update('fake_id'); + + $this->assertInstanceOf(MeetingParticipant::class, $meeting_participants_detail); + $this->assertEquals('fake_id', $meeting_participants_detail->id); + } + + public function test_meeting_participants_admit() + { + Http::fake([ + 'meetingParticipants/admit' => Http::response( + (new MeetingParticipantsFakeResponse())->getAdmittedMeetingParticipantsFakeDetail() + ), + ]); + + $laravel_webex = new LaravelWebex(); + $meeting_participants_detail = $laravel_webex->meeting_participants()->admit(); + + $this->assertInstanceOf(MeetingParticipant::class, $meeting_participants_detail); + $this->assertEquals('fake_id', $meeting_participants_detail->id); + } + + public function test_error_on_meeting_query() + { + Http::fake([ + 'meetingParticipants/query' => Http::response( + (new MeetingParticipantsFakeResponse())->getErrorOnFakeQueryWithEmail(), + 401 + ), + ]); + + $laravel_webex = new LaravelWebex(); + $error_meeting_participants_detail = $laravel_webex->meeting_participants()->queryWIthEmail('fake_id'); + + $this->assertInstanceOf(Error::class, $error_meeting_participants_detail); + $this->assertEquals('fake_message', $error_meeting_participants_detail->message); + $this->assertIsArray($error_meeting_participants_detail->errors); + $this->assertEquals('fake_trackingId', $error_meeting_participants_detail->trackingId); + } + + public function test_error_on_update() + { + Http::fake([ + 'meetingParticipants/fake_id' => Http::response( + (new MeetingParticipantsFakeResponse())->getErrorOnFakeUpdate(), + 401 + ), + ]); + + $laravel_webex = new LaravelWebex(); + $error_meeting_participants_detail = $laravel_webex->meeting_participants()->update('fake_id'); + + $this->assertInstanceOf(Error::class, $error_meeting_participants_detail); + $this->assertEquals('fake_message', $error_meeting_participants_detail->message); + $this->assertIsArray($error_meeting_participants_detail->errors); + $this->assertEquals('fake_trackingId', $error_meeting_participants_detail->trackingId); + } + + public function test_error_on_admit() + { + Http::fake([ + 'meetingParticipants/admit' => Http::response( + (new MeetingParticipantsFakeResponse())->getErrorOnFakeAdmit(), + 401 + ), + ]); + + $laravel_webex = new LaravelWebex(); + $error_meeting_participants_detail = $laravel_webex->meeting_participants()->admit(); + + $this->assertInstanceOf(Error::class, $error_meeting_participants_detail); + $this->assertEquals('fake_message', $error_meeting_participants_detail->message); + $this->assertIsArray($error_meeting_participants_detail->errors); + $this->assertEquals('fake_trackingId', $error_meeting_participants_detail->trackingId); + } }