Skip to content

Commit

Permalink
Add sendchatmessage api endpoint (#204)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
SamuelWei and FelixJacobi authored Sep 17, 2024
1 parent 13fabd0 commit 3563503
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 7 deletions.
19 changes: 19 additions & 0 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use BigBlueButton\Parameters\JoinMeetingParameters;
use BigBlueButton\Parameters\PublishRecordingsParameters;
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
use BigBlueButton\Parameters\SendChatMessageParameters;
use BigBlueButton\Parameters\UpdateRecordingsParameters;
use BigBlueButton\Responses\ApiVersionResponse;
use BigBlueButton\Responses\CreateMeetingResponse;
Expand All @@ -62,6 +63,7 @@
use BigBlueButton\Responses\JoinMeetingResponse;
use BigBlueButton\Responses\PublishRecordingsResponse;
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
use BigBlueButton\Responses\SendChatMessageResponse;
use BigBlueButton\Responses\UpdateRecordingsResponse;
use BigBlueButton\Util\UrlBuilder;

Expand Down Expand Up @@ -478,6 +480,23 @@ public function insertDocument(InsertDocumentParameters $insertDocumentParams):
return new InsertDocumentResponse($xml);
}

public function getSendChatMessageUrl(SendChatMessageParameters $sendChatMessageParams): string
{
return $this->urlBuilder->buildUrl(ApiMethod::SEND_CHAT_MESSAGE, $sendChatMessageParams->getHTTPQuery());
}

/**
* @throws NetworkException
* @throws ParsingException
* @throws RuntimeException
*/
public function getSendChatMessage(SendChatMessageParameters $sendChatMessageParams): SendChatMessageResponse
{
$xml = $this->processXmlResponse($this->getSendChatMessageUrl($sendChatMessageParams));

return new SendChatMessageResponse($xml);
}

/* ____________________ SPECIAL METHODS ___________________ */

public function getJSessionId(): ?string
Expand Down
1 change: 1 addition & 0 deletions src/Enum/ApiMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ enum ApiMethod: string
case HOOKS_LIST = 'hooks/list';
case HOOKS_DESTROY = 'hooks/destroy';
case INSERT_DOCUMENT = 'insertDocument';
case SEND_CHAT_MESSAGE = 'sendChatMessage';
}
3 changes: 1 addition & 2 deletions src/Http/Transport/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ public function request(TransportRequest $request): TransportResponse

$ch = curl_init();
// @codeCoverageIgnoreStart
/* @phpstan-ignore-next-line */
if (!$ch) {
throw new RuntimeException('Could not create curl instance. Error: '.curl_error($ch));
throw new RuntimeException('Could not create curl instance.');
}
// @codeCoverageIgnoreEnd

Expand Down
39 changes: 39 additions & 0 deletions src/Parameters/SendChatMessageParameters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* This file is part of littleredbutton/bigbluebutton-api-php.
*
* littleredbutton/bigbluebutton-api-php is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* littleredbutton/bigbluebutton-api-php is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with littleredbutton/bigbluebutton-api-php. If not, see <http://www.gnu.org/licenses/>.
*/

namespace BigBlueButton\Parameters;

/**
* Class SendChatMessageParameters.
*
* @method string getMeetingID()
* @method $this setMeetingID(string $id)
* @method string getMessage()
* @method $this setMessage(string $message)
* @method string|null getUserName()
* @method $this setUserName(string $userName)
*/
final class SendChatMessageParameters extends BaseParameters
{
public function __construct(protected string $meetingID, protected string $message, protected ?string $userName = null)
{
}
}
26 changes: 26 additions & 0 deletions src/Responses/SendChatMessageResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/**
* This file is part of littleredbutton/bigbluebutton-api-php.
*
* littleredbutton/bigbluebutton-api-php is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* littleredbutton/bigbluebutton-api-php is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with littleredbutton/bigbluebutton-api-php. If not, see <http://www.gnu.org/licenses/>.
*/

namespace BigBlueButton\Responses;

final class SendChatMessageResponse extends BaseResponse
{
}
10 changes: 5 additions & 5 deletions tools/.phpstan/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3563503

Please sign in to comment.