AddAppointmentCommand.php
7 years ago
AddAppointmentCommandHandler.php
1 year ago
AddBookingCommand.php
7 years ago
AddBookingCommandHandler.php
1 year ago
ApproveBookingRemotelyCommand.php
2 years ago
ApproveBookingRemotelyCommandHandler.php
1 year ago
CancelBookingCommand.php
7 years ago
CancelBookingCommandHandler.php
2 years ago
CancelBookingRemotelyCommand.php
7 years ago
CancelBookingRemotelyCommandHandler.php
2 years ago
DeleteAppointmentCommand.php
7 years ago
DeleteAppointmentCommandHandler.php
2 years ago
DeleteBookingCommand.php
4 years ago
DeleteBookingCommandHandler.php
2 years ago
GetAppointmentCommand.php
7 years ago
GetAppointmentCommandHandler.php
1 year ago
GetAppointmentsCommand.php
7 years ago
GetAppointmentsCommandHandler.php
1 year ago
GetIcsCommand.php
5 years ago
GetIcsCommandHandler.php
4 years ago
GetPackageAppointmentsCommand.php
1 year ago
GetPackageAppointmentsCommandHandler.php
1 year ago
GetTimeSlotsCommand.php
7 years ago
GetTimeSlotsCommandHandler.php
1 year ago
ReassignBookingCommand.php
5 years ago
ReassignBookingCommandHandler.php
1 year ago
RejectBookingRemotelyCommand.php
2 years ago
RejectBookingRemotelyCommandHandler.php
1 year ago
SuccessfulBookingCommand.php
7 years ago
SuccessfulBookingCommandHandler.php
1 year ago
UpdateAppointmentCommand.php
7 years ago
UpdateAppointmentCommandHandler.php
1 year ago
UpdateAppointmentStatusCommand.php
7 years ago
UpdateAppointmentStatusCommandHandler.php
1 year ago
UpdateAppointmentTimeCommand.php
7 years ago
UpdateAppointmentTimeCommandHandler.php
1 year ago
UpdateBookingStatusCommand.php
1 year ago
UpdateBookingStatusCommandHandler.php
1 year 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 |