Skip to content

Commit

Permalink
update calendar
Browse files Browse the repository at this point in the history
Signed-off-by: Dieter Coopman <dieter@deltasolutions.be>
  • Loading branch information
dietercoopman committed Oct 27, 2023
1 parent ad52fdd commit 00ea137
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@
use Microsoft\Graph\Model\DateTimeTimeZone;
use Microsoft\Graph\Model\EmailAddress;
use Microsoft\Graph\Model\ItemBody;
use Microsoft\Graph\Model\Location;
use Microsoft\Graph\Model\PhysicalAddress;

class Calendar
{
use Connect,
Authenticate;

/**
* Get all contacts
* Get all calendars
*/
public function getCalendars(): array
{
return $this->get('/me/calendars', returns: \Microsoft\Graph\Model\Calendar::class);
}

/**
* Get single calendars
*/
public function getCalendar($calendar_id)
{
return $this->get('/me/calendars/'.$calendar_id, returns: \Microsoft\Graph\Model\Calendar::class);
}

/**
* Get all events in a calendar
*/
Expand All @@ -44,7 +54,7 @@ public function saveEventToCalendar(\Microsoft\Graph\Model\Calendar $calendar, \
* Make an event and return an event object of the type \Microsoft\Graph\Model\Event
* this is a shortcut to creating an event object and setting all the bases properties.
*/
public function makeEvent(string $starttime, string $endtime, string $timezone, string $subject, string $body, array $attendees = [], bool $isOnlineMeeting = false): \Microsoft\Graph\Model\Event
public function makeEvent(string $starttime, string $endtime, string $timezone, string $subject, string $body, object $location_address, array $attendees = [], bool $isOnlineMeeting = false): \Microsoft\Graph\Model\Event
{

$event = app(\Microsoft\Graph\Model\Event::class);
Expand All @@ -65,7 +75,19 @@ public function makeEvent(string $starttime, string $endtime, string $timezone,
$end->setTimeZone($timezone);
$event->setEnd($end);

$event->setIsOnlineMeeting(true);
$event->setIsOnlineMeeting($isOnlineMeeting);

if ( $location_address ) {
$address = new PhysicalAddress();
$address->setStreet($location_address->address_street.' '.$location_address->address_house_nr.trim(' '.$location_address->suffix));
$address->setPostalCode($location_address->address_zip_code);
$address->setCity($location_address->address_city);
$address->setCountryOrRegion($location_address->address_country);

$location = new Location();
$location->setAddress($address);
$event->setLocation($location);
}

$arrOfAttendees = [];
foreach ($attendees as $attendee) {
Expand Down

0 comments on commit 00ea137

Please sign in to comment.