Skip to content
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
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
->in(__DIR__ . '/src/Services/SonetGroup/')
->in(__DIR__ . '/src/Services/IMOpenLines/')
->in(__DIR__ . '/src/Services/Landing/')
->in(__DIR__ . '/src/Services/Messageservice/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
->ignoreDotFiles(true)
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

### Added

- Added service `Services\Messageservice\Sender` and `Services\Messageservice\Message\Status` with support for `messageservice.*` methods,
see [messageservice.* methods](https://apidocs.bitrix24.com/api-reference/messageservice/index.html) ([#498](https://github.com/bitrix24/b24phpsdk/issues/498)):
- `sender.add` — register a new SMS message service provider
- `sender.update` — update a registered message service provider
- `sender.list` — get list of sender codes registered by the current application
- `sender.delete` — delete a registered message service provider
- `message.status.update` — update delivery status of a message sent via a provider

- Added service `Services\Landing\Site\Service\Site` with support methods,
see [landing.site.* methods](https://github.com/bitrix24/b24phpsdk/issues/267):
- `add` adds a site
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,18 @@ test-integration-landing-role:
test-integration-landing-repowidget:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_landing_repowidget

.PHONY: test-integration-scope-messageservice
test-integration-scope-messageservice:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_messageservice

.PHONY: test-integration-messageservice-sender
test-integration-messageservice-sender:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_messageservice_sender

.PHONY: test-integration-messageservice-message-status
test-integration-messageservice-message-status:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_messageservice_message_status

# work dev environment
.PHONY: php-dev-server-up
php-dev-server-up:
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ parameters:
- tests/Integration/Services/CRM/Documentgenerator/Document
- tests/Integration/Services/CRM/Documentgenerator/Template
- tests/Integration/Services/Landing
- tests/Integration/Services/Messageservice
excludePaths:
- tests/Integration/Services/CRM/Requisites/Service/RequisiteUserfieldUseCaseTest.php
- tests/Integration/Services/CRM/Status
Expand Down
9 changes: 9 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@
<testsuite name="integration_tests_landing_repowidget">
<directory>./tests/Integration/Services/Landing/RepoWidget/</directory>
</testsuite>
<testsuite name="integration_tests_scope_messageservice">
<directory>./tests/Integration/Services/Messageservice/</directory>
</testsuite>
<testsuite name="integration_tests_messageservice_sender">
<directory>./tests/Integration/Services/Messageservice/Sender/</directory>
</testsuite>
<testsuite name="integration_tests_messageservice_message_status">
<directory>./tests/Integration/Services/Messageservice/Message/Status/</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
__DIR__ . '/tests/Integration/Services/CRM/Documentgenerator/Template',
__DIR__ . '/src/Services/Landing',
__DIR__ . '/tests/Integration/Services/Landing',
__DIR__ . '/src/Services/Messageservice',
__DIR__ . '/tests/Integration/Services/Messageservice',
__DIR__ . '/tests/Unit/',
])
->withCache(cacheDirectory: __DIR__ . '/var/.cache/rector')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Message\Status\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class MessageStatusUpdateResult extends AbstractResult
{
/**
* Check if message status was updated successfully.
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function isSuccess(): bool
{
return (bool)$this->getCoreResponse()->getResponseData()->getResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Message\Status\Service;

use Bitrix24\SDK\Attributes\ApiEndpointMetadata;
use Bitrix24\SDK\Attributes\ApiServiceMetadata;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Exceptions\TransportException;
use Bitrix24\SDK\Services\AbstractService;
use Bitrix24\SDK\Services\Messageservice\Message\Status\Result\MessageStatusUpdateResult;

#[ApiServiceMetadata(new Scope(['messageservice']))]
class MessageStatus extends AbstractService
{
/**
* Update delivery status of a message sent via a message service provider.
*
* Supported status values:
* - queued — message is queued for sending
* - sent — message was sent by the provider
* - delivered — message was successfully delivered to the recipient
* - undelivered — message was not delivered to the recipient
* - failed — provider encountered a sending or processing error
*
* @param string $code Sender code. Can be retrieved via messageservice.sender.list
* @param string $messageId External message identifier received by the handler on message send
* @param string $status New message status
*
* @throws BaseException
* @throws TransportException
* @link https://apidocs.bitrix24.com/api-reference/messageservice/messageservice-message-status-update.html
*/
#[ApiEndpointMetadata(
'messageservice.message.status.update',
'https://apidocs.bitrix24.com/api-reference/messageservice/messageservice-message-status-update.html',
'Update delivery status of a message sent via a message service provider'
)]
public function update(
string $code,
string $messageId,
string $status
): MessageStatusUpdateResult {
return new MessageStatusUpdateResult(
$this->core->call('messageservice.message.status.update', [
'CODE' => $code,
'MESSAGE_ID' => $messageId,
'STATUS' => $status,
])
);
}
}
48 changes: 48 additions & 0 deletions src/Services/Messageservice/MessageserviceServiceBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice;

use Bitrix24\SDK\Attributes\ApiServiceBuilderMetadata;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Services\AbstractServiceBuilder;
use Bitrix24\SDK\Services\Messageservice\Message\Status\Service\MessageStatus;
use Bitrix24\SDK\Services\Messageservice\Sender\Service\Sender;

#[ApiServiceBuilderMetadata(new Scope(['messageservice']))]
class MessageserviceServiceBuilder extends AbstractServiceBuilder
{
public function sender(): Sender
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Sender(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function messageStatus(): MessageStatus
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new MessageStatus(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}
}
29 changes: 29 additions & 0 deletions src/Services/Messageservice/Sender/Result/SenderAddResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Sender\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class SenderAddResult extends AbstractResult
{
/**
* Check if sender was registered successfully.
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function isSuccess(): bool
{
return (bool)$this->getCoreResponse()->getResponseData()->getResult();
}
}
29 changes: 29 additions & 0 deletions src/Services/Messageservice/Sender/Result/SenderDeleteResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Sender\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class SenderDeleteResult extends AbstractResult
{
/**
* Check if sender was deleted successfully.
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function isSuccess(): bool
{
return (bool)$this->getCoreResponse()->getResponseData()->getResult();
}
}
29 changes: 29 additions & 0 deletions src/Services/Messageservice/Sender/Result/SenderUpdateResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Sender\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

class SenderUpdateResult extends AbstractResult
{
/**
* Check if sender was updated successfully.
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function isSuccess(): bool
{
return (bool)$this->getCoreResponse()->getResponseData()->getResult();
}
}
33 changes: 33 additions & 0 deletions src/Services/Messageservice/Sender/Result/SendersListResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\Messageservice\Sender\Result;

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;

class SendersListResult extends AbstractResult
{
/**
* Get list of registered sender codes.
*
* @return string[]
* @throws BaseException
*/
public function getSenderCodes(): array
{
$result = $this->getCoreResponse()->getResponseData()->getResult();

return is_array($result) ? array_values(array_map('strval', $result)) : [];
}
}
Loading
Loading