Skip to content

Commit

Permalink
collection
Browse files Browse the repository at this point in the history
  • Loading branch information
yparitcher committed Nov 24, 2024
1 parent 61cbb2c commit 2e4888c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/RingCentral.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use SheavesCapital\RingCentral\Exceptions\CouldNotSendMessage;

class RingCentral {
Expand Down Expand Up @@ -168,7 +170,7 @@ public function sendMessage(array $message): Response {

public function getExtensions(): Collection {
$r = $this->get('/account/~/extension');
return collect($r->json('records'));
return $r->collect('records');
}

protected function getMessages(string $extensionId, ?Carbon $fromDate = null, ?Carbon $toDate = null, ?int $perPage = 100): Collection {
Expand All @@ -183,15 +185,15 @@ protected function getMessages(string $extensionId, ?Carbon $fromDate = null, ?C
$data['dateTo'] = $toDate->toIso8601String();
}
$r = $this->get('/account/~/extension/'.$extensionId.'/message-store', $data);
return collect($r->json('records'));
return $r->collect('records');
}

public function getMessagesForExtensionId(string $extensionId, ?Carbon $fromDate = null, ?Carbon $toDate = null, ?int $perPage = 100): Collection {
return collect($this->getMessages($extensionId, $fromDate, $toDate, $perPage));
return $this->getMessages($extensionId, $fromDate, $toDate, $perPage);
}

public function getPhoneNumbers(): Collection {
return collect($this->get('/account/~/phone-number')->json('records'));
return $this->get('/account/~/phone-number')->collect('records');
}

public function getMessageAttachmentById(string $extensionId, string $messageId, string $attachementId): Response {
Expand All @@ -213,7 +215,7 @@ public function getCallLogs(?Carbon $fromDate = null, ?Carbon $toDate = null, bo
$dtat['recordingType'] = 'All';
}
$r = $this->get('/account/~/call-log', $data);
return collect($r->json('records'));
return $r->collect('records');
}

public function getCallLogsForExtensionId(string $extensionId, ?Carbon $fromDate = null, ?Carbon $toDate = null, bool $withRecording = true, ?int $perPage = 100): Collection {
Expand All @@ -231,15 +233,15 @@ public function getCallLogsForExtensionId(string $extensionId, ?Carbon $fromDate
$dtat['recordingType'] = 'All';
}
$r = $this->get('/account/~/extension/'.$extensionId.'/call-log', $data);
return collect($r->json('records'));
return $r->collect('records');
}

public function getRecordingById(string $recordingId): Response {
return $this->get("https://media.ringcentral.com/restapi/v1.0/account/~/recording/{$recordingId}/content", prependPath: false);
}

public function listWebhooks(): Collection {
return collect($this->get('/subscription')->json('records'));
return $this->get('/subscription')->collect('records');
}

public function createWebhook(array $filters, int $expiresIn, string $address, ?string $verificationToken = null): Response {
Expand Down

0 comments on commit 2e4888c

Please sign in to comment.