src/Controller/Api/Agents/DefaultController.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by JosuĂ© Yannick Cruz Sandoval <josue.yannick@gmail.com>
  4. <<<<<<< HEAD
  5.  * Date created 06/10/2020 03:23 p. m.
  6. =======
  7.  * Date created 07/10/2020 05:41 p. m.
  8. >>>>>>> sprint6.1
  9.  */
  10. namespace App\Controller\Api\Agents;
  11. use App\Controller\Api\Webhooks\MetamapWebhook;
  12. use App\Controller\ApiBaseController;
  13. use App\ExternalProvider\MiddlewarePlatformService;
  14. use Doctrine\Persistence\ManagerRegistry;
  15. use FOS\RestBundle\Controller\Annotations as Rest;
  16. use FOS\RestBundle\Controller\Annotations\Post;
  17. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  18. use Symfony\Component\HttpFoundation\JsonResponse;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. class DefaultController extends ApiBaseController
  23. {
  24.     #[Route(path'/')]
  25.     function index(Request $request): JsonResponse|Response
  26.     {
  27.         if (str_contains($request->getHost(), 'adminmerchant')) {
  28.             return $this->redirectToRoute('agents_home');
  29.         } else {
  30.             return $this->apiResponse();
  31.         }
  32.     }
  33.     #[Route(path'/bind/webhook/metamap'methods: ["POST"])]
  34.     function bindWebhookMetamap(Request $requestMetamapWebhook $metamapWebhookParameterBagInterface $paramsManagerRegistry $mr): JsonResponse|Response
  35.     {
  36.         return $metamapWebhook->handle($request$params$mr);
  37.     }
  38.     /**
  39.      *
  40.      * @return JsonResponse|Response
  41.      * @throws \Exception
  42.      */
  43.     #[Rest\Get('/supported-app-versions'name'api_agents_supported_app_versions')]
  44.     function getSupportedAppVersions(MiddlewarePlatformService $platformService): JsonResponse|Response
  45.     {
  46.         return $this->apiResponse([
  47.             'versions' => $platformService->getSupportedAppVersions(),
  48.             'date' => (new \DateTime('now', new \DateTimeZone('UTC')))
  49.                 ->format(\DateTime::ISO8601)
  50.         ]);
  51.     }
  52.     /**
  53.      * @return JsonResponse|Response
  54.      */
  55.     #[Rest\Post('/public/testDataWithFiles')]
  56.     function testFileSend(Request $request): JsonResponse|Response
  57.     {
  58.         return $this->apiResponse([
  59.             'data' => $request->request->all(),
  60.             'files' => $request->files->all(),
  61.         ]);
  62.     }
  63. }