diff --git a/src/RingCentral.php b/src/RingCentral.php index 9d48bda..dff820e 100644 --- a/src/RingCentral.php +++ b/src/RingCentral.php @@ -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 {