Skip to content

Feature/134-complete-scope-crm-vol-3 #136

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

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
Draft
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 @@ -9,6 +9,7 @@
->in(__DIR__ . '/src/Services/CRM/VatRates/')
->in(__DIR__ . '/src/Services/CRM/Contact/')
->in(__DIR__ . '/src/Services/CRM/Requisites/')
->in(__DIR__ . '/src/Services/CRM/Activity/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
->ignoreDotFiles(true)
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
## Unreleased 1.3.0 – 2025.03.31

### Added
- Added service `Services\AI\Engine\Service\Type` with support methods:
- `crm.activity.type.add` - method registers a custom activity type with a name and icon
- `crm.activity.type.delete` - delete a custom activity type
- `crm.activity.type.list` - get a list of custom task types
- Added service `Services\AI\Engine\Service\Communication` with support methods:
- `crm.activity.communication.fields` - get a description of the communication

### Fixed
- Fix typehint errors in `src/Services/CRM/Activity/Result/ActivityItemResult.php`

- Added **PHP 8.4** [support](https://github.com/bitrix24/b24phpsdk/issues/120) 🚀
- Added method `Bitrix24\SDK\Services\Main\Service::guardValidateCurrentAuthToken` for validate current auth token with
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ test-integration-scope-entity:
test-integration-scope-ai-admin:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_ai_admin

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

.PHONY: test-integration-scope-crm-activity
test-integration-scope-crm-activity:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_crm_activity

# 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 @@ -11,6 +11,7 @@ parameters:
- tests/Integration/Services/IMOpenLines
- tests/Integration/Services/Main
- tests/Integration/Services/Placement
- tests/Integration/Services/CRM
bootstrapFiles:
- tests/bootstrap.php
parallel:
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<testsuite name="integration_tests_scope_ai_admin">
<directory>./tests/Integration/Services/AI/</directory>
</testsuite>
<testsuite name="integration_tests_scope_crm">
<directory>./tests/Integration/Services/CRM/</directory>
</testsuite>
<testsuite name="integration_tests_scope_crm_activity">
<directory>./tests/Integration/Services/CRM/Activity</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 @@ -34,6 +34,8 @@
__DIR__ . '/tests/Integration/Services/Main',
__DIR__ . '/src/Services/Placement',
__DIR__ . '/tests/Integration/Services/Placement',
__DIR__ . '/src/Services/CRM',
__DIR__ . '/tests/Integration/Services/CRM',
__DIR__ . '/tests/Unit/',
])
->withCache(cacheDirectory: __DIR__ . '.cache/rector')
Expand Down
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ enum ActivityContentType: int
case plainText = 1;
case bbCode = 2;
case html = 3;
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityDirectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ enum ActivityDirectionType: int
case default = 0;
case incoming = 1;
case outgoing = 2;
}
}
14 changes: 1 addition & 13 deletions src/Services/CRM/Activity/ActivityFetcherBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

class ActivityFetcherBuilder extends AbstractServiceBuilder
{
/**
* @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\EmailFetcher
*/
public function emailFetcher(): Activity\ReadModel\EmailFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -34,9 +31,6 @@ public function emailFetcher(): Activity\ReadModel\EmailFetcher
return $this->serviceCache[__METHOD__];
}

/**
* @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\OpenLineFetcher
*/
public function openLineFetcher(): Activity\ReadModel\OpenLineFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -46,9 +40,6 @@ public function openLineFetcher(): Activity\ReadModel\OpenLineFetcher
return $this->serviceCache[__METHOD__];
}

/**
* @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\VoximplantFetcher
*/
public function voximplantFetcher(): Activity\ReadModel\VoximplantFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -58,9 +49,6 @@ public function voximplantFetcher(): Activity\ReadModel\VoximplantFetcher
return $this->serviceCache[__METHOD__];
}

/**
* @return \Bitrix24\SDK\Services\CRM\Activity\ReadModel\WebFormFetcher
*/
public function webFormFetcher(): Activity\ReadModel\WebFormFetcher
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -69,4 +57,4 @@ public function webFormFetcher(): Activity\ReadModel\WebFormFetcher

return $this->serviceCache[__METHOD__];
}
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityNotifyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ enum ActivityNotifyType: int
case minutes = 1;
case hours = 2;
case days = 3;
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityPriority.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ enum ActivityPriority: int
case low = 1;
case medium = 2;
case high = 3;
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ enum ActivityStatus: int
case waiting = 1;
case finished = 2;
case finishedAutomatically = 3;
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/ActivityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ enum ActivityType: int
case letter = 4;
case action = 5;
case userAction = 6;
}
}
10 changes: 2 additions & 8 deletions src/Services/CRM/Activity/ReadModel/EmailFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class EmailFetcher
{
private BulkItemsReaderInterface $bulkItemsReader;

/**
* @param BulkItemsReaderInterface $bulkItemsReader
*/
public function __construct(BulkItemsReaderInterface $bulkItemsReader)
public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
$this->bulkItemsReader = $bulkItemsReader;
}

/**
Expand All @@ -55,4 +49,4 @@ public function getList(array $order, array $filter, array $select, ?int $limit
yield $cnt => new EmailActivityItemResult($item);
}
}
}
}
10 changes: 2 additions & 8 deletions src/Services/CRM/Activity/ReadModel/OpenLineFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class OpenLineFetcher
{
private BulkItemsReaderInterface $bulkItemsReader;

/**
* @param BulkItemsReaderInterface $bulkItemsReader
*/
public function __construct(BulkItemsReaderInterface $bulkItemsReader)
public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
$this->bulkItemsReader = $bulkItemsReader;
}

/**
Expand All @@ -59,4 +53,4 @@ public function getList(array $order, array $filter, array $select, ?int $openLi
yield $cnt => new OpenLineActivityItemResult($item);
}
}
}
}
10 changes: 2 additions & 8 deletions src/Services/CRM/Activity/ReadModel/VoximplantFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class VoximplantFetcher
{
private BulkItemsReaderInterface $bulkItemsReader;

/**
* @param BulkItemsReaderInterface $bulkItemsReader
*/
public function __construct(BulkItemsReaderInterface $bulkItemsReader)
public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
$this->bulkItemsReader = $bulkItemsReader;
}

/**
Expand All @@ -55,4 +49,4 @@ public function getList(array $order, array $filter, array $select, ?int $limit
yield $cnt => new ActivityItemResult($item);
}
}
}
}
11 changes: 3 additions & 8 deletions src/Services/CRM/Activity/ReadModel/WebFormFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@
#[ApiBatchServiceMetadata(new Scope(['crm']))]
class WebFormFetcher
{
private BulkItemsReaderInterface $bulkItemsReader;

/**
* @param BulkItemsReaderInterface $bulkItemsReader
*/
public function __construct(BulkItemsReaderInterface $bulkItemsReader)
public function __construct(private readonly BulkItemsReaderInterface $bulkItemsReader)
{
$this->bulkItemsReader = $bulkItemsReader;
}

/**
Expand All @@ -55,8 +49,9 @@ public function getList(array $order, array $filter, array $select, ?int $webFor
} else {
$filter = array_merge($filter, ['PROVIDER_ID' => 'CRM_WEBFORM']);
}

foreach ($this->bulkItemsReader->getTraversableList('crm.activity.list', $order, $filter, $select, $limit) as $cnt => $item) {
yield $cnt => new WebFormActivityItemResult($item);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/Result/ActivitiesResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public function getActivities(): array

return $res;
}
}
}
9 changes: 6 additions & 3 deletions src/Services/CRM/Activity/Result/ActivityItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @property-read ActivityDirectionType $DIRECTION // with crm_enum_activity direction type
* @property-read int $EDITOR_ID // Editor
* @property-read CarbonImmutable $END_TIME // Completion time
* @property-read array $FILES // Added files with diskfile type
* @property-read int $FILES // Added files with diskfile type
* @property-read int $ID // Activity ID
* @property-read boolean $IS_INCOMING_CHANNEL
* @property-read CarbonImmutable $LAST_UPDATED // Date of the last update date
Expand Down Expand Up @@ -67,8 +67,11 @@
* @property-read ActivityStatus $STATUS
* @property-read string $SUBJECT
* @property-read ActivityType $TYPE_ID
* @property-read array $WEBDAV_ELEMENTS
* @property-read int $WEBDAV_ELEMENTS
* @property-read int $AUTHOR_ID
* @property-read int $AUTOCOMPLETE_RULE
* @property-read ActivityPriority $PRIORITY
*/
class ActivityItemResult extends AbstractCrmItem
{
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Activity/Result/ActivityResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function activity(): ActivityItemResult
{
return new ActivityItemResult($this->getCoreResponse()->getResponseData()->getResult());
}
}
}
28 changes: 28 additions & 0 deletions src/Services/CRM/Activity/Result/ActivityTypeResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Gleb Starikov <[email protected]>
*
* 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\CRM\Activity\Result;

use Bitrix24\SDK\Services\CRM\Common\Result\AbstractCrmItem;

/**
* @see https://apidocs.bitrix24.com/api-reference/crm/timeline/activities/types/crm-activity-type-add.html
*
* @property-read string $TYPE_ID
* @property-read string $NAME
* @property-read string $IS_CONFIGURABLE_TYPE
* @property-read string $ICON_ID
*/
class ActivityTypeResult extends AbstractCrmItem
{
}
42 changes: 42 additions & 0 deletions src/Services/CRM/Activity/Result/ActivityTypesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Gleb Starikov <[email protected]>
*
* 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\CRM\Activity\Result;

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

/**
* @see https://apidocs.bitrix24.com/api-reference/crm/timeline/activities/types/crm-activity-type-add.html
*
* @property-read string $TYPE_ID
* @property-read string $NAME
* @property-read string $IS_CONFIGURABLE_TYPE
* @property-read int $ICON_ID
*/
class ActivityTypesResult extends AbstractResult
{
/**
* @return \Bitrix24\SDK\Services\CRM\Activity\Result\ActivityTypeResult[]
* @throws BaseException
*/
public function getActivityTypes(): array
{
$res = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$res[] = new ActivityTypeResult($item);
}

return $res;
}
}
30 changes: 30 additions & 0 deletions src/Services/CRM/Activity/Result/CommunicationItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Gleb Starikov <[email protected]>
*
* 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\CRM\Activity\Result;

use Bitrix24\SDK\Services\CRM\Common\Result\AbstractCrmItem;

/**
* @see https://apidocs.bitrix24.ru/api-reference/crm/timeline/activities/activity-base/crm-activity-communication-fields.html
*
* @property-read int $ID
* @property-read int $ACTIVITY_ID
* @property-read int $ENTITY_ID
* @property-read int $ENTITY_TYPE_ID
* @property-read string $TYPE
* @property-read string $VALUE
*/
class CommunicationItemResult extends AbstractCrmItem
{
}
Loading
Loading