Skip to content

Commit

Permalink
Merge 4fc21a7 into f7d3b14
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslav-sulkovsky committed Dec 16, 2019
2 parents f7d3b14 + 4fc21a7 commit 9a52654
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/Event.php
Expand Up @@ -68,9 +68,19 @@ public static function get(Carbon $startDateTime = null, Carbon $endDateTime = n

$googleEvents = $googleCalendar->listEvents($startDateTime, $endDateTime, $queryParameters);

$googleEventsList = $googleEvents->getItems();

while($googleEvents->getNextPageToken()) {
$queryParameters['pageToken'] = $googleEvents->getNextPageToken();

$googleEvents = $googleCalendar->listEvents($startDateTime, $endDateTime, $queryParameters);

$googleEventsList = array_merge($googleEventsList, $googleEvents->getItems());
}

$useUserOrder = isset($queryParameters['orderBy']);

return collect($googleEvents)
return collect($googleEventsList)
->map(function (Google_Service_Calendar_Event $event) use ($calendarId) {
return static::createFromGoogleCalendarEvent($event, $calendarId);
})
Expand Down
6 changes: 3 additions & 3 deletions src/GoogleCalendar.php
Expand Up @@ -6,6 +6,7 @@
use DateTime;
use Google_Service_Calendar;
use Google_Service_Calendar_Event;
use Google_Service_Calendar_Events;

class GoogleCalendar
{
Expand All @@ -30,7 +31,7 @@ public function getCalendarId(): string
/*
* @link https://developers.google.com/google-apps/calendar/v3/reference/events/list
*/
public function listEvents(Carbon $startDateTime = null, Carbon $endDateTime = null, array $queryParameters = []): array
public function listEvents(Carbon $startDateTime = null, Carbon $endDateTime = null, array $queryParameters = []): Google_Service_Calendar_Events
{
$parameters = [
'singleEvents' => true,
Expand All @@ -53,8 +54,7 @@ public function listEvents(Carbon $startDateTime = null, Carbon $endDateTime = n
return $this
->calendarService
->events
->listEvents($this->calendarId, $parameters)
->getItems();
->listEvents($this->calendarId, $parameters);
}

public function getEvent(string $eventId): Google_Service_Calendar_Event
Expand Down

0 comments on commit 9a52654

Please sign in to comment.