diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3365ff0e..ff6973bd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -23,6 +23,9 @@ test/Verify + + test/Application + test/Verify2 diff --git a/src/Application/Application.php b/src/Application/Application.php index 3f3eed30..ee12922a 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -230,7 +230,7 @@ public function toArray(): array { // Build up capabilities that are set $availableCapabilities = [ - 'voice' => [VoiceConfig::ANSWER, VoiceConfig::EVENT], + 'voice' => [VoiceConfig::ANSWER, VoiceConfig::EVENT, VoiceConfig::FALLBACK_ANSWER_URL], 'messages' => [MessagesConfig::INBOUND, MessagesConfig::STATUS], 'rtc' => [RtcConfig::EVENT] ]; diff --git a/src/Application/VoiceConfig.php b/src/Application/VoiceConfig.php index b957b317..47a83a46 100644 --- a/src/Application/VoiceConfig.php +++ b/src/Application/VoiceConfig.php @@ -10,6 +10,8 @@ class VoiceConfig { public const EVENT = 'event_url'; public const ANSWER = 'answer_url'; + public const FALLBACK_ANSWER_URL = 'fallback_answer_url'; + protected ?bool $signedCallbacks = null; protected ?int $conversationsTtl = null; protected ?string $region = null; diff --git a/src/Application/Webhook.php b/src/Application/Webhook.php index 88ab3457..e8f488e2 100644 --- a/src/Application/Webhook.php +++ b/src/Application/Webhook.php @@ -8,9 +8,7 @@ class Webhook implements \Stringable { public const METHOD_POST = 'POST'; public const METHOD_GET = 'GET'; - public ?string $socketTimeout = null; - public ?string $connectionTimeout = null; public function __construct(protected ?string $url, protected ?string $method = self::METHOD_POST) diff --git a/test/Application/ApplicationTest.php b/test/Application/ApplicationTest.php index 7ad7b39d..d840886e 100644 --- a/test/Application/ApplicationTest.php +++ b/test/Application/ApplicationTest.php @@ -9,6 +9,7 @@ use Vonage\Application\MessagesConfig; use Vonage\Application\RtcConfig; use Vonage\Application\VoiceConfig; +use Vonage\Application\Webhook; use Vonage\Client\Exception\Exception as ClientException; use VonageTest\Traits\HTTPTestTrait; use VonageTest\VonageTestCase; @@ -164,4 +165,17 @@ public function testConfigCanBeCopied(): void $webhook = $otherapp->getVoiceConfig()->getWebhook(VoiceConfig::ANSWER); $this->assertEquals('https://example.com/webhooks/answer', $webhook); } + + public function testCanSetFallbackUrlWebhook(): void + { + $application = new Application(); + $application->setName('my application'); + $application->getVoiceConfig()->setRegion('eu-west'); + + $webhook = new Webhook('https://example.com/fallbackUrl', 'GET'); + $application->getVoiceConfig()->setWebhook(\Vonage\Application\VoiceConfig::FALLBACK_ANSWER_URL, $webhook); + + $output = $application->toArray(); + $this->assertEquals('https://example.com/fallbackUrl', $output['capabilities']['voice']['webhooks']['fallback_answer_url']['address']); + } }