addType('start', Types::INTEGER); $this->addType('end', Types::INTEGER); $this->addType('length', Types::INTEGER); $this->addType('increment', Types::INTEGER); $this->addType('preparationDuration', Types::INTEGER); $this->addType('followupDuration', Types::INTEGER); $this->addType('timeBeforeNextSlot', Types::INTEGER); $this->addType('dailyMax', Types::INTEGER); $this->addType('futureLimit', Types::INTEGER); $this->addType('createTalkRoom', Types::BOOLEAN); } /** * Total length of one slot of the appointment config * in minutes * * @return int Minutes of Appointment slot length */ public function getTotalLength(): int { return $this->getLength() + $this->getPreparationDuration() + $this->getFollowupDuration(); } /** * Principals always have the same format * * @return string */ public function getPrincipalUri(): string { return 'principals/users/' . $this->userId; } public function getCalendarFreebusyUrisAsArray(): array { return json_decode($this->getCalendarFreebusyUris(), true); } /** * @param string[] $uris */ public function setCalendarFreeBusyUrisAsArray(array $uris): self { $this->setCalendarFreebusyUris(json_encode($uris)); return $this; } public function setAvailabilityAsArray(array $availability): self { $this->setAvailability(json_encode($availability)); return $this; } public function getAvailabilityAsArray(): array { return json_decode($this->getAvailability(), true, 512, JSON_THROW_ON_ERROR); } #[\Override] #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->id, 'token' => $this->getToken(), 'name' => $this->getName(), 'description' => $this->getDescription(), 'location' => $this->getLocation(), 'visibility' => $this->getVisibility(), 'userId' => $this->getUserId(), 'targetCalendarUri' => $this->getTargetCalendarUri(), 'calendarFreeBusyUris' => $this->getCalendarFreebusyUrisAsArray(), 'availability' => $this->getAvailability() === null ? null : json_decode($this->getAvailability(), true), 'start' => $this->getStart(), 'end' => $this->getEnd(), 'length' => $this->getLength(), 'increment' => $this->getIncrement(), 'preparationDuration' => $this->getPreparationDuration(), 'followupDuration' => $this->getFollowupDuration(), 'totalLength' => $this->getTotalLength(), 'timeBeforeNextSlot' => $this->getTimeBeforeNextSlot(), 'dailyMax' => $this->getDailyMax(), 'futureLimit' => $this->getFutureLimit(), 'createTalkRoom' => $this->getCreateTalkRoom(), ]; } }