-
Notifications
You must be signed in to change notification settings - Fork 57
Add scope Booking wrappers #476
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
Draft
fatestr1ngs
wants to merge
1
commit into
bitrix24:v3-dev
Choose a base branch
from
fatestr1ngs:feature/473-add-booking-scope-v3
base: v3-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Services/Booking/Booking/Result/AddedBookingResult.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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']); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| ]) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.