Skip to content

Feature/194 add crm status #195

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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
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 @@ -12,6 +12,7 @@
->in(__DIR__ . '/src/Services/CRM/Quote/')
->in(__DIR__ . '/src/Services/CRM/Lead/')
->in(__DIR__ . '/src/Services/CRM/Currency/')
->in(__DIR__ . '/src/Services/CRM/Status/')
->name('*.php')
->exclude(['vendor', 'storage', 'docker', 'docs']) // Exclude directories
->ignoreDotFiles(true)
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

### Added

- Added service `Services\CRM\Status\Service\Status` with support methods,
see [crm.status.* methods](https://github.com/bitrix24/b24phpsdk/issues/194):
- `fields` returns descriptions of reference book fields
- `get` returns an element of the reference book by its identifier
- `list` returns a list of elements of the reference book by filter, with batch calls support
- `add` creates a new element in the specified reference book, with batch calls support
- `delete` deletes an element from the reference book, with batch calls support
- `update` updates an existing element of the reference book, with batch calls support
- `countByFilter` counts elements of the reference book by filter
- Added service `Services\CRM\Status\Service\StatusEntity` with support methods,
- `items` returns elements of the reference book by its symbolic identifier
- `types` returns descriptions of reference book types
- Added service `Services\CRM\Lead\Service\LeadContact` with support methods,
see [crm.lead.contact.* methods](https://github.com/bitrix24/b24phpsdk/issues/170):
- `fields` get fiels for lead contact connection
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ integration_tests_lead_productrows:
.PHONY: integration_tests_crm_quote
integration_tests_crm_quote:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_crm_quote

.PHONY: integration_tests_crm_status
integration_tests_crm_status:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_crm_status

# work dev environment
.PHONY: 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 @@ -26,6 +26,7 @@ parameters:
- tests/Integration/Services/CRM/Quote/Service/QuoteProductRowsTest.php
- tests/Integration/Services/CRM/Lead/Service/LeadUserfieldTest.php
- tests/Integration/Services/CRM/Currency
- tests/Integration/Services/CRM/Status
bootstrapFiles:
- tests/bootstrap.php
parallel:
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<testsuite name="integration_tests_crm_quote">
<directory>./tests/Integration/Services/CRM/Quote/</directory>
</testsuite>
<testsuite name="integration_tests_crm_status">
<directory>./tests/Integration/Services/CRM/Status/</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
25 changes: 25 additions & 0 deletions src/Services/CRM/CRMServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,29 @@ public function duplicate(): Duplicates\Service\Duplicate

return $this->serviceCache[__METHOD__];
}

public function status(): Status\Service\Status
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Status\Service\Status(
new Status\Service\Batch($this->batch, $this->log),
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function statusEntity(): Status\Service\StatusEntity
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Status\Service\StatusEntity(
$this->core,
$this->log
);
}

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

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* Class StatusEntitiesResult
*
* @package Bitrix24\SDK\Services\CRM\Status\Result
*/
class StatusEntitiesResult extends AbstractResult
{
/**
* @return StatusEntityItemResult[]
* @throws BaseException
*/
public function getEntities(): array
{
$res = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$res[] = new StatusEntityItemResult($item);
}

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

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* @property-read string $NAME
* @property-read int $SORT
* @property-read string $STATUS_ID
*/
class StatusEntityItemResult extends AbstractCrmItem
{
}
31 changes: 31 additions & 0 deletions src/Services/CRM/Status/Result/StatusEntityTypeItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* @property-read string $ID
* @property-read string $NAME
* @property-read string $PARENT_ID
* @property-read array $SEMANTIC_INFO
* @property-read int $ENTITY_TYPE_ID
* @property-read string $PREFIX
* @property-read string $FIELD_ATTRIBUTE_SCOPE
* @property-read int $CATEGORY_ID
* @property-read bool $IS_ENABLED
*/
class StatusEntityTypeItemResult extends AbstractCrmItem
{
}
40 changes: 40 additions & 0 deletions src/Services/CRM/Status/Result/StatusEntityTypesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* Class StatusEntityTypesResult
*
* @package Bitrix24\SDK\Services\CRM\Status\Result
*/
class StatusEntityTypesResult extends AbstractResult
{
/**
* @return StatusEntityTypeItemResult[]
* @throws BaseException
*/
public function getEntityTypes(): array
{
$res = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$res[] = new StatusEntityTypeItemResult($item);
}

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

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* Class StatusItemResult
*
* @property-read int $ID
* @property-read string|null $ENTITY_ID
* @property-read string|null $STATUS_ID
* @property-read int|null $SORT
* @property-read string|null $NAME
* @property-read string|null $NAME_INIT
* @property-read bool|null $SYSTEM
* @property-read int|null $CATEGORY_ID
* @property-read string|null $COLOR
* @property-read bool|null $SEMANTICS
* @property-read array|null $EXTRA
*/
class StatusItemResult extends AbstractCrmItem
{
}
33 changes: 33 additions & 0 deletions src/Services/CRM/Status/Result/StatusResult.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.
*
* © Vadim Soluyanov <[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\Status\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* Class StatusResult
*
* @package Bitrix24\SDK\Services\CRM\Status\Result
*/
class StatusResult extends AbstractResult
{
/**
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function status(): StatusItemResult
{
return new StatusItemResult($this->getCoreResponse()->getResponseData()->getResult());
}
}
40 changes: 40 additions & 0 deletions src/Services/CRM/Status/Result/StatusesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <[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\Status\Result;

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

/**
* Class StatusesResult
*
* @package Bitrix24\SDK\Services\CRM\Status\Result
*/
class StatusesResult extends AbstractResult
{
/**
* @return StatusItemResult[]
* @throws BaseException
*/
public function getStatuses(): array
{
$items = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$items[] = new StatusItemResult($item);
}

return $items;
}
}
Loading