Skip to content

Commit

Permalink
Merge pull request #11 from rgazelot/fetch-single-event
Browse files Browse the repository at this point in the history
Fetch a single event
  • Loading branch information
Taluu committed Dec 1, 2015
2 parents 8a7b878 + 3539c1c commit e166ecb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Api/EventApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ public function getCalendarView(
/** {@inheritDoc} */
public function get($identifier)
{
$request = $this->guzzle->createRequest('GET', sprintf('events/%s', $identifier), []);
$response = $this->guzzle->send($request);

if (200 > $response->getStatusCode() || 300 <= $response->getStatusCode()) {
throw new ApiErrorException($response);
}

return Event::hydrate($response->json());
}

/** {@inheritDoc} */
Expand Down
9 changes: 9 additions & 0 deletions src/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class Event extends AbstractEvent
/** @var Recurrence */
private $recurrence;

/** @var array */
private $raw;

public function __construct(Calendar $calendar = null)
{
$this->calendar = $calendar;
Expand Down Expand Up @@ -232,6 +235,11 @@ public function addParticipation(BaseEventParticipation $participation)
return parent::addParticipation($participation);
}

public function getRaw()
{
return $this->raw;
}

/**
* Hydrate a new Event object with data received from Office365 api
*
Expand All @@ -248,6 +256,7 @@ public static function hydrate(array $data, Calendar $calendar = null)

$event->id = $data['Id'];
$event->etag = $data['ChangeKey'];
$event->raw = $data;

// if subject is not set or is null, we use null as name
$event->name = isset($data['Subject']) ? $data['Subject'] : null;
Expand Down

0 comments on commit e166ecb

Please sign in to comment.