Skip to content

Commit fd72359

Browse files
authored
Get recording was broken, introduce a total override for this edge case where region URL is different from REST base URL (#413)
1 parent 5d59b3f commit fd72359

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Client/APIResource.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,15 @@ public function delete(string $id, array $headers = []): ?array
188188
* @throws ClientExceptionInterface
189189
* @throws Exception\Exception
190190
*/
191-
public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true)
191+
public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true, bool $uriOverride = false)
192192
{
193193
$uri = $this->getBaseUrl() . $this->baseUri . '/' . $id;
194194

195+
// This is a necessary hack if you want to fetch a totally different URL but use Vonage Auth
196+
if ($uriOverride) {
197+
$uri = $id;
198+
}
199+
195200
if (!empty($query)) {
196201
$uri .= '?' . http_build_query($query);
197202
}

src/Voice/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,6 @@ public function unmuteCall(string $callId): void
274274

275275
public function getRecording(string $url): StreamInterface
276276
{
277-
return $this->getAPIResource()->get($url, [], [], false);
277+
return $this->getAPIResource()->get($url, [], [], false, true);
278278
}
279279
}

test/Voice/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public function testCanSearchCalls(): void
646646
public function testCanDownloadRecording(): void
647647
{
648648
$fixturePath = __DIR__ . '/Fixtures/mp3fixture.mp3';
649-
$url = 'recordings/mp3fixture.mp3';
649+
$url = 'https://api-us.nexmo.com/v1/files/999f999-526d-4013-87fc-c824f7a443b3';
650650

651651
$this->vonageClient->send(Argument::that(function (RequestInterface $request) {
652652
$this->assertEquals(
@@ -657,7 +657,7 @@ public function testCanDownloadRecording(): void
657657
$uri = $request->getUri();
658658
$uriString = $uri->__toString();
659659
$this->assertEquals(
660-
'https://api.nexmo.com/v1/calls/recordings/mp3fixture.mp3',
660+
'https://api-us.nexmo.com/v1/files/999f999-526d-4013-87fc-c824f7a443b3',
661661
$uriString
662662
);
663663
return true;

0 commit comments

Comments
 (0)