src/Api/SmsController.php line 64

Open in your IDE?
  1. <?php
  2. namespace App\Api;
  3. use App\Entity\Sms;
  4. use App\Entity\Station;
  5. use App\Entity\WayBill;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. use Doctrine\Persistence\ObjectManager;
  8. use FOS\RestBundle\Controller\AbstractFOSRestController;
  9. use FOS\RestBundle\Controller\Annotations as Rest;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. class SmsController extends AbstractFOSRestController {
  14.     private ObjectManager $em;
  15.     public function __construct(ManagerRegistry $registry)
  16.     {
  17.         $this->em $registry->getManager();
  18.     }
  19.     // {
  20.     //     phoneNumber: '+254721459276',
  21.     //     failureReason: 'UserInBlackList',
  22.     //     retryCount: '0',
  23.     //     id: 'ATXid_05fa295f25664bce10c2813df28ddcc4',
  24.     //     status: 'Failed',
  25.     //     networkCode: '63902'
  26.     // }
  27.     // {
  28.     //      "phoneNumber":"+254721459276",
  29.     //      "failureReason":"UserInBlackList",
  30.     //      "retryCount":"0",
  31.     //      "id":"ATXid_9dc512ca196b7f93002724bff2f0db97",
  32.     //      "status":"Failed",
  33.     //      "networkCode":"63902"
  34.     //  }
  35.     /**
  36.      * @Rest\Get("/sms/failed/{stationId}", name="failed_sms")
  37.      */
  38.     public function  getFailedSms(Request $request$stationId)
  39.     {
  40.         $failedDeliveryNotifications $this->em->getRepository(WayBill::class)->findFailedSms($stationId);
  41. //        return $this->view($failedDeliveryNotifications, Response::HTTP_OK);
  42.         return new JsonResponse($failedDeliveryNotificationsResponse::HTTP_OK);
  43.     }
  44.     /**
  45.      * @Rest\Patch ("/sms/failed/{station_id}/{sms_id}", name="failed_sms_update")
  46.      */
  47.     public function  updateManuallySentSMS(Request $request$station_id,$sms_id)
  48.     {
  49.         $sms $this->em->getRepository(Sms::class)->findOneBy([
  50.             'id' => $sms_id
  51.         ]);
  52.         $sms->setManuallySent(true);
  53.         $this->em->flush();
  54.         $failedDeliveryNotifications $this->em->getRepository(WayBill::class)->findFailedSms($station_id);
  55. //        return $this->view($failedDeliveryNotifications, Response::HTTP_OK);
  56.         return new JsonResponse($failedDeliveryNotificationsResponse::HTTP_OK);
  57.     }
  58. }