Skip to content

Commit 3563503

Browse files
Add sendchatmessage api endpoint (#204)
* Implement SendChatMessage api * Update src/Parameters/SendChatMessageParameters.php Co-authored-by: Felix Jacobi <felix@jacobi-hamburg.net> * Rectored code * Fixed PHPStan --------- Co-authored-by: Felix Jacobi <felix@jacobi-hamburg.net>
1 parent 13fabd0 commit 3563503

6 files changed

Lines changed: 91 additions & 7 deletions

File tree

src/BigBlueButton.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use BigBlueButton\Parameters\JoinMeetingParameters;
4646
use BigBlueButton\Parameters\PublishRecordingsParameters;
4747
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
48+
use BigBlueButton\Parameters\SendChatMessageParameters;
4849
use BigBlueButton\Parameters\UpdateRecordingsParameters;
4950
use BigBlueButton\Responses\ApiVersionResponse;
5051
use BigBlueButton\Responses\CreateMeetingResponse;
@@ -62,6 +63,7 @@
6263
use BigBlueButton\Responses\JoinMeetingResponse;
6364
use BigBlueButton\Responses\PublishRecordingsResponse;
6465
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
66+
use BigBlueButton\Responses\SendChatMessageResponse;
6567
use BigBlueButton\Responses\UpdateRecordingsResponse;
6668
use BigBlueButton\Util\UrlBuilder;
6769

@@ -478,6 +480,23 @@ public function insertDocument(InsertDocumentParameters $insertDocumentParams):
478480
return new InsertDocumentResponse($xml);
479481
}
480482

483+
public function getSendChatMessageUrl(SendChatMessageParameters $sendChatMessageParams): string
484+
{
485+
return $this->urlBuilder->buildUrl(ApiMethod::SEND_CHAT_MESSAGE, $sendChatMessageParams->getHTTPQuery());
486+
}
487+
488+
/**
489+
* @throws NetworkException
490+
* @throws ParsingException
491+
* @throws RuntimeException
492+
*/
493+
public function getSendChatMessage(SendChatMessageParameters $sendChatMessageParams): SendChatMessageResponse
494+
{
495+
$xml = $this->processXmlResponse($this->getSendChatMessageUrl($sendChatMessageParams));
496+
497+
return new SendChatMessageResponse($xml);
498+
}
499+
481500
/* ____________________ SPECIAL METHODS ___________________ */
482501

483502
public function getJSessionId(): ?string

src/Enum/ApiMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ enum ApiMethod: string
4545
case HOOKS_LIST = 'hooks/list';
4646
case HOOKS_DESTROY = 'hooks/destroy';
4747
case INSERT_DOCUMENT = 'insertDocument';
48+
case SEND_CHAT_MESSAGE = 'sendChatMessage';
4849
}

src/Http/Transport/CurlTransport.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ public function request(TransportRequest $request): TransportResponse
8888

8989
$ch = curl_init();
9090
// @codeCoverageIgnoreStart
91-
/* @phpstan-ignore-next-line */
9291
if (!$ch) {
93-
throw new RuntimeException('Could not create curl instance. Error: '.curl_error($ch));
92+
throw new RuntimeException('Could not create curl instance.');
9493
}
9594
// @codeCoverageIgnoreEnd
9695

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of littleredbutton/bigbluebutton-api-php.
7+
*
8+
* littleredbutton/bigbluebutton-api-php is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* littleredbutton/bigbluebutton-api-php is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with littleredbutton/bigbluebutton-api-php. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
namespace BigBlueButton\Parameters;
23+
24+
/**
25+
* Class SendChatMessageParameters.
26+
*
27+
* @method string getMeetingID()
28+
* @method $this setMeetingID(string $id)
29+
* @method string getMessage()
30+
* @method $this setMessage(string $message)
31+
* @method string|null getUserName()
32+
* @method $this setUserName(string $userName)
33+
*/
34+
final class SendChatMessageParameters extends BaseParameters
35+
{
36+
public function __construct(protected string $meetingID, protected string $message, protected ?string $userName = null)
37+
{
38+
}
39+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of littleredbutton/bigbluebutton-api-php.
7+
*
8+
* littleredbutton/bigbluebutton-api-php is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* littleredbutton/bigbluebutton-api-php is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with littleredbutton/bigbluebutton-api-php. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
namespace BigBlueButton\Responses;
23+
24+
final class SendChatMessageResponse extends BaseResponse
25+
{
26+
}

tools/.phpstan/composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)