Skip to content
Merged
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 @@ -17,6 +17,7 @@
->in(__DIR__ . '/src/Services/CRM/Timeline/')
->in(__DIR__ . '/src/Services/Entity/Section/')
->in(__DIR__ . '/src/Services/Department/')
->in(__DIR__ . '/src/Services/Sale/')
->in(__DIR__ . '/src/Services/Task/')
->in(__DIR__ . '/src/Services/Sale/')
->name('*.php')
Expand Down
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run integration tests for Sale scope",
"type": "shell",
"command": "make test-integration-scope-sale",
"args": [],
"isBackground": false,
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

### Added

- Added service `Services\Sale\PersonTypeStatus\Service\PersonTypeStatus` with support methods,
see [sale.businessValuePersonDomain.* methods](https://github.com/bitrix24/b24phpsdk/issues/228):
- `add` adds business value for person domain
- `list` retrieves list of business values for person domain
- `delete` deletes business values by filter
- `getFields` gets fields description for business value person domain
- Added service `Services\Task\Service\Task` with support methods,
see [tasks.task.* methods](https://github.com/bitrix24/b24phpsdk/issues/214):
- `add` creates a task, with batch calls support
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<testsuite name="integration_tests_department">
<directory>./tests/Integration/Services/Department/</directory>
</testsuite>
<testsuite name="integration_tests_scope_sale">
<directory>./tests/Integration/Services/Sale/</directory>
</testsuite>
<testsuite name="integration_tests_task">
<directory>./tests/Integration/Services/Task/</directory>
</testsuite>
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.
*
* © Vadim Soluyanov <vadimsallee@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\Sale\PersonTypeStatus\Result;

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

class PersonTypeStatusAddResult extends AddedItemResult
{
/**
* @throws BaseException
*/
public function isSuccess(): bool
{
$result = $this->getCoreResponse()->getResponseData()->getResult();
return isset($result['businessValuePersonDomain']);
}
}
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.
*
* © Vadim Soluyanov <vadimsallee@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\Sale\PersonTypeStatus\Result;

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

class PersonTypeStatusFieldsResult extends FieldsResult
{
/**
* @throws BaseException
*/
public function getFieldsDescription(): array
{
return $this->getCoreResponse()->getResponseData()->getResult()['businessValuePersonDomain'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

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

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* Class PersonTypeStatusItemResult
*
* @property-read string|null $domain
* @property-read int|null $personTypeId
*/
class PersonTypeStatusItemResult extends AbstractItem
{
// Access individual fields via magic getters, e.g. $item->domain, $item->personTypeId
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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

use Bitrix24\SDK\Core\Result\AbstractResult;

class PersonTypeStatusesResult extends AbstractResult
{
/**
* @return PersonTypeStatusItemResult[]
*/
public function getPersonTypeStatuses(): array
{
$items = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult()['businessValuePersonDomains'] as $item) {
$items[] = new PersonTypeStatusItemResult($item);
}

return $items;
}
}
138 changes: 138 additions & 0 deletions src/Services/Sale/PersonTypeStatus/Service/PersonTypeStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Vadim Soluyanov <vadimsallee@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\Sale\PersonTypeStatus\Service;

use Bitrix24\SDK\Attributes\ApiEndpointMetadata;
use Bitrix24\SDK\Core\Contracts\CoreInterface;
use Bitrix24\SDK\Services\AbstractService;
use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Result\PersonTypeStatusesResult;
use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Result\PersonTypeStatusFieldsResult;
use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Result\PersonTypeStatusAddResult;
use Bitrix24\SDK\Core\Result\DeletedItemResult;
use Psr\Log\LoggerInterface;

class PersonTypeStatus extends AbstractService
{
public function __construct(CoreInterface $core, LoggerInterface $logger)
{
parent::__construct($core, $logger);
}

/**
* Add business value for person domain.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-add.html
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
#[ApiEndpointMetadata(
'sale.businessValuePersonDomain.add',
'https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-add.html',
'Add business value for person domain'
)]
public function add(int $personTypeId, string $domain): PersonTypeStatusAddResult
{
return new PersonTypeStatusAddResult(
$this->core->call(
'sale.businessValuePersonDomain.add',
[
'fields' => [
'personTypeId' => $personTypeId,
'domain' => $domain
]
]
)
);
}

/**
* Retrieves list of business values for person domain.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-list.html
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
#[ApiEndpointMetadata(
'sale.businessValuePersonDomain.list',
'https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-list.html',
'List business values for person domain'
)]
public function list(array $filter = [], array $order = [], array $select = [], ?int $start = null): PersonTypeStatusesResult
{
$params = ['filter' => $filter, 'order' => $order, 'select' => $select];
if ($start !== null) {
$params['start'] = $start;
}

return new PersonTypeStatusesResult(
$this->core->call(
'sale.businessValuePersonDomain.list',
$params
)
);
}

/**
* Delete business values matching filter.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-delete-by-filter.html
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
#[ApiEndpointMetadata(
'sale.businessValuePersonDomain.deleteByFilter',
'https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-delete-by-filter.html',
'Delete business values by filter'
)]
public function delete(int $personTypeId, string $domain): DeletedItemResult
{
return new DeletedItemResult(
$this->core->call(
'sale.businessValuePersonDomain.deleteByFilter',
['fields' =>
[
'personTypeId' => $personTypeId,
'domain' => $domain
]
]
)
);
}

/**
* Get fields description for business value person domain.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-getfields.html
*
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
*/
#[ApiEndpointMetadata(
'sale.businessValuePersonDomain.getFields',
'https://apidocs.bitrix24.com/api-reference/sale/business-value-person-domain/sale-business-value-person-domain-getfields.html',
'Get fields for business value person domain'
)]
public function getFields(): PersonTypeStatusFieldsResult
{
return new PersonTypeStatusFieldsResult(
$this->core->call(
'sale.businessValuePersonDomain.getFields',
[]
)
);
}
}
14 changes: 13 additions & 1 deletion src/Services/Sale/SaleServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@
use Bitrix24\SDK\Attributes\ApiServiceBuilderMetadata;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Services\AbstractServiceBuilder;
use Bitrix24\SDK\Services\Sale\PersonTypeStatus\Service\PersonTypeStatus;

#[ApiServiceBuilderMetadata(new Scope(['sale']))]
class SaleServiceBuilder extends AbstractServiceBuilder
{
public function personTypeStatus(): PersonTypeStatus
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new PersonTypeStatus(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

public function personType(): PersonType\Service\PersonType
{
if (!isset($this->serviceCache[__METHOD__])) {
Expand All @@ -31,5 +44,4 @@ public function personType(): PersonType\Service\PersonType

return $this->serviceCache[__METHOD__];
}

}
2 changes: 1 addition & 1 deletion src/Services/ServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,4 @@ public function getAiAdminScope(): AIServiceBuilder

return $this->serviceCache[__METHOD__];
}
}
}
Loading