diff --git a/src/Voice/NCCO/Action/Record.php b/src/Voice/NCCO/Action/Record.php index 937a0bf0..4a5ef742 100644 --- a/src/Voice/NCCO/Action/Record.php +++ b/src/Voice/NCCO/Action/Record.php @@ -53,7 +53,7 @@ class Record implements ActionInterface /** * @var int */ - protected $timeOut = 7200; + protected $timeOut = 0; /** * @var bool @@ -133,10 +133,13 @@ public function toNCCOArray(): array $data = [ 'action' => 'record', 'format' => $this->getFormat(), - 'timeOut' => (string)$this->getTimeout(), 'beepStart' => $this->getBeepStart() ? 'true' : 'false', ]; + if ($this->getTimeout() !== 0) { + $data['timeOut'] = (string)$this->getTimeout(); + } + if ($this->getEndOnSilence()) { $data['endOnSilence'] = (string)$this->getEndOnSilence(); } diff --git a/test/Voice/NCCO/Action/RecordTest.php b/test/Voice/NCCO/Action/RecordTest.php index 577f0e4f..ed625127 100644 --- a/test/Voice/NCCO/Action/RecordTest.php +++ b/test/Voice/NCCO/Action/RecordTest.php @@ -30,12 +30,20 @@ public function testWebhookMethodCanBeSetInFactory(): void public function testJsonSerializeLooksCorrect(): void { + $record = new Record(); $this->assertSame([ 'action' => 'record', 'format' => 'mp3', - 'timeOut' => '7200', 'beepStart' => 'false' - ], (new Record())->jsonSerialize()); + ], $record->jsonSerialize()); + + $record->setTimeout(1234); + $this->assertSame([ + 'action' => 'record', + 'format' => 'mp3', + 'beepStart' => 'false', + 'timeOut' => '1234' + ], $record->jsonSerialize()); } public function testSettingChannelBackToOneResetsValues(): void