/** * @ApiDoc( * section="List actions", * description="List of all deals for specified client", * filters={ * {"name"="token", "type"="text"} * } * ) * @Method("GET") * @Route("/clients/{id}/deals-list") * @ParamConverter("client", converter="account.doctrine.orm") * @param Client $client * @return JsonResponse */ public function indexAction(Client $client) { if (!$this->get('perfico_crm.permission_manager')->checkAnyRole(['ROLE_DEAL_VIEW_ALL', 'ROLE_DEAL_VIEW_OWN'])) { return new JsonResponse([], Response::HTTP_FORBIDDEN); } return new JsonResponse($this->get('perfico_crm.api.transformer')->transformCollection($client->getDeals(), new DealsListMap(), 'deals')); }
/** * @ApiDoc( * section="Phone", * description="List of all phones for specified client", * filters={ * {"name"="token", "type"="text"} * } * ) * @Method("GET") * @Route("/phones/client/{id}", requirements={"id" = "\d+"}) * @ParamConverter("client", converter="account.doctrine.orm") * @deprecated will be removed in the feature */ public function getClientPhonesAction(Client $client) { if (!$this->get('perfico_crm.permission_manager')->checkAnyRole(['ROLE_PHONE_VIEW_ALL', 'ROLE_PHONE_VIEW_OWN'])) { return new JsonResponse([], Response::HTTP_FORBIDDEN); } $phones = $client->getPhones(); return new JsonResponse($this->get('perfico_crm.api.transformer')->transformCollection($phones, new PhoneMap(), 'phones')); }
/** * @return Client */ public function create() { $client = new Client(); $client->setAccount($this->getCurrentAccount()); if (!$this->securityContext->getToken() instanceof AnonymousToken) { $client->setUser($this->securityContext->getToken()->getUser()); } return $client; }
/** * @ApiDoc( * section="List actions", * description="List of all activities for specified client", * filters={ * {"name"="token", "type"="text"} * } * ) * @Method("GET") * @Route("/clients/{id}/activities-list") * @param Client $client * @ParamConverter("client", converter="account.doctrine.orm") * @return JsonResponse */ public function activitiesAction(Client $client) { return new JsonResponse($this->get('perfico_crm.api.transformer')->transformCollection($client->getActivities(), new ActivityListMap(), 'activities')); }