Skip to content

Commit

Permalink
fluent
Browse files Browse the repository at this point in the history
  • Loading branch information
yparitcher committed Nov 26, 2024
1 parent eb5c78d commit fd4cf9a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/RingCentral.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Fluent;
use Illuminate\Support\Str;
use SheavesCapital\RingCentral\Enums\CallDirection;
use SheavesCapital\RingCentral\Exceptions\CouldNotSendMessage;
Expand Down Expand Up @@ -173,7 +174,7 @@ public function getExtensions(): Collection {
return $r->collect('records');
}

protected function getExtensionMap(): Collection {
public function getExtensionMap(): Collection {
return Cache::flexible('ringcentral_extension_map', [86400, 259200], function () {
return RingCentral::getExtensions()
->mapWithKeys(function (array $extension) {
Expand Down Expand Up @@ -284,15 +285,15 @@ public function verifyWebhook(Request $request): bool {
return $request->header('verification-token') == $this->verification_token;
}

public function parseWebhookBody(Request $request): Collection {
public function parseWebhookBody(Request $request): Fluent {
$timestamp = $request->date('timestamp');
$direction = $request->enum('body.parties.0.direction', CallDirection::class);
$extensionId = $request->input('body.parties.0.extensionId');
$extensionEmail = $this->getExtensionMap()->get($extensionId);
$recordingId = $request->input('body.parties.0.recordings.id');
$externalKey = $direction == CallDirection::INBOUND ? 'from' : 'to';
$externalPhoneNumber = $request->string("body.parties.0.{$externalKey}.phoneNumber")->ltrim('+1');
return collect([
return fluent([
'timestamp' => $timestamp,
'direction' => $direction,
'extensionId' => $extensionId,
Expand Down

0 comments on commit fd4cf9a

Please sign in to comment.