Skip to content

Commit

Permalink
update calendar usage doc
Browse files Browse the repository at this point in the history
  • Loading branch information
frets1700 committed Dec 6, 2023
1 parent 2c1de65 commit 79a62f6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 61 deletions.
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
# Outlook

### Status
[![Build Status](https://travis-ci.org/Symplicity/outlook.svg?branch=master)](https://travis-ci.org/Symplicity/outlook)
[![Latest Stable Version](https://poser.pugx.org/symplicity/outlook/v/stable)](https://packagist.org/packages/symplicity/outlook)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Symplicity/outlook/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Symplicity/outlook/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/Symplicity/outlook/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Symplicity/outlook/?branch=master)
[![License](https://poser.pugx.org/symplicity/outlook/license)](https://packagist.org/packages/symplicity/outlook)

## Installation

Use composer to install Outlook package.

```
$ composer require symplicity/outlook "^1.0"
```

# Usage

We will be using Monolog Logger to log all info. Logger needs to be passed for all instance creations.

$ composer require symplicity/outlook "^5.0"
```
<?php
$log = new Logger('outlook_sync');
$streamHandler = new StreamHandler($file);
$log->pushHandler($streamHandler, Logger::WARNING);
```

## Documentations
- [Starting](docs/calendar-usage.md)
Expand Down
88 changes: 47 additions & 41 deletions docs/calendar-usage.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Starting with Calendar

To start working with calendars simply extend the Calendar class. There are a bunch of methods that needs to be implemented
To start working with calendars simply extend your class to the abstract Calendar class.

```
<?php
declare(strict_types=1);
namespace YourPackage;
Expand All @@ -16,61 +15,68 @@ use Symplicity\Outlook\Entities\ResponseBody;
use Symplicity\Outlook\Interfaces\Utils\BatchResponseInterface;
class OutlookCalendar extends Calendar
{
public function isBatchRequest(): CalendarInterface
{
return true;
}
{
public function saveEventLocal(ReaderEntityInterface $reader) : void
{
// handle events received from outlook
}
public function deleteEventLocal(ReaderEntityInterface $event) : void
public function deleteEventLocal(string $eventId) : void
{
// handle events deleted from outlook
}
public function getLocalEvents() : array
{
// setup a return for all events that you want pushed to outlook calendar.
// For events that needs to be deleted create an instance of Delete class. You can also set up your own by implementing the DeleteInterface
// A Writer entity is setup for use but u can always create a new one for your specific use case, just make sure it implements WriterInterface
$event1 = new Writer()
->setId('1')
->setSubject('testing new outlook events')
->setInternalEventType('Php Appointments')
->setLocation(new Location(['DisplayName' => 'Test']))
->setBody(new ResponseBody(['ContentType' => 'HTML', 'Content' => 'Testing Calendar']))
->setStartDate(new ODateTime(new DateTime('2019-02-20 08:30:00'), 'Eastern Standard Time'))
->setEndDate(new ODateTime(new DateTime('2019-02-20 09:00:00'), 'Eastern Standard Time'));
$event2 = new Writer()
->setId('2')
->setSubject('testing new outlook events - 2')
->setInternalEventType('Php Appointments')
->setLocation(new Location(['DisplayName' => 'Test']))
->setBody(new ResponseBody(['ContentType' => 'HTML', 'Content' => 'Testing Calendar']))
->setStartDate(new ODateTime(new DateTime('2019-02-21 08:30:00'), 'Eastern Standard Time'))
->setEndDate(new ODateTime(new DateTime('2019-02-21 09:00:00'), 'Eastern Standard Time'));
$event3 = new Delete('guid', 'internalEventId')
// Post event to outlook
$start = new \Microsoft\Graph\Generated\Models\DateTimeTimeZone();
$start->setTimeZone('Eastern Standard Time');
$start->setDateTime('2023-11-28 15:00:00');
$end = new \Microsoft\Graph\Generated\Models\DateTimeTimeZone();
$end->setTimeZone('Eastern Standard Time');
$end->setDateTime('2023-11-28 16:00:00');
$body = new \Microsoft\Graph\Generated\Models\ItemBody();
$body->setContent('This is a test event');
$event1 = new \Symplicity\Outlook\Models\Event();
$event1->setSubject('Test1');
$event1->setStart($start);
$event1->setEnd($end);
$event1->setBody($body);
// Delete event from outlook
$event2 = new \Symplicity\Outlook\Models\Event();
$event2->setIsDelete();
$event2->setId('ABC==');
// Patch event to outlook
$body = new \Microsoft\Graph\Generated\Models\ItemBody();
$body->setContent('Update event with extension');
$event3 = new \Microsoft\Graph\Generated\Models\Event();
$event3->setSubject('Update Event');
$event3->setId('ADB==');
$event3->setStart($start);
$event3->setEnd($end);
$event3->setBody($body);
$extension = new \Microsoft\Graph\Generated\Models\OpenTypeExtension();
$extension->setExtensionName('com.symplicity.test');
$extension->setAdditionalData([
'internalId' => '1232133'
]);
$event3->setExtensions([$extension]);
return [$event1, $event2, $event3];
}
public function handlePoolResponses(array $responses = []) : void
public function handleBatchResponse(?BatchResponseContent $responses): void
{
foreach ($responses as $id => $response) {
$outlookResponse = $response['response'] ?? null;
if ($outlookResponse instanceof BatchResponse && $outlookResponse->getStatus() === Promise::FULFILLED) {
// Handle Fullfilled mappings.
} else {
// Handle Rejected mappings.
}
}
// handle responses from push events request
}
}
```
3 changes: 2 additions & 1 deletion src/Interfaces/CalendarInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function getEventBy(string $id, ?EventItemRequestBuilderGetQueryParameter
/**
* Method to get all instances of a series master
* @param string $id
* @param InstancesRequestBuilderGetQueryParameters $params
* @param InstancesRequestBuilderGetQueryParameters|null $params
* @param array $args
*/
public function getEventInstances(string $id, ?InstancesRequestBuilderGetQueryParameters $params = null, array $args = []): void;

Expand Down

0 comments on commit 79a62f6

Please sign in to comment.