From e18c494b197f739c9ee37670fc7de7e2dd2e3e84 Mon Sep 17 00:00:00 2001 From: Yechiel Date: Tue, 26 Nov 2024 15:54:15 -0500 Subject: [PATCH] inbound call records --- src/RingCentral.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/RingCentral.php b/src/RingCentral.php index c33c51c..1ae8a23 100644 --- a/src/RingCentral.php +++ b/src/RingCentral.php @@ -196,13 +196,7 @@ public function getPhoneNumbers(): Collection { protected function generatePhoneNumberMap(): Collection { return Cache::flexible('ringcentral_phone_map', [86400, 259200], function () { return RingCentral::getPhoneNumbers()->mapWithKeys(function ($record) { - return isset($record['extension']) - ? [ - $record['phoneNumber'] => RingCentral::getExtensionMap()[ - $record['extension']['id'] - ], - ] - : null; + return isset($record['extension']) ? [$record['phoneNumber'] => $record['extension']['id']] : null; }); }); } @@ -338,6 +332,11 @@ public function parseCallRecordArray(array $record): Fluent { $timestamp = Carbon::parse($record['startTime']); $direction = CallDirection::from($record->get('direction')); $extensionId = $record->get('extension.id'); + if ($extensionId == null) { + $internalKey = $direction == CallDirection::INBOUND ? 'to' : 'from'; + $internalPhone = $record->get("{$internalKey}.phoneNumber"); + $extensionId = $this->getPhoneNumberMap()->get($internalPhone); + } $extensionEmail = $this->getExtensionMap()->get($extensionId); $recordingId = $record->get('recording.id'); $externalKey = $direction == CallDirection::INBOUND ? 'from' : 'to';