PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Application / Commands / Notification / SendAmeliaSmsApiRequestCommandHandler.php
ameliabooking / src / Application / Commands / Notification Last commit date
GetNotificationsCommand.php 7 years ago GetNotificationsCommandHandler.php 2 years ago GetSMSNotificationsHistoryCommand.php 7 years ago GetSMSNotificationsHistoryCommandHandler.php 2 years ago SendAmeliaSmsApiRequestCommand.php 7 years ago SendAmeliaSmsApiRequestCommandHandler.php 2 years ago SendTestEmailCommand.php 7 years ago SendTestEmailCommandHandler.php 2 years ago SendUndeliveredNotificationsCommand.php 4 years ago SendUndeliveredNotificationsCommandHandler.php 2 years ago UpdateNotificationCommand.php 7 years ago UpdateNotificationCommandHandler.php 2 years ago UpdateNotificationStatusCommand.php 7 years ago UpdateNotificationStatusCommandHandler.php 2 years ago UpdateSMSNotificationHistoryCommand.php 7 years ago UpdateSMSNotificationHistoryCommandHandler.php 1 year ago
SendAmeliaSmsApiRequestCommandHandler.php
59 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Commands\Notification;
4
5 use AmeliaBooking\Application\Commands\CommandHandler;
6 use AmeliaBooking\Application\Commands\CommandResult;
7 use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException;
8 use AmeliaBooking\Application\Services\Notification\SMSAPIService;
9 use AmeliaBooking\Domain\Entity\Entities;
10 use Interop\Container\Exception\ContainerException;
11
12 /**
13 * Class SendAmeliaSmsApiRequestCommandHandler
14 *
15 * @package AmeliaBooking\Application\Commands\Notification
16 */
17 class SendAmeliaSmsApiRequestCommandHandler extends CommandHandler
18 {
19 /**
20 * @param SendAmeliaSmsApiRequestCommand $command
21 *
22 * @return CommandResult
23 *
24 * @throws ContainerException
25 * @throws AccessDeniedException
26 */
27 public function handle(SendAmeliaSmsApiRequestCommand $command)
28 {
29 if (!$this->getContainer()->getPermissionsService()->currentUserCanWrite(Entities::NOTIFICATIONS)) {
30 throw new AccessDeniedException('You are not allowed to send test email');
31 }
32
33 $result = new CommandResult();
34
35 /** @var SMSAPIService $smsApiService */
36 $smsApiService = $this->getContainer()->get('application.smsApi.service');
37
38
39 $action = $command->getField('process');
40
41 $data = $command->getField('data');
42
43 $data = apply_filters('amelia_before_send_sms_request_filter', $data, $action);
44
45 do_action('amelia_before_send_sms_request', $data, $action);
46
47 // Call method dynamically and pass data to the function. Method name is the request field.
48 $apiResponse = $smsApiService->{$action}($data);
49
50 do_action('amelia_after_send_sms_request', $data, $action);
51
52 $result->setResult(CommandResult::RESULT_SUCCESS);
53 $result->setMessage('Amelia SMS API request successful');
54 $result->setData($apiResponse);
55
56 return $result;
57 }
58 }
59