Skip to content

Commit

Permalink
feat: added endpoints and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrealessio committed Sep 19, 2024
1 parent a379319 commit a42d534
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 1 deletion.
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);

Check warning on line 45 in src/Api/Meetings/MeetingParticipant.php

View check run for this annotation

Codecov / codecov/patch

src/Api/Meetings/MeetingParticipant.php#L45

Added line #L45 was not covered by tests
}

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);

Check warning on line 79 in src/Api/Meetings/MeetingParticipant.php

View check run for this annotation

Codecov / codecov/patch

src/Api/Meetings/MeetingParticipant.php#L79

Added line #L79 was not covered by tests
}

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);

Check warning on line 97 in src/Api/Meetings/MeetingParticipant.php

View check run for this annotation

Codecov / codecov/patch

src/Api/Meetings/MeetingParticipant.php#L97

Added line #L97 was not covered by tests
}

return new MeetingParticipantEntity($response->data);
}
}
23 changes: 22 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 Down
45 changes: 45 additions & 0 deletions tests/Unit/Meetings/MeetingParticipantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,49 @@ 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);
}
}

0 comments on commit a42d534

Please sign in to comment.