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