src/Opportunity/Controller/Proxy/OpportunityProxyController.php line 67

  1. <?php
  2. namespace App\Opportunity\Controller\Proxy;
  3. use App\Core\Util\HttpClient;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. #[Route(path'/api/opportunities'name'opportunity_opportunities_')]
  8. class OpportunityProxyController extends AbstractOpportunityProxyController
  9. {
  10.     protected static function basePath(): string
  11.     {
  12.         return '/opportunities';
  13.     }
  14.     #[Route('/opportunities'methods: ['GET'])]
  15.     public function index(HttpClient $client): Response
  16.     {
  17.         return $this->forwardGet($client);
  18.     }
  19.     #[Route('/opportunities/{id}'name'by_id'methods: ['GET'])]
  20.     public function getById(HttpClient $clientint $id): Response
  21.     {
  22.         if ($id <= 0) {
  23.             return new JsonResponse(['error' => 'Invalid id'], 400);
  24.         }
  25.         return $this->forwardGet($client'/' $id);
  26.     }
  27.     #[Route('/opportunities/init'name'init'methods: ['POST'])]
  28.     public function init(HttpClient $client): Response
  29.     {
  30.         return $this->forwardJson($client'POST');
  31.     }
  32.     #[Route('/opportunities'name'save'methods: ['POST'])]
  33.     public function save(HttpClient $client): Response
  34.     {
  35.         return $this->forwardJson($client'POST');
  36.     }
  37.     #[Route('/opportunities/{id}'name'edit'methods: ['PUT'])]
  38.     public function edit(HttpClient $clientint $id): Response
  39.     {
  40.         if ($id <= 0) {
  41.             return new JsonResponse(['error' => 'Invalid id'], 400);
  42.         }
  43.         return $this->forwardJson($client'PUT''/' $id);
  44.     }
  45.     #[Route('/{id}'name'delete'methods: ['DELETE'])]
  46.     public function delete(HttpClient $clientint $id): Response
  47.     {
  48.         if ($id <= 0) {
  49.             return new JsonResponse(['error' => 'Invalid id'], 400);
  50.         }
  51.         return $this->forwardDelete($client'/' $id);
  52.     }
  53.     #[Route('/opportunities/statistics/perStatus'methods: ['GET'])]
  54.     public function statistics(HttpClient $client): Response
  55.     {
  56.         return $this->forwardGet($client);
  57.     }
  58. }