public function __construct(ReservationItemView $reservationItemView, IRestServer $server, $showUser, $showDetails)
 {
     $this->referenceNumber = $reservationItemView->ReferenceNumber;
     $this->startDate = $reservationItemView->StartDate->ToIso();
     $this->endDate = $reservationItemView->EndDate->ToIso();
     $this->duration = $reservationItemView->GetDuration()->__toString();
     $this->resourceName = $reservationItemView->ResourceName;
     if ($showUser) {
         $this->firstName = $reservationItemView->FirstName;
         $this->lastName = $reservationItemView->LastName;
     }
     if ($showDetails) {
         $this->title = $reservationItemView->Title;
         $this->description = $reservationItemView->Description;
     }
     $this->requiresApproval = (bool) $reservationItemView->RequiresApproval;
     $this->isRecurring = (bool) $reservationItemView->IsRecurring;
     $this->scheduleId = $reservationItemView->ScheduleId;
     $this->userId = $reservationItemView->UserId;
     $this->resourceId = $reservationItemView->ResourceId;
     $this->bufferTime = $reservationItemView->GetBufferTime()->__toString();
     $bufferedDuration = $reservationItemView->BufferedTimes();
     $this->bufferedStartDate = $bufferedDuration->GetBegin()->ToIso();
     $this->bufferedEndDate = $bufferedDuration->GetEnd()->ToIso();
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $reservationItemView->ResourceId));
     $this->AddService($server, WebServices::GetReservation, array(WebServiceParams::ReferenceNumber => $reservationItemView->ReferenceNumber));
     $this->AddService($server, WebServices::GetUser, array(WebServiceParams::UserId => $reservationItemView->UserId));
     $this->AddService($server, WebServices::GetSchedule, array(WebServiceParams::ScheduleId => $reservationItemView->ScheduleId));
 }
 /**
  * @param IRestServer $server
  * @param BookableResource $resource
  * @param ReservationItemView|null $conflictingReservation
  * @param ReservationItemView|null $nextReservation
  * @param Date|null $nextAvailableTime
  */
 public function __construct(IRestServer $server, $resource, $conflictingReservation, $nextReservation, $nextAvailableTime)
 {
     $this->resource = new ResourceReference($server, $resource);
     $this->available = $conflictingReservation == null;
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $resource->GetId()));
     if (!$this->available) {
         $this->availableAt = $nextAvailableTime != null ? $nextAvailableTime->ToTimezone($server->GetSession()->Timezone)->ToIso() : null;
         $this->AddService($server, WebServices::GetUser, array(WebServiceParams::UserId => $conflictingReservation->UserId));
         $this->AddService($server, WebServices::GetReservation, array(WebServiceParams::ReferenceNumber => $conflictingReservation->ReferenceNumber));
     }
     if ($this->available && $nextReservation != null) {
         $this->availableUntil = $nextReservation->BufferedTimes()->GetBegin()->ToTimezone($server->GetSession()->Timezone)->ToIso();
     }
 }