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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

### Added

- Added services `Services\Catalog\Enum\Service\CatalogEnum`, `Services\Catalog\Extra\Service\Extra`
and `Services\Catalog\Measure\Service\Measure` with support for `catalog.enum.*`, `catalog.extra.*`
and `catalog.measure.*` methods,
see [catalog.enum.* methods](https://apidocs.bitrix24.com/api-reference/catalog/enum/index.html),
[catalog.extra.* methods](https://apidocs.bitrix24.com/api-reference/catalog/extra/index.html) and
[catalog.measure.* methods](https://apidocs.bitrix24.com/api-reference/catalog/measure/index.html) ([#530](https://github.com/bitrix24/b24phpsdk/issues/530)):
- `CatalogEnum::getRoundTypes` returns available catalog rounding types
- `CatalogEnum::getStoreDocumentTypes` returns available store accounting document types
- `Extra::get` gets information about a markup by its identifier
- `Extra::list` gets a list of markups by filter
- `Extra::fields` returns the description of markup fields
- `Measure::add` creates a new measurement unit
- `Measure::update` updates an existing measurement unit
- `Measure::get` gets information about a measurement unit by its identifier
- `Measure::list` gets the list of measurement units
- `Measure::delete` deletes a measurement unit
- `Measure::fields` returns the description of measurement unit fields
- 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-catalog-enum
test-integration-catalog-enum:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_enum

.PHONY: test-integration-catalog-extra
test-integration-catalog-extra:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_extra

.PHONY: test-integration-catalog-measure
test-integration-catalog-measure:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_catalog_measure

# work dev environment
.PHONY: php-dev-server-up
php-dev-server-up:
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_catalog_enum">
<directory>./tests/Integration/Services/Catalog/Enum/</directory>
</testsuite>
<testsuite name="integration_tests_catalog_extra">
<directory>./tests/Integration/Services/Catalog/Extra/</directory>
</testsuite>
<testsuite name="integration_tests_catalog_measure">
<directory>./tests/Integration/Services/Catalog/Measure/</directory>
</testsuite>
</testsuites>
<source>
<include>
Expand Down
39 changes: 38 additions & 1 deletion src/Services/Catalog/CatalogServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Bitrix24\SDK\Services\AbstractServiceBuilder;
use Bitrix24\SDK\Services\Catalog;
#[ApiServiceBuilderMetadata(new Scope(['catalog']))]

class CatalogServiceBuilder extends AbstractServiceBuilder
{
public function product(): Catalog\Product\Service\Product
Expand All @@ -44,4 +45,40 @@ public function catalog(): Catalog\Catalog\Service\Catalog

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

public function catalogEnum(): Catalog\Enum\Service\CatalogEnum
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Catalog\Enum\Service\CatalogEnum(
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}

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

return $this->serviceCache[__METHOD__];
}

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

return $this->serviceCache[__METHOD__];
}
}
24 changes: 24 additions & 0 deletions src/Services/Catalog/Enum/Result/RoundTypeItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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\Catalog\Enum\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read int $id
* @property-read string $name
*/
class RoundTypeItemResult extends AbstractItem
{
}
34 changes: 34 additions & 0 deletions src/Services/Catalog/Enum/Result/RoundTypesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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\Catalog\Enum\Result;

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

class RoundTypesResult extends AbstractResult
{
/**
* @return RoundTypeItemResult[]
* @throws BaseException
*/
public function getRoundTypes(): array
{
$items = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult()['enum'] as $item) {
$items[] = new RoundTypeItemResult($item);
}

return $items;
}
}
24 changes: 24 additions & 0 deletions src/Services/Catalog/Enum/Result/StoreDocumentTypeItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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\Catalog\Enum\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read string $id
* @property-read string $name
*/
class StoreDocumentTypeItemResult extends AbstractItem
{
}
34 changes: 34 additions & 0 deletions src/Services/Catalog/Enum/Result/StoreDocumentTypesResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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\Catalog\Enum\Result;

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

class StoreDocumentTypesResult extends AbstractResult
{
/**
* @return StoreDocumentTypeItemResult[]
* @throws BaseException
*/
public function getStoreDocumentTypes(): array
{
$items = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult()['enum'] as $item) {
$items[] = new StoreDocumentTypeItemResult($item);
}

return $items;
}
}
61 changes: 61 additions & 0 deletions src/Services/Catalog/Enum/Service/CatalogEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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\Catalog\Enum\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\Catalog\Enum\Result\RoundTypesResult;
use Bitrix24\SDK\Services\Catalog\Enum\Result\StoreDocumentTypesResult;

#[ApiServiceMetadata(new Scope(['catalog']))]
class CatalogEnum extends AbstractService
{
/**
* Returns a list of rounding types available in the catalog.
*
* @link https://apidocs.bitrix24.com/api-reference/catalog/enum/catalog-enum-get-round-types.html
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'catalog.enum.getRoundTypes',
'https://apidocs.bitrix24.com/api-reference/catalog/enum/catalog-enum-get-round-types.html',
'Returns a list of rounding types available in the catalog.'
)]
public function getRoundTypes(): RoundTypesResult
{
return new RoundTypesResult($this->core->call('catalog.enum.getRoundTypes'));
}

/**
* Returns the types of store accounting documents available for REST.
*
* @link https://apidocs.bitrix24.com/api-reference/catalog/enum/catalog-enum-get-store-document-types.html
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'catalog.enum.getStoreDocumentTypes',
'https://apidocs.bitrix24.com/api-reference/catalog/enum/catalog-enum-get-store-document-types.html',
'Returns the types of store accounting documents available for REST.'
)]
public function getStoreDocumentTypes(): StoreDocumentTypesResult
{
return new StoreDocumentTypesResult($this->core->call('catalog.enum.getStoreDocumentTypes'));
}
}
37 changes: 37 additions & 0 deletions src/Services/Catalog/Extra/Result/ExtraItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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\Catalog\Extra\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;
use MoneyPHP\Percentage\Percentage;

/**
* @property-read int $id
* @property-read string $name
* @property-read Percentage $percentage
*/
class ExtraItemResult extends AbstractItem
{
/**
* @param int|string $offset
*/
public function __get($offset): mixed
{
if ($offset === 'percentage') {
return new Percentage((string)$this->data[$offset]);
}

return parent::__get($offset);
}
}
28 changes: 28 additions & 0 deletions src/Services/Catalog/Extra/Result/ExtraResult.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.
*
* © 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\Catalog\Extra\Result;

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

class ExtraResult extends AbstractResult
{
/**
* @throws BaseException
*/
public function extra(): ExtraItemResult
{
return new ExtraItemResult($this->getCoreResponse()->getResponseData()->getResult()['extra']);
}
}
Loading
Loading