/**
  * @Req\Route("/info-sms/me/delete-subscription/{mobile}")
  * @Req\Method({"POST"})
  *
  * @param string  $mobile
  *
  * @return JsonResponse
  */
 public function deleteAction($mobile)
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $this->deleteSubscriptionApiWorker->delete($mobile, $uniqueness);
     return new JsonResponse($this->collectSubscriptionsApiWorker->collect($uniqueness));
 }
 /**
  * @Req\Route("/info-sms/me/collect-subscriptions")
  * @Req\Method({"GET"})
  *
  * @return JsonResponse
  */
 public function collectAction()
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $subscriptions = $this->collectSubscriptionsApiWorker->collect($uniqueness);
     return new JsonResponse($subscriptions);
 }
 /**
  * @Req\Route("/info-sms/me/create-subscription")
  * @Req\Method({"POST"})
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function createAction(Request $request)
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $response = $this->create($request);
     if ($response->getStatusCode() != '200') {
         return $response;
     }
     return new JsonResponse($this->collectSubscriptionsApiWorker->collect($uniqueness));
 }
 /**
  * @Req\Route("/info-sms/me/update-subscription/{mobile}")
  * @Req\Method({"POST"})
  *
  * @param string  $mobile
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function updateAction($mobile, Request $request)
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $data = $request->request->all();
     foreach (array('alias', 'topics', 'active') as $key) {
         Assertion::keyExists($data, $key);
     }
     try {
         $this->updateSubscriptionApiWorker->update($mobile, $uniqueness, $data['alias'], $data['topics'], $data['active']);
     } catch (BlankAliasApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.BLANK_ALIAS'), 400);
     } catch (NoTopicsApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.NO_TOPICS'), 400);
     }
     return new JsonResponse($this->collectSubscriptionsApiWorker->collect($uniqueness));
 }
 /**
  * @Req\Route("/info-sms/me/recharge-subscription/{mobile}")
  * @Req\Method({"POST"})
  *
  * @param string  $mobile
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function rechargeAction($mobile, Request $request)
 {
     /** @var UsernamePasswordToken $token */
     $token = $this->tokenStorage->getToken();
     $uniqueness = $token->getUsername();
     $data = $request->request->all();
     foreach (array('topics', 'resellPackage') as $key) {
         Assertion::keyExists($data, $key);
     }
     try {
         $this->rechargeSubscriptionApiWorker->recharge($mobile, $uniqueness, $data['topics'], $data['resellPackage']);
     } catch (NoTopicsApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.NO_TOPICS'), 400);
     } catch (NoResellPackageApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.NO_RESELL_PACKAGE'), 400);
     } catch (InsufficientBalanceApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.INSUFFICIENT_BALANCE'), 400);
     } catch (TrialNotAcceptedApiException $e) {
         return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.TRIAL_NOT_ACCEPTED'), 400);
     }
     return new JsonResponse($this->collectSubscriptionsApiWorker->collect($uniqueness));
 }