id = $id; $this->summary = $summary; if ($role !== self::ROLE_FREEBUSYREADER && $role !== self::ROLE_READER && $role !== self::ROLE_OWNER) { throw new InvalidArgumentException('Invalid calendar Role.'); } $this->role = $role; $this->timeZone = $timeZone; $this->colorId = $colorId; $this->selected = $selected; $this->primary = $primary; } /** * @param $data * * @return GoogleCalendarListItem */ public static function fromArray($data) { if (!isset($data['kind']) || $data['kind'] !== self::$kind) { throw new InvalidArgumentException('Invalid resource type. Expected: calendar#event'); } if (!isset($data['id'])) { throw new InvalidArgumentException('Missing required resorce field "id".'); } $id = $data['id']; $summary = $data['summary']; $role = $data['accessRole']; $timeZone = $data['timeZone']; $colorId = $data['colorId']; $selected = (isset($data['selected']) && $data['selected'] === true); $primary = (isset($data['primary']) && $data['primary'] === true); return new self($id, $summary, $role, $timeZone, $colorId, $selected, $primary); } /** * @return string */ public function getId() { return $this->id; } /** * @return string */ public function getSummary() { return $this->summary; } /** * @return string */ public function getRole() { return $this->role; } /** * @return string */ public function getTimeZone() { return $this->timeZone; } /** * @return string */ public function getColorId() { return $this->colorId; } /** * @return bool */ public function isSelected() { return $this->selected; } /** * @return bool */ public function isPrimary() { return $this->primary; } }