/**
  * @Req\Route("/credit/me/pick-profile")
  * @Req\Method({"GET"})
  *
  * @return JsonResponse
  */
 public function pickAction()
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     return new JsonResponse($this->pickProfileApiWorker->pick($uniqueness));
 }
Exemple #2
0
 /**
  * @Req\Route("/info-sms/me/buy-package")
  * @Req\Method({"POST"})
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function buyAction(Request $request)
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $data = $request->request->all();
     foreach (array('id') as $key) {
         Assertion::keyExists($data, $key);
     }
     try {
         $this->buyPackageApiWorker->buy($uniqueness, $data['id']);
     } catch (InsufficientBalanceApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.PROFILE.INSUFFICIENT_BALANCE'), 400);
     }
     return new JsonResponse(['infoSmsProfile' => $this->pickInfoSmsProfileApiWorker->pick($uniqueness), 'creditProfile' => $this->pickCreditProfileApiWorker->pick($uniqueness)]);
 }