From 28b939a969692e60b508944b380e03a5afcc933b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 11 Aug 2020 11:10:24 +0000 Subject: [PATCH] Add SMS messaging to customer when rider fulfills a JO from rider app. #464 --- .../RiderAPIHandler/ResqRiderAPIHandler.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index 138b7989..5f6a920f 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -21,6 +21,7 @@ use App\Service\MQTTClient; use App\Service\WarrantyHandler; use App\Service\JobOrderHandlerInterface; use App\Service\InvoiceGeneratorInterface; +use App\Service\RisingTideGateway; use App\Entity\RiderSession; use App\Entity\Rider; @@ -45,12 +46,13 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface protected $jo_handler; protected $ic; protected $session; + protected $rt; public function __construct(EntityManagerInterface $em, RedisClientProvider $redis, EncoderFactoryInterface $ef, RiderCache $rcache, string $country_code, MQTTClient $mclient, WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler, - InvoiceGeneratorInterface $ic) + InvoiceGeneratorInterface $ic, RisingTideGateway $rt) { $this->em = $em; $this->redis = $redis; @@ -61,6 +63,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface $this->wh = $wh; $this->jo_handler = $jo_handler; $this->ic = $ic; + $this->rt = $rt; // one device = one session, since we have control over the devices // when a rider logs in, we just change the rider assigned to the device @@ -579,6 +582,15 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface ]; $this->mclient->sendEvent($jo, $payload); + // send SMS to customer + $phone_number = $jo->getCustomer()->getPhoneMobile(); + if (!empty($phone_number)) + { + // TODO: put this in config file or somewhere + $message = "Your Resq job order has been completed."; + $this->rt->sendSMS($phone_number, 'MOTOLITE', $message); + } + return $data; }