Skip to content

Commit

Permalink
Get recording was broken, introduce a total override for this edge ca…
Browse files Browse the repository at this point in the history
…se where region URL is different from REST base URL (#413)
  • Loading branch information
SecondeJK authored Jun 1, 2023
1 parent 5d59b3f commit fd72359
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Client/APIResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,15 @@ public function delete(string $id, array $headers = []): ?array
* @throws ClientExceptionInterface
* @throws Exception\Exception
*/
public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true)
public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true, bool $uriOverride = false)
{
$uri = $this->getBaseUrl() . $this->baseUri . '/' . $id;

// This is a necessary hack if you want to fetch a totally different URL but use Vonage Auth
if ($uriOverride) {
$uri = $id;
}

if (!empty($query)) {
$uri .= '?' . http_build_query($query);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Voice/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,6 @@ public function unmuteCall(string $callId): void

public function getRecording(string $url): StreamInterface
{
return $this->getAPIResource()->get($url, [], [], false);
return $this->getAPIResource()->get($url, [], [], false, true);
}
}
4 changes: 2 additions & 2 deletions test/Voice/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public function testCanSearchCalls(): void
public function testCanDownloadRecording(): void
{
$fixturePath = __DIR__ . '/Fixtures/mp3fixture.mp3';
$url = 'recordings/mp3fixture.mp3';
$url = 'https://api-us.nexmo.com/v1/files/999f999-526d-4013-87fc-c824f7a443b3';

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

0 comments on commit fd72359

Please sign in to comment.