Skip to content
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 @@ -27,6 +27,7 @@
->in(__DIR__ . '/src/Services/Sale/')
->in(__DIR__ . '/src/Services/Disk/')
->in(__DIR__ . '/src/Services/Calendar/')
->in(__DIR__ . '/src/Services/Booking/')
->in(__DIR__ . '/src/Services/Lists/')
->in(__DIR__ . '/src/Services/SonetGroup/')
->name('*.php')
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

### Added

- Added `Services\Booking\BookingServiceBuilder` with Booking scope wrappers and integration coverage for `booking.v1.clienttype.*`, `booking.v1.resourceType.*`, `booking.v1.resource.*`, `booking.v1.resource.slots.*`, `booking.v1.waitlist.*`, `booking.v1.waitlist.client.*`, `booking.v1.waitlist.externalData.*`, `booking.v1.booking.*`, `booking.v1.booking.client.*`, and `booking.v1.booking.externalData.*` methods.
Comment thread
fatestr1ngs marked this conversation as resolved.

### Changed

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ help:
@echo "test-integration-sale-payment-item-basket - run PaymentItemBasket integration tests"
@echo "test-integration-sale-payment-item-shipment - run PaymentItemShipment integration tests"
@echo "test-integration-sale-property-relation - run PropertyRelation integration tests"
@echo "test-integration-scope-booking - run Booking integration tests"
@echo "test-integration-landing-page - run Landing Page integration tests"
@echo "test-integration-landing-syspage - run Landing SysPage integration tests"
@echo "test-integration-landing-repo - run Landing Repo integration tests"
Expand Down Expand Up @@ -405,6 +406,10 @@ test-integration-landing-role:
test-integration-scope-sonet-group:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_sonet_group

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

.PHONY: test-integration-scope-disk
test-integration-scope-disk:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_disk
Expand Down
2 changes: 1 addition & 1 deletion docs/open-api/openapi.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ parameters:
- tests/Integration/Services/Landing
- tests/Integration/Services/Disk
- tests/Integration/Services/Calendar
- tests/Integration/Services/Booking
- tests/Integration/Services/Lists
- tests/Integration/Services/CRM/Documentgenerator/Numerator
- tests/Integration/Services/CRM/Documentgenerator/Document
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@
<testsuite name="integration_tests_scope_sonet_group">
<directory>./tests/Integration/Services/SonetGroup/</directory>
</testsuite>
<testsuite name="integration_tests_scope_booking">
<directory>./tests/Integration/Services/Booking/</directory>
</testsuite>
<testsuite name="integration_tests_scope_main_eventlog">
<file>./tests/Integration/Services/Main/Service/EventLogTest.php</file>
<file>./tests/Integration/Services/Main/EventLogField/Service/EventLogFieldTest.php</file>
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
__DIR__ . '/tests/Integration/Services/Disk',
__DIR__ . '/src/Services/Calendar',
__DIR__ . '/tests/Integration/Services/Calendar',
__DIR__ . '/src/Services/Booking',
__DIR__ . '/tests/Integration/Services/Booking',
__DIR__ . '/src/Services/Lists',
__DIR__ . '/tests/Integration/Services/Lists',
__DIR__ . '/src/Services/CRM/Documentgenerator/Numerator',
Expand Down
11 changes: 11 additions & 0 deletions src/Core/EndpointUrlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ public function format(
'tasks.flow.Flow.isExists',
'tasks.flow.Flow.activate',
'tasks.flow.Flow.pin',
'booking.v1.resourceType.add',
'booking.v1.resourceType.update',
'booking.v1.resourceType.get',
'booking.v1.resourceType.list',
'booking.v1.resourceType.delete',
'booking.v1.waitlist.externalData.list',
'booking.v1.waitlist.externalData.set',
'booking.v1.waitlist.externalData.unset',
'booking.v1.booking.externalData.list',
'booking.v1.booking.externalData.set',
'booking.v1.booking.externalData.unset',
];
if (!in_array($apiMethod, $caseSensitiveMethods, true)) {
$apiMethod = strtolower($apiMethod);
Expand Down
29 changes: 29 additions & 0 deletions src/Services/Booking/Booking/Result/AddedBookingResult.php
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.
*
* © Veronica Akhmetova <264936994+fatestr1ngs@users.noreply.github.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\Booking\Booking\Result;

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

class AddedBookingResult extends AddedItemResult
{
/**
* @throws BaseException
*/
#[\Override]
public function getId(): int
{
return (int)$this->getCoreResponse()->getResponseData()->getResult()[0];
}
}
27 changes: 27 additions & 0 deletions src/Services/Booking/Booking/Result/BookingItemResult.php
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.
*
* © Veronica Akhmetova <264936994+fatestr1ngs@users.noreply.github.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\Booking\Booking\Result;

use Bitrix24\SDK\Core\Result\AbstractAnnotatedItem;

/**
* @property-read int|null $id
* @property-read string|null $name
* @property-read string|null $description
* @property-read array<string, mixed>|null $datePeriod
* @property-read array<int, int>|null $resourceIds
*/
class BookingItemResult extends AbstractAnnotatedItem
{
}
28 changes: 28 additions & 0 deletions src/Services/Booking/Booking/Result/BookingResult.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.
*
* © Veronica Akhmetova <264936994+fatestr1ngs@users.noreply.github.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\Booking\Booking\Result;

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

class BookingResult extends AbstractResult
{
/**
* @throws BaseException
*/
public function getBooking(): BookingItemResult
{
return new BookingItemResult($this->getCoreResponse()->getResponseData()->getResult()['booking']);
}
}
34 changes: 34 additions & 0 deletions src/Services/Booking/Booking/Result/BookingsResult.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.
*
* © Veronica Akhmetova <264936994+fatestr1ngs@users.noreply.github.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\Booking\Booking\Result;

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

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

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

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Veronica Akhmetova <264936994+fatestr1ngs@users.noreply.github.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\Booking\Booking\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\Booking\Booking\Result\AddedBookingResult;
use Bitrix24\SDK\Services\Booking\Booking\Result\BookingResult;
use Bitrix24\SDK\Services\Booking\Booking\Result\BookingsResult;
use Psr\Log\LoggerInterface;

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

/**
* Adds a booking.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-add.html
*
* @param array<string, mixed> $fields
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.add',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-add.html',
'Adds a booking.'
)]
public function add(array $fields): AddedBookingResult
{
return new AddedBookingResult(
$this->core->call('booking.v1.booking.add', [
'fields' => $fields,
])
);
}

/**
* Creates a booking from a waitlist entry.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-createfromwaitlist.html
*
* @param array<string, mixed> $fields
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.createfromwaitlist',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-createfromwaitlist.html',
'Creates a booking from a waitlist entry.'
)]
public function createFromWaitlist(int $waitListId, array $fields = []): AddedItemResult
{
return new AddedItemResult(
$this->core->call('booking.v1.booking.createfromwaitlist', [
'waitListId' => $waitListId,
'fields' => $fields,
])
);
}

/**
* Updates a booking.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-update.html
*
* @param array<string, mixed> $fields
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.update',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-update.html',
'Updates a booking.'
)]
public function update(int $id, array $fields): UpdatedItemResult
{
return new UpdatedItemResult(
$this->core->call('booking.v1.booking.update', [
'id' => $id,
'fields' => $fields,
])
);
}

/**
* Retrieves a booking.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-get.html
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.get',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-get.html',
'Retrieves a booking.'
)]
public function get(int $id): BookingResult
{
return new BookingResult(
$this->core->call('booking.v1.booking.get', [
'id' => $id,
])
);
}

/**
* Retrieves a list of bookings.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-list.html
*
* @param array<string, mixed> $filter
* @param array<string, string> $order
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.list',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-list.html',
'Retrieves a list of bookings.'
)]
public function list(array $filter = [], array $order = []): BookingsResult
{
return new BookingsResult(
$this->core->call('booking.v1.booking.list', [
'filter' => $filter,
'order' => $order,
])
);
}

/**
* Deletes a booking.
*
* @link https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-delete.html
*
* @throws BaseException
* @throws TransportException
*/
#[ApiEndpointMetadata(
'booking.v1.booking.delete',
'https://apidocs.bitrix24.com/api-reference/booking/booking/booking-v1-booking-delete.html',
'Deletes a booking.'
)]
public function delete(int $id): DeletedItemResult
{
return new DeletedItemResult(
$this->core->call('booking.v1.booking.delete', [
'id' => $id,
])
);
}
}
Loading