Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added endpoints and tests #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/Api/Meetings/MeetingParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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);
}
}
44 changes: 43 additions & 1 deletion tests/Fake/Meetings/MeetingParticipantsFakeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

Expand All @@ -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()
);
}
}
4 changes: 2 additions & 2 deletions tests/Fake/Meetings/MeetingsFakeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getDeleteMeetingFakeResponse()
public function getErrorOnMeetingsFakeList()
{
return json_encode(
$this->fakeError()
);
$this->fakeError()
);
}
}
99 changes: 99 additions & 0 deletions tests/Unit/Meetings/MeetingParticipantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading