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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@
- `list` returns a list of payments
- `delete` deletes a payment
- `getFields` returns the fields and settings for payments
- Added service `Services\Sale\CashboxHandler\Service\CashboxHandler` with support methods,
see [sale.cashbox.handler.* methods](https://github.com/bitrix24/b24phpsdk/issues/258):
- `add` adds a REST cashbox handler
- `update` updates the data of the REST cashbox handler
- `list` returns a list of available REST cashbox handlers
- `delete` deletes the REST cashbox handler
- Added service `Services\Sale\Cashbox\Service\Cashbox` with support methods,
see [sale.cashbox.* methods](https://github.com/bitrix24/b24phpsdk/issues/258):
- `add` adds a new cash register
- `update` updates an existing cash register
- `list` returns a list of configured cash registers
- `delete` deletes a cash register
- `checkApply` saves the result of printing the receipt
- Added service `Services\Calendar\Service\Calendar` with support methods,
see [calendar.* methods](https://github.com/bitrix24/b24phpsdk/issues/263):
- `add` adds a new calendar section
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ help:
@echo "test-integration-calendar-event - run Calendar Event integration tests"
@echo "test-integration-calendar-resource - run Calendar Resource integration tests"
@echo "test-integration-sale-basket-property - run BasketProperty integration tests"
@echo "test-integration-sale-cashbox-handler - run CashboxHandler integration tests"
@echo "test-integration-sale-cashbox - run Cashbox integration tests"
@echo "test-integration-sale-delivery - run Delivery integration tests"
@echo "test-integration-sale-delivery-extra-service - run DeliveryExtraService integration tests"
@echo "test-integration-scope-paysystem - run Payment System integration tests"
Expand Down Expand Up @@ -279,6 +281,14 @@ test-integration-sale-basket:
test-integration-sale-order:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_order

.PHONY: test-integration-sale-cashbox-handler
test-integration-sale-cashbox-handler:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_cashbox_handler

.PHONY: test-integration-sale-cashbox
test-integration-sale-cashbox:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_cashbox

.PHONY: test-integration-sale-payment-item-basket
test-integration-sale-payment-item-basket:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_sale_payment_item_basket
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@
<testsuite name="integration_tests_sale_order">
<directory>./tests/Integration/Services/Sale/Order/</directory>
</testsuite>
<testsuite name="integration_tests_sale_cashbox_handler">
<directory>./tests/Integration/Services/Sale/CashboxHandler/</directory>
</testsuite>
<testsuite name="integration_tests_sale_cashbox">
<directory>./tests/Integration/Services/Sale/Cashbox/</directory>
</testsuite>
<testsuite name="integration_tests_sale_delivery_handler">
<directory>./tests/Integration/Services/Sale/DeliveryHandler/Service/</directory>
</testsuite>
Expand Down
35 changes: 35 additions & 0 deletions src/Services/Sale/Cashbox/Result/CashboxItemResult.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.
*
* © Sally Fancen <[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\Sale\Cashbox\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* Class CashboxItemResult
*
* @property-read int|null $ID
* @property-read string|null $NAME
* @property-read string|null $REST_CODE
* @property-read string|null $EMAIL
* @property-read string|null $OFD
* @property-read array|null $OFD_SETTINGS
* @property-read string|null $NUMBER_KKM
* @property-read string|null $ACTIVE
* @property-read int|null $SORT
* @property-read string|null $USE_OFFLINE
* @property-read array|null $SETTINGS
*/
class CashboxItemResult extends AbstractItem
{
}
37 changes: 37 additions & 0 deletions src/Services/Sale/Cashbox/Result/CashboxesResult.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.
*
* © Sally Fancen <[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\Sale\Cashbox\Result;

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

/**
* Result for sale.cashbox.list
*/
class CashboxesResult extends AbstractResult
{
/**
* @return CashboxItemResult[]
* @throws BaseException
*/
public function getCashboxes(): array
{
$result = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$result[] = new CashboxItemResult($item);
}

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

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Sally Fancen <[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\Sale\Cashbox\Service;

use Bitrix24\SDK\Attributes\ApiEndpointMetadata;
use Bitrix24\SDK\Attributes\ApiServiceMetadata;
use Bitrix24\SDK\Core\Contracts\CoreInterface;
use Bitrix24\SDK\Core\Credentials\Scope;
use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Exceptions\TransportException;
use Bitrix24\SDK\Core\Result\AddedItemResult;
use Bitrix24\SDK\Core\Result\DeletedItemResult;
use Bitrix24\SDK\Core\Result\UpdatedItemResult;
use Bitrix24\SDK\Services\AbstractService;
use Bitrix24\SDK\Services\Sale\Cashbox\Result\CashboxesResult;
use Psr\Log\LoggerInterface;

#[ApiServiceMetadata(new Scope(['sale', 'cashbox']))]
class Cashbox extends AbstractService
{
public function __construct(CoreInterface $core, LoggerInterface $logger)
{
parent::__construct($core, $logger);
}

/**
* Adds a new cash register.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-add.html
*
* @param array $fields Fields for cash register creation (NAME*, REST_CODE*, EMAIL*, OFD, OFD_SETTINGS, NUMBER_KKM, ACTIVE, SORT, USE_OFFLINE, SETTINGS)
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'sale.cashbox.add',
'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-add.html',
'Adds a new cash register.'
)]
public function add(array $fields): AddedItemResult
{
return new AddedItemResult(
$this->core->call('sale.cashbox.add', $fields)
);
}

/**
* Updates an existing cash register.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-update.html
*
* @param int $id Identifier of the cash register
* @param array $fields Fields to update (NAME, EMAIL, OFD, OFD_SETTINGS, NUMBER_KKM, ACTIVE, SORT, USE_OFFLINE, SETTINGS)
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'sale.cashbox.update',
'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-update.html',
'Updates an existing cash register.'
)]
public function update(int $id, array $fields): UpdatedItemResult
{
return new UpdatedItemResult(
$this->core->call('sale.cashbox.update', [
'ID' => $id,
'FIELDS' => $fields,
])
);
}

/**
* Returns a list of configured cash registers.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-list.html
*
* @param array|null $select Fields to select
* @param array|null $filter Filter conditions
* @param array|null $order Sorting parameters
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'sale.cashbox.list',
'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-list.html',
'Returns a list of configured cash registers.'
)]
public function list(?array $select = null, ?array $filter = null, ?array $order = null): CashboxesResult
{
$params = [];
if ($select !== null) {
$params['SELECT'] = $select;
}

if ($filter !== null) {
$params['FILTER'] = $filter;
}

if ($order !== null) {
$params['ORDER'] = $order;
}

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

/**
* Deletes a cash register.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-delete.html
*
* @param int $id Identifier of the cash register to be deleted
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'sale.cashbox.delete',
'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-delete.html',
'Deletes a cash register.'
)]
public function delete(int $id): DeletedItemResult
{
return new DeletedItemResult(
$this->core->call('sale.cashbox.delete', [
'ID' => $id,
])
);
}

/**
* Saves the result of printing the receipt.
*
* @link https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-check-apply.html
*
* @param array $fields Fields for receipt result (UUID*, PRINT_END_TIME, REG_NUMBER_KKT, FISCAL_DOC_ATTR, FISCAL_DOC_NUMBER, FISCAL_RECEIPT_NUMBER, FN_NUMBER, SHIFT_NUMBER)
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'sale.cashbox.check.apply',
'https://apidocs.bitrix24.com/api-reference/sale/cashbox/sale-cashbox-check-apply.html',
'Saves the result of printing the receipt.'
)]
public function checkApply(array $fields): UpdatedItemResult
{
return new UpdatedItemResult(
$this->core->call('sale.cashbox.check.apply', $fields)
);
}
}
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.
*
* © Sally Fancen <[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\Sale\CashboxHandler\Result;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* Class CashboxHandlerItemResult
*
* @property-read int|null $ID
* @property-read string|null $NAME
* @property-read string|null $CODE
* @property-read int|null $SORT
* @property-read array|null $SETTINGS
* @property-read string|null $SETTINGS.PRINT_URL
* @property-read string|null $SETTINGS.CHECK_URL
* @property-read string|null $SETTINGS.HTTP_VERSION
* @property-read array|null $SETTINGS.CONFIG
* @property-read string|null $SETTINGS.SUPPORTS_FFD105
*/
class CashboxHandlerItemResult extends AbstractItem
{
}
37 changes: 37 additions & 0 deletions src/Services/Sale/CashboxHandler/Result/CashboxHandlersResult.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.
*
* © Sally Fancen <[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\Sale\CashboxHandler\Result;

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

/**
* Result for sale.cashbox.handler.list
*/
class CashboxHandlersResult extends AbstractResult
{
/**
* @return CashboxHandlerItemResult[]
* @throws BaseException
*/
public function getCashboxHandlers(): array
{
$result = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult() as $item) {
$result[] = new CashboxHandlerItemResult($item);
}

return $result;
}
}
Loading