PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.31
Booking for Appointments and Events Calendar – Amelia v1.2.31
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 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 / Services / Notification / ApplicationNotificationService.php
ameliabooking / src / Application / Services / Notification Last commit date
AbstractNotificationService.php 1 year ago AbstractWhatsAppNotificationService.php 1 year ago ApplicationNotificationService.php 1 year ago AppointmentNotificationService.php 1 year ago BasicWhatsAppNotificationService.php 1 year ago EmailNotificationService.php 1 year ago NotificationHelperService.php 1 year ago SMSAPIService.php 1 year ago SMSNotificationService.php 1 year ago
ApplicationNotificationService.php
278 lines
1 <?php
2
3 /**
4 * @copyright © TMS-Plugins. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace AmeliaBooking\Application\Services\Notification;
9
10 use AmeliaBooking\Domain\Collection\Collection;
11 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
12 use AmeliaBooking\Domain\Entity\Booking\Appointment\Appointment;
13 use AmeliaBooking\Domain\Services\Settings\SettingsService;
14 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
15 use AmeliaBooking\Infrastructure\Common\Container;
16 use AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException;
17 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
18 use Interop\Container\Exception\ContainerException;
19 use Slim\Exception\ContainerValueNotFoundException;
20
21 /**
22 * Class ApplicationNotificationService
23 *
24 * @package AmeliaBooking\Application\Services\Notification
25 */
26 class ApplicationNotificationService
27 {
28 protected $container;
29
30 /**
31 * ApplicationNotificationService constructor.
32 *
33 * @param Container $container
34 */
35 public function __construct(Container $container)
36 {
37 $this->container = $container;
38 }
39
40 /**
41 * @param Appointment $appointment
42 * @param bool $logNotification
43 *
44 * @throws InvalidArgumentException
45 * @throws QueryExecutionException
46 * @throws ContainerException
47 */
48 public function sendAppointmentProviderStatusNotifications(
49 $appointment,
50 $logNotification = true
51 ) {
52 /** @var SettingsService $settingsService */
53 $settingsService = $this->container->get('domain.settings.service');
54
55 /** @var AppointmentNotificationService $appointmentNotificationService */
56 $appointmentNotificationService = $this->container->get('application.notification.appointment.service');
57
58 /** @var EmailNotificationService $emailNotificationService */
59 $emailNotificationService = $this->container->get('application.emailNotification.service');
60
61 /** @var SMSNotificationService $smsNotificationService */
62 $smsNotificationService = $this->container->get('application.smsNotification.service');
63
64 /** @var AbstractWhatsAppNotificationService $whatsAppNotificationService */
65 $whatsAppNotificationService = $this->container->get('application.whatsAppNotification.service');
66
67 $appointmentNotificationService->sendProviderStatusNotifications(
68 $emailNotificationService,
69 $appointment,
70 $logNotification
71 );
72
73 if ($settingsService->getSetting('notifications', 'smsSignedIn') === true) {
74 $appointmentNotificationService->sendProviderStatusNotifications(
75 $smsNotificationService,
76 $appointment,
77 $logNotification
78 );
79 }
80
81 if ($whatsAppNotificationService->checkRequiredFields()) {
82 $appointmentNotificationService->sendProviderStatusNotifications(
83 $whatsAppNotificationService,
84 $appointment,
85 $logNotification
86 );
87 }
88 }
89
90 /**
91 * @param Appointment $appointment
92 * @param Collection $bookings
93 * @param bool $logNotification
94 * @param bool $isBackend
95 * @param bool $sendInvoice
96 *
97 * @throws InvalidArgumentException
98 * @throws QueryExecutionException
99 * @throws NotFoundException
100 * @throws ContainerException
101 */
102 public function sendAppointmentCustomersStatusNotifications(
103 $appointment,
104 $bookings,
105 $logNotification = true,
106 $isBackend = true,
107 $sendInvoice = false,
108 $notifyCustomers = true
109 ) {
110 /** @var SettingsService $settingsService */
111 $settingsService = $this->container->get('domain.settings.service');
112
113 /** @var AppointmentNotificationService $appointmentNotificationService */
114 $appointmentNotificationService = $this->container->get('application.notification.appointment.service');
115
116 /** @var EmailNotificationService $emailNotificationService */
117 $emailNotificationService = $this->container->get('application.emailNotification.service');
118
119 /** @var SMSNotificationService $smsNotificationService */
120 $smsNotificationService = $this->container->get('application.smsNotification.service');
121
122 /** @var AbstractWhatsAppNotificationService $whatsAppNotificationService */
123 $whatsAppNotificationService = $this->container->get('application.whatsAppNotification.service');
124
125 $appointmentNotificationService->sendCustomersStatusNotifications(
126 $emailNotificationService,
127 $appointment,
128 $bookings,
129 $logNotification,
130 $isBackend,
131 $sendInvoice,
132 $notifyCustomers
133 );
134
135 if ($settingsService->getSetting('notifications', 'smsSignedIn') === true) {
136 $appointmentNotificationService->sendCustomersStatusNotifications(
137 $smsNotificationService,
138 $appointment,
139 $bookings,
140 $logNotification,
141 $isBackend,
142 $sendInvoice
143 );
144 }
145
146 if ($whatsAppNotificationService->checkRequiredFields()) {
147 $appointmentNotificationService->sendCustomersStatusNotifications(
148 $whatsAppNotificationService,
149 $appointment,
150 $bookings,
151 $logNotification,
152 $isBackend,
153 $sendInvoice
154 );
155 }
156 }
157
158 /**
159 * @param Appointment $appointment
160 * @param bool $notifyProvider
161 * @param bool $notifyCustomers
162 *
163 * @throws QueryExecutionException
164 * @throws InvalidArgumentException
165 */
166 public function sendAppointmentRescheduleNotifications(
167 $appointment,
168 $notifyProvider = true,
169 $notifyCustomers = true
170 ) {
171 /** @var SettingsService $settingsService */
172 $settingsService = $this->container->get('domain.settings.service');
173
174 /** @var AppointmentNotificationService $appointmentNotificationService */
175 $appointmentNotificationService = $this->container->get('application.notification.appointment.service');
176
177 /** @var EmailNotificationService $emailNotificationService */
178 $emailNotificationService = $this->container->get('application.emailNotification.service');
179
180 /** @var SMSNotificationService $smsNotificationService */
181 $smsNotificationService = $this->container->get('application.smsNotification.service');
182
183 /** @var AbstractWhatsAppNotificationService $whatsAppNotificationService */
184 $whatsAppNotificationService = $this->container->get('application.whatsAppNotification.service');
185
186 $appointmentNotificationService->sendRescheduledNotifications(
187 $emailNotificationService,
188 $appointment,
189 $notifyProvider,
190 $notifyCustomers
191 );
192
193 if ($settingsService->getSetting('notifications', 'smsSignedIn') === true) {
194 $appointmentNotificationService->sendRescheduledNotifications(
195 $smsNotificationService,
196 $appointment,
197 $notifyProvider,
198 $notifyCustomers
199 );
200 }
201
202 if ($whatsAppNotificationService->checkRequiredFields()) {
203 $appointmentNotificationService->sendRescheduledNotifications(
204 $whatsAppNotificationService,
205 $appointment,
206 $notifyProvider,
207 $notifyCustomers
208 );
209 }
210 }
211
212 /**
213 * @param Appointment $appointment
214 * @param int|null $changedProviderId
215 * @param bool $notifyProvider
216 * @param bool $notifyCustomers
217 *
218 * @throws QueryExecutionException
219 * @throws InvalidArgumentException
220 */
221 public function sendAppointmentUpdatedNotifications(
222 $appointment,
223 $changedProviderId,
224 $notifyProvider = true,
225 $notifyCustomers = true
226 ) {
227 /** @var SettingsService $settingsService */
228 $settingsService = $this->container->get('domain.settings.service');
229
230 /** @var AppointmentNotificationService $appointmentNotificationService */
231 $appointmentNotificationService = $this->container->get('application.notification.appointment.service');
232
233 /** @var EmailNotificationService $emailNotificationService */
234 $emailNotificationService = $this->container->get('application.emailNotification.service');
235
236 /** @var SMSNotificationService $smsNotificationService */
237 $smsNotificationService = $this->container->get('application.smsNotification.service');
238
239 /** @var AbstractWhatsAppNotificationService $whatsAppNotificationService */
240 $whatsAppNotificationService = $this->container->get('application.whatsAppNotification.service');
241
242 if ($changedProviderId) {
243 $newProviderId = $appointment->getProviderId()->getValue();
244
245 $appointment->setProviderId(new Id($changedProviderId));
246 }
247
248 $appointmentNotificationService->sendUpdatedNotifications(
249 $emailNotificationService,
250 $appointment,
251 $notifyProvider,
252 $notifyCustomers
253 );
254
255 if ($settingsService->getSetting('notifications', 'smsSignedIn') === true) {
256 $appointmentNotificationService->sendUpdatedNotifications(
257 $smsNotificationService,
258 $appointment,
259 $notifyProvider,
260 $notifyCustomers
261 );
262 }
263
264 if ($whatsAppNotificationService->checkRequiredFields()) {
265 $appointmentNotificationService->sendUpdatedNotifications(
266 $whatsAppNotificationService,
267 $appointment,
268 $notifyProvider,
269 $notifyCustomers
270 );
271 }
272
273 if ($changedProviderId) {
274 $appointment->setProviderId(new Id($newProviderId));
275 }
276 }
277 }
278