Skip to content

Commit

Permalink
saveRecordingById
Browse files Browse the repository at this point in the history
  • Loading branch information
yparitcher committed Nov 24, 2024
1 parent 6e1c6f4 commit 1df6b61
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/RingCentral.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,20 @@ public function getCallLogsForExtensionId(string $extensionId, ?Carbon $fromDate
}

public function getRecordingById(string $recordingId): Response {
return $this->get("https://media.ringcentral.com/restapi/v1.0/account/~/recording/{$recordingId}/content", prependPath: false);
$response = Http::withToken($this->accessToken())
->withOptions(['stream' => true])
->get("https://media.ringcentral.com/restapi/v1.0/account/~/recording/{$recordingId}/content");
$response->onError($this->errorHandler(...));
return $response;
}

public function saveRecordingById(string $recordingId, string $disk, string $path): string|false {
$response = $this->getRecordingById($recordingId);
$ext = ($response->header('Content-Type') == 'audio/mpeg') ? '.mp3' : '.wav';
$name = Str::random(40).$ext;
$path = trim($path, '/').'/'.$name;
$result = Storage::disk($disk)->put($path, $response->body());
return $result ? $path : false;
}

public function listWebhooks(): Collection {
Expand Down

0 comments on commit 1df6b61

Please sign in to comment.