Skip to content

Commit

Permalink
add abilities to add query params (#63)
Browse files Browse the repository at this point in the history
* add abilities to add query params

* add abilty to add query params on another methods
  • Loading branch information
glendmaatita authored and freekmurze committed Jan 10, 2018
1 parent e35df4f commit 3aa3c07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function createFromGoogleCalendarEvent(Google_Service_Calendar_Eve
*
* @return mixed
*/
public static function create(array $properties, string $calendarId = null)
public static function create(array $properties, string $calendarId = null, $optParams = [])
{
$event = new static;

Expand All @@ -57,7 +57,7 @@ public static function create(array $properties, string $calendarId = null)
$event->$name = $value;
}

return $event->save('insertEvent');
return $event->save('insertEvent', $optParams);
}

public static function get(Carbon $startDateTime = null, Carbon $endDateTime = null, array $queryParameters = [], string $calendarId = null) : Collection
Expand Down Expand Up @@ -135,26 +135,26 @@ public function isAllDayEvent(): bool
return is_null($this->googleEvent['start']['dateTime']);
}

public function save(string $method = null): Event
public function save(string $method = null, $optParams = []): Event
{
$method = $method ?? ($this->exists() ? 'updateEvent' : 'insertEvent');

$googleCalendar = $this->getGoogleCalendar($this->calendarId);

$this->googleEvent->setAttendees($this->attendees);

$googleEvent = $googleCalendar->$method($this);
$googleEvent = $googleCalendar->$method($this, $optParams);

return static::createFromGoogleCalendarEvent($googleEvent, $googleCalendar->getCalendarId());
}

public function update(array $attributes): Event
public function update(array $attributes, $optParams = []): Event
{
foreach ($attributes as $name => $value) {
$this->$name = $value;
}

return $this->save('updateEvent');
return $this->save('updateEvent', $optParams);
}

public function delete(string $eventId = null)
Expand Down
4 changes: 2 additions & 2 deletions src/GoogleCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public function getEvent(string $eventId): Google_Service_Calendar_Event
/*
* @link https://developers.google.com/google-apps/calendar/v3/reference/events/insert
*/
public function insertEvent($event): Google_Service_Calendar_Event
public function insertEvent($event, $optParams = []): Google_Service_Calendar_Event
{
if ($event instanceof Event) {
$event = $event->googleEvent;
}

return $this->calendarService->events->insert($this->calendarId, $event);
return $this->calendarService->events->insert($this->calendarId, $event, $optParams);
}

public function updateEvent($event): Google_Service_Calendar_Event
Expand Down

0 comments on commit 3aa3c07

Please sign in to comment.