bundles/VehicleIngestBundle/Controller/LeasingController.php line 51

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace VehicleIngestBundle\Controller;
  4. use Pimcore\Controller\FrontendController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Messenger\MessageBusInterface;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use VehicleIngestBundle\Message\IngestLeasingMessage;
  10. use VehicleIngestBundle\Service\ErrorResponseFactory;
  11. /**
  12.  * Accept-and-enqueue only: this controller's job is purely to satisfy the mobile.de seller-api
  13.  * contract (200 on PUT, 204 on DELETE) so the automedia exporter doesn't error on the leasing
  14.  * sub-resource, and to hand the payload off to Messenger. The actual persistence (mapping onto
  15.  * the vehicle's `Leasing` objectbrick + filterRate) happens asynchronously in
  16.  * IngestLeasingMessageHandler/LeasingMapper (Plan 3, Task 5) - kept off the request path so a
  17.  * slow/delayed leasing push never blocks the automedia exporter's ack.
  18.  */
  19. class LeasingController extends FrontendController
  20. {
  21.     public function __construct(
  22.         private MessageBusInterface $bus,
  23.         private ErrorResponseFactory $errors,
  24.     ) {
  25.     }
  26.     /**
  27.      * @Route("/seller-api/sellers/{sellerId}/ads/{adId}/leasing", name="seller_api_ad_leasing_put", methods={"PUT"}, requirements={"adId"="\d+"})
  28.      */
  29.     public function putLeasingAction(Request $requeststring $adId): Response
  30.     {
  31.         $data json_decode($request->getContent(), true);
  32.         if (!is_array($data)) {
  33.             return $this->errors->keyed('body');
  34.         }
  35.         $this->bus->dispatch(new IngestLeasingMessage($adId'upsert'$data));
  36.         return new Response(''Response::HTTP_OK);
  37.     }
  38.     /**
  39.      * @Route("/seller-api/sellers/{sellerId}/ads/{adId}/leasing", name="seller_api_ad_leasing_delete", methods={"DELETE"}, requirements={"adId"="\d+"})
  40.      */
  41.     public function deleteLeasingAction(string $adId): Response
  42.     {
  43.         $this->bus->dispatch(new IngestLeasingMessage($adId'delete'null));
  44.         return new Response(''Response::HTTP_NO_CONTENT);
  45.     }
  46. }