InboundCallWebHookController.php 1.63 KB
<?php

namespace NexmoBundle\Controller;

use AppBundle\Entity\Patient;
use AppBundle\Entity\VoiceCall;
use AppBundle\Event\VoiceCallEvent;
use AppBundle\Event\VoiceCallEvents;
use CobrandBundle\CobrandInstance;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Post;
use JMS\DiExtraBundle\Annotation\Inject;
use NexmoBundle\VoiceCall\VoiceCallOrigins;
use NexmoBundle\VoiceCall\VoiceCallStatus;
use NexmoBundle\WebHook\OnAnswerInboundWebHook;
use NexmoBundle\WebHook\OnEventInboundWebHook;
use Sentry\SentryBundle\SentrySymfonyClient;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class InboundCallWebHookController extends NexmoWebHookController
{
    /**
     * @var OnAnswerInboundWebHook
     * @Inject("nexmo.webhooks.answer_inbound")
     */
    private $answerHandler;

    /**
     * @var OnEventInboundWebHook
     * @Inject("nexmo.webhooks.event_inbound")
     */
    private $eventHookHandler;

    /**
     * Inbound call answer url
     * @Get("/answer-url", name="answer_webhook")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\JsonResponse
     * @throws \Doctrine\DBAL\ConnectionException
     */
    public function answerUrlAction(Request $request)
    {
        return $this->answerHandler->handle($request);
    }

    /**
     * @Post("/event-url", name="event_webhook")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\JsonResponse
     * @throws \Exception
     */
    public function eventUrlAction(Request $request)
    {
        return $this->eventHookHandler->handle($request);
    }
}