AddAppointmentCommand.php
1 year ago
AddAppointmentCommandHandler.php
2 months ago
AddBookingCommand.php
1 year ago
AddBookingCommandHandler.php
1 year ago
ApproveBookingRemotelyCommand.php
1 year ago
ApproveBookingRemotelyCommandHandler.php
2 months ago
CancelBookingCommand.php
1 year ago
CancelBookingCommandHandler.php
6 months ago
CancelBookingRemotelyCommand.php
1 year ago
CancelBookingRemotelyCommandHandler.php
1 month ago
DeleteAppointmentCommand.php
1 year ago
DeleteAppointmentCommandHandler.php
1 year ago
DeleteBookingCommand.php
1 year ago
DeleteBookingCommandHandler.php
10 months ago
DeleteBookingRemotelyCommand.php
10 months ago
DeleteBookingRemotelyCommandHandler.php
6 months ago
GetAppointmentBookingsCommand.php
6 months ago
GetAppointmentBookingsCommandHandler.php
2 months ago
GetAppointmentCommand.php
7 years ago
GetAppointmentCommandHandler.php
2 weeks ago
GetAppointmentsCommand.php
1 year ago
GetAppointmentsCommandHandler.php
2 weeks ago
GetIcsCommand.php
6 months ago
GetIcsCommandHandler.php
4 years ago
GetTimeSlotsCommand.php
1 year ago
GetTimeSlotsCommandHandler.php
1 month ago
ReassignBookingCommand.php
1 year ago
ReassignBookingCommandHandler.php
3 months ago
RejectBookingRemotelyCommand.php
1 year ago
RejectBookingRemotelyCommandHandler.php
4 months ago
SuccessfulBookingCommand.php
1 year ago
SuccessfulBookingCommandHandler.php
1 year ago
UpdateAppointmentCommand.php
1 year ago
UpdateAppointmentCommandHandler.php
3 months ago
UpdateAppointmentNoteCommand.php
3 months ago
UpdateAppointmentNoteCommandHandler.php
3 months ago
UpdateAppointmentStatusCommand.php
1 year ago
UpdateAppointmentStatusCommandHandler.php
2 months ago
UpdateAppointmentTimeCommand.php
1 year ago
UpdateAppointmentTimeCommandHandler.php
1 month ago
UpdateBookingStatusCommand.php
1 year ago
UpdateBookingStatusCommandHandler.php
5 months ago
GetIcsCommandHandler.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Commands\Booking\Appointment; |
| 4 | |
| 5 | use AmeliaBooking\Application\Commands\CommandHandler; |
| 6 | use AmeliaBooking\Application\Commands\CommandResult; |
| 7 | use AmeliaBooking\Application\Services\Booking\IcsApplicationService; |
| 8 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 9 | use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException; |
| 10 | use Interop\Container\Exception\ContainerException; |
| 11 | use Slim\Exception\ContainerValueNotFoundException; |
| 12 | use UnexpectedValueException; |
| 13 | |
| 14 | /** |
| 15 | * Class GetIcsCommandHandler |
| 16 | * |
| 17 | * @package AmeliaBooking\Application\Commands\Booking\Appointment |
| 18 | */ |
| 19 | class GetIcsCommandHandler extends CommandHandler |
| 20 | { |
| 21 | /** |
| 22 | * @param GetIcsCommand $command |
| 23 | * |
| 24 | * @return CommandResult |
| 25 | * @throws UnexpectedValueException |
| 26 | * @throws ContainerValueNotFoundException |
| 27 | * @throws InvalidArgumentException |
| 28 | * @throws ContainerException |
| 29 | * @throws QueryExecutionException |
| 30 | */ |
| 31 | public function handle(GetIcsCommand $command) |
| 32 | { |
| 33 | $result = new CommandResult(); |
| 34 | |
| 35 | /** @var IcsApplicationService $icsService */ |
| 36 | $icsService = $this->container->get('application.ics.service'); |
| 37 | |
| 38 | $result->setAttachment(true); |
| 39 | |
| 40 | if (!$command->getField('params')['token']) { |
| 41 | $result->setResult(CommandResult::RESULT_ERROR); |
| 42 | |
| 43 | return $result; |
| 44 | } |
| 45 | |
| 46 | $result->setFile( |
| 47 | $icsService->getIcsData( |
| 48 | $command->getField('params')['type'], |
| 49 | $command->getArg('id'), |
| 50 | !empty($command->getField('params')['recurring']) ? |
| 51 | $command->getField('params')['recurring'] : [], |
| 52 | false, |
| 53 | $command->getField('params')['token'] |
| 54 | )['translated'][0] |
| 55 | ); |
| 56 | |
| 57 | return $result; |
| 58 | } |
| 59 | } |
| 60 |