/** * @ApiDoc( * section="Messaging", * description="Send a message in a conversation", * input="MessageBundle\Model\Message", * statusCodes={ * 201 = "Created", * }, * ) * @Method("POST") * @Route * @param ConversationInterface $conversation * @param InputMessageInterface $message * @param ConstraintViolationListInterface $validationErrors * @ParamConverter(name="conversation", converter="message_bundle.conversation") * @ParamConverter(name="message", converter="fos_rest.request_body", class="MessageBundle\Model\Message") * @View(statusCode=201) */ public function sendMessageAction(ConversationInterface $conversation, InputMessageInterface $message, ConstraintViolationListInterface $validationErrors) { if (count($validationErrors) > 0) { throw new ConstraintViolationBadRequestException($validationErrors); } $this->sender->sendMessage($conversation, $this->getSender(), $message->getBody()); }
/** * @ApiDoc( * section="Messaging", * description="Start a conversation wich a user", * input="MessageBundle\Model\Conversation", * statusCodes={ * 201 = "Created", * }, * ) * @Method("POST") * @Route("/users/{user}/conversations") * @param PersonInterface $user * @param InputConversationInterface $conversation * @param ConstraintViolationListInterface $validationErrors * @ParamConverter(name="conversation", converter="fos_rest.request_body", class="MessageBundle\Model\Conversation") * @ParamConverter(name="user", class="UserBundle:User", converter="doctrine.orm") * @View(statusCode=201) */ public function startConversationAction(PersonInterface $user, InputConversationInterface $conversation, ConstraintViolationListInterface $validationErrors) { if (count($validationErrors) > 0) { throw new ConstraintViolationBadRequestException($validationErrors); } $this->sender->startConversation($this->getSender(), $user, $conversation->getBody(), $conversation->getSubject()); }