diff --git a/src/Facade/CalDavClient.php b/src/Facade/CalDavClient.php index d2d9763..3e379b1 100644 --- a/src/Facade/CalDavClient.php +++ b/src/Facade/CalDavClient.php @@ -25,7 +25,7 @@ use CalDAVClient\Facade\Responses\EventCreatedResponse; use CalDAVClient\Facade\Responses\EventDeletedResponse; use CalDAVClient\Facade\Responses\EventUpdatedResponse; -use CalDAVClient\Facade\Responses\GetCalendarResponse; +use CalDAVClient\Facade\Responses\GetCalendarMultiResponse; use CalDAVClient\Facade\Responses\GetCalendarsResponse; use CalDAVClient\Facade\Responses\ResourceCollectionResponse; use CalDAVClient\Facade\Responses\UserPrincipalResponse; @@ -298,21 +298,22 @@ public function getCalendars($calendar_home_set_url) /** * @param string $calendar_url - * @return GetCalendarResponse + * @param int $depth Defaults to 0 to obtain calendar metadata. Set to 1 to obtain (all) calendar contents as well. + * @return GetCalendarMultiResponse * @throws \GuzzleHttp\Exception\GuzzleException */ - public function getCalendar($calendar_url) + public function getCalendar($calendar_url, $depth = 0) { $http_response = $this->makeRequest( RequestFactory::createPropFindRequest ( $calendar_url, CalDAVRequestFactory::getInstance()->build(CalDAVRequestFactory::CalendarRequestType)->getContent(), - 0 + $depth ) ); - return new GetCalendarResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); + return new GetCalendarMultiResponse($this->server_url, (string)$http_response->getBody(), $http_response->getStatusCode()); } diff --git a/src/Facade/Responses/ETagEntityMultiResponse.php b/src/Facade/Responses/ETagEntityMultiResponse.php new file mode 100644 index 0000000..9745024 --- /dev/null +++ b/src/Facade/Responses/ETagEntityMultiResponse.php @@ -0,0 +1,12 @@ +code == HttpResponse::HttpCodeMultiResponse; + return ($this->code == HttpResponse::HttpCodeMultiResponse || $this->code == HttpResponse::HttpCodeOk); } } \ No newline at end of file diff --git a/src/Facade/Responses/GetCalendarMultiResponse.php b/src/Facade/Responses/GetCalendarMultiResponse.php new file mode 100644 index 0000000..7ae98a4 --- /dev/null +++ b/src/Facade/Responses/GetCalendarMultiResponse.php @@ -0,0 +1,30 @@ +found_props['getctag']) ? $this->found_props['getctag'] : null; } - } \ No newline at end of file diff --git a/src/Facade/Responses/GetCalendarsResponse.php b/src/Facade/Responses/GetCalendarsResponse.php index 03366fc..c9415c5 100644 --- a/src/Facade/Responses/GetCalendarsResponse.php +++ b/src/Facade/Responses/GetCalendarsResponse.php @@ -23,7 +23,7 @@ final class GetCalendarsResponse extends GenericMultiCalDAVResponse */ protected function buildSingleResponse() { - return new GetCalendarResponse(); + return new GetCalendarMultiResponse(); } /** diff --git a/src/ICalDavClient.php b/src/ICalDavClient.php index a706c05..21359d9 100644 --- a/src/ICalDavClient.php +++ b/src/ICalDavClient.php @@ -21,7 +21,7 @@ use CalDAVClient\Facade\Responses\EventCreatedResponse; use CalDAVClient\Facade\Responses\EventDeletedResponse; use CalDAVClient\Facade\Responses\EventUpdatedResponse; -use CalDAVClient\Facade\Responses\GetCalendarResponse; +use CalDAVClient\Facade\Responses\GetCalendarMultiResponse; use CalDAVClient\Facade\Responses\GetCalendarsResponse; use CalDAVClient\Facade\Responses\ResourceCollectionResponse; use CalDAVClient\Facade\Responses\UserPrincipalResponse; @@ -86,7 +86,7 @@ public function getCalendars($calendar_home_set_url); /** * @param string $calendar_url - * @return GetCalendarResponse + * @return GetCalendarMultiResponse */ public function getCalendar($calendar_url); diff --git a/tests/FacadeTest.php b/tests/FacadeTest.php index 5cf8dd2..38aca04 100644 --- a/tests/FacadeTest.php +++ b/tests/FacadeTest.php @@ -118,11 +118,14 @@ function testGetCalendars(){ } function testGetCalendar(){ - $res = self::$client->getCalendar($this->getCalendarUrl()); - $this->assertTrue($res->isSuccessFull(), "Calendar request not successful"); - $this->assertTrue(!empty($res->getDisplayName()), "Display name not set"); - $this->assertTrue(!empty($res->getSyncToken()), "Sync-token empty"); - return $res; + $responses = self::$client->getCalendar($this->getCalendarUrl())->getResponses(); + + foreach ($responses as $res) { + $this->assertTrue($res->isSuccessFull(), "Calendar request not successful"); + $this->assertTrue(!empty($res->getDisplayName()), "Display name not set"); + $this->assertTrue(!empty($res->getSyncToken()), "Sync-token empty"); + } + return $responses[0]; } function testSyncCalendar(){