Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Facade/CalDavClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}


Expand Down
12 changes: 12 additions & 0 deletions src/Facade/Responses/ETagEntityMultiResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php namespace CalDAVClient\Facade\Responses;

class ETagEntityMultiResponse extends GenericMultiCalDAVResponse
{
/**
* @return ETagEntityResponse
*/
protected function buildSingleResponse()
{
return new ETagEntityResponse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ public function getHRef()
*/
public function isSuccessFull()
{
return $this->code == HttpResponse::HttpCodeMultiResponse;
return ($this->code == HttpResponse::HttpCodeMultiResponse || $this->code == HttpResponse::HttpCodeOk);
}
}
30 changes: 30 additions & 0 deletions src/Facade/Responses/GetCalendarMultiResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php namespace CalDAVClient\Facade\Responses;
/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

/**
* Class GetCalendarMultiResponse
* @package CalDAVClient\Facade\Responses
*/
final class GetCalendarMultiResponse extends GenericMultiCalDAVResponse
{

/**
* @return GetCalendarResponse
*/
protected function buildSingleResponse()
{
return new GetCalendarResponse();
}

}
3 changes: 1 addition & 2 deletions src/Facade/Responses/GetCalendarResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Class GetCalendarResponse
* @package CalDAVClient\Facade\Responses
*/
final class GetCalendarResponse extends ETagEntityResponse
final class GetCalendarResponse extends GenericSinglePROPFINDCalDAVResponse
{
const ResourceTypeCalendar = 'calendar';
/**
Expand Down Expand Up @@ -45,5 +45,4 @@ public function getCTag(){
return isset($this->found_props['getctag']) ? $this->found_props['getctag'] : null;
}


}
2 changes: 1 addition & 1 deletion src/Facade/Responses/GetCalendarsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class GetCalendarsResponse extends GenericMultiCalDAVResponse
*/
protected function buildSingleResponse()
{
return new GetCalendarResponse();
return new GetCalendarMultiResponse();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ICalDavClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +86,7 @@ public function getCalendars($calendar_home_set_url);

/**
* @param string $calendar_url
* @return GetCalendarResponse
* @return GetCalendarMultiResponse
*/
public function getCalendar($calendar_url);

Expand Down
13 changes: 8 additions & 5 deletions tests/FacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down