vendor/launchpad/backend/src/Admin/Api/Controller/AccountController.php line 18

Open in your IDE?
  1. <?php
  2. namespace LaunchPad\Bundle\LaunchPadBundle\Admin\Api\Controller;
  3. use LaunchPad\Bundle\LaunchPadBundle\Admin\Api\Request\Account\InitializeAccountRequest;
  4. use LaunchPad\Bundle\LaunchPadBundle\Base\Entity\Account\Account;
  5. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\AccountService;
  6. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\Translation\TranslationService;
  7. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\UserService;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use OpenApi\Annotations as OA;
  10. /**
  11.  * Class PaymentDeviceController
  12.  * @package BoBoFin\Admin\Api\Controller
  13.  * @Route("/account", name="admin_account_")
  14.  */
  15. class AccountController extends BaseAdminApiController
  16. {
  17.     /** @var AccountService  */
  18.     private $accountService;
  19.     public function __construct(
  20.         TranslationService $translationService,
  21.         AccountService $accountService
  22.     ) {
  23.         parent::__construct($translationService);
  24.         $this->accountService $accountService;
  25.     }
  26.     /**
  27.      * @Route("/list", name="list")
  28.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  29.      * @throws \Doctrine\Common\Annotations\AnnotationException
  30.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  31.      *
  32.      * @OA\Post(
  33.      *      path="/account/list",
  34.      *      operationId="listAccounts",
  35.      *      tags={"Account"},
  36.      *      summary="Account",
  37.      *      description="List all accounts",
  38.      *      @OA\Response(
  39.      *          response=200,
  40.      *          description="Successful operation",
  41.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  42.      *      ),
  43.      *      security={
  44.      *          {"Bearer": {}}
  45.      *      }
  46.      * )
  47.      */
  48.     public function getAccountListAction()
  49.     {
  50.         $list $this->paginatorService->getPaginated(
  51.             Account::class,
  52.             $this->data
  53.         );
  54.         return $this->success($listnull, ['account_data''basic_data']);
  55.     }
  56.     /**
  57.      * @Route("/details", name="details")
  58.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  59.      * @throws \Doctrine\Common\Annotations\AnnotationException
  60.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  61.      *
  62.      * @OA\Post(
  63.      *      path="/account/details",
  64.      *      operationId="Accounts",
  65.      *      tags={"Account"},
  66.      *      summary="Account",
  67.      *      description="Get Account Details ",
  68.      *      @OA\Response(
  69.      *          response=200,
  70.      *          description="Successful operation",
  71.      *          @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  72.      *      ),
  73.      *      security={
  74.      *          {"Bearer": {}}
  75.      *      }
  76.      * )
  77.      */
  78.     public function getAccountDetailsAction()
  79.     {
  80.         $this->requirePostParams(['id']);
  81.         $result $this->accountService->getAccountById($this->data['id']);
  82.         return $this->success($resultnull, ['account_data''basic_data']);
  83.     }
  84.     /**
  85.      * @Route("/initialize", name="initialize")
  86.      * @param UserService $userService
  87.      * @param AccountService $accountService
  88.      * @return \Symfony\Component\HttpFoundation\JsonResponse
  89.      * @throws \Doctrine\Common\Annotations\AnnotationException
  90.      * @throws \LaunchPad\Bundle\LaunchPadBundle\Base\Exception\MissingApiParamsException
  91.      * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
  92.      */
  93.     public function initializeAction(UserService $userServiceAccountService $accountService)
  94.     {
  95.         $request $this->validateRequest(InitializeAccountRequest::class);
  96.         $user $userService->getUserById($request->id);
  97.         if(!$user) return $this->failure('User not found');
  98.         $accountService->userCreated($user);
  99.         return $this->success();
  100.     }
  101. }