# CalInvite::Event

_class_ defined in `lib/cal_invite/event.rb`

Superclass: `Object`

## Constants

### `PROVIDER_ALIASES`

Value: `{ ics_content: :ics }.freeze`

Legacy provider symbols that still resolve; `:ics_content` has produced the
same output as `:ics` since IcsContent became a subclass of Ics.

## Attributes

### `start_time` (W)

### `end_time` (W)

### `title` (RW)

### `description` (RW)

### `location` (RW)

### `url` (RW)

### `attendees` (RW)

### `timezone` (RW)

### `show_attendees` (RW)

### `notes` (RW)

### `multi_day_sessions` (RW)

### `all_day` (RW)

### `organizer` (RW)

### `uid` (RW)

### `sequence` (RW)

### `geo` (RW)

### `reminders` (RW)

### `busy` (RW)

### `visibility` (RW)

### `rrule` (RW)

### `calendar_name` (RW)

### `importance` (RW)

### `allow_counter` (RW)

## Class methods

### `new(attributes = {})`

Initializes a new Event instance with the given attributes.

@param attributes [Hash] The attributes to initialize the event with
@option attributes [String] :title The event title
@option attributes [Time] :start_time The event start time. Optional with :multi_day_sessions
  (defaults to the earliest session start).
@option attributes [Time] :end_time The event end time. Optional with :multi_day_sessions
  (defaults to the latest session end).
@option attributes [String] :description The event description
@option attributes [String] :location The event location
@option attributes [String] :url The event URL
@option attributes [Array<String>] :attendees The event attendees
@option attributes [String] :timezone The event timezone. Defaults to
  CalInvite.configuration.timezone ('UTC' unless configured).
@option attributes [Boolean] :show_attendees (false) Whether to show attendees
@option attributes [String] :notes Additional notes
@option attributes [Array<Hash>] :multi_day_sessions Multi-day session details
@option attributes [Boolean] :all_day (false) Whether it's an all-day event
@option attributes [String, Hash] :organizer The event organizer: an email string, or e.g. { name: "Jane Doe", email: "jane@example.com" }
@option attributes [String] :uid A stable identifier for this event. If omitted, a random one
  is generated and memoized on this instance. To update or cancel a previously sent invite,
  you MUST pass the same :uid used originally — mail/calendar clients match REQUEST/CANCEL
  messages to an existing event by UID, not by content.
@option attributes [Integer] :sequence (0) RFC 5545 SEQUENCE number. Increment it yourself
  each time you re-send a REQUEST or a CANCEL for the same :uid.
@option attributes [Array<Float>, Hash] :geo Location coordinates, e.g. [37.4595, -122.1418]
  or { lat:, lng: }
@option attributes [Array<Integer>] :reminders Minutes-before-start values; one VALARM per entry
@option attributes [Boolean] :busy (true) Whether this event shows as busy on free/busy lookups
@option attributes [Symbol, String] :visibility (:public) :public, :private, or :confidential
@option attributes [String] :rrule A raw RFC 5545 recurrence rule value, e.g. "FREQ=WEEKLY;COUNT=5"
@option attributes [String] :calendar_name Calendar-level display name (X-WR-CALNAME)
@option attributes [Symbol, String] :importance :low, :normal, or :high
@option attributes [Boolean] :allow_counter (true) false emits X-MICROSOFT-DISALLOW-COUNTER

@raise [ArgumentError] If required attributes are missing or invalid, or a key isn't an Event attribute

## Instance methods

### `end_time()`

The event end. Without an explicit value, a multi-day event ends at its
latest session end.

@return [Time, nil]

### `generate_calendar_url(provider, method: :publish)`

Generates a calendar URL (or, for the ics/ical/ics_content providers, raw
iCalendar content) for the specified provider.

@param provider [Symbol, String] One of {CalInvite::Providers::SUPPORTED_PROVIDERS}
  (`:ics_content` is also accepted as a legacy alias of `:ics`)
@param method [Symbol] The iCalendar METHOD to use (:publish, :request, :cancel,
  :reply, :counter, or :decline_counter). Only honored by the ics-family providers
  (ics, ical, ics_content); ignored by URL-based providers.
  - :request (with an {#organizer} set) produces an invite that mail clients
    (Gmail, Outlook, Apple Mail) recognize and render with Accept/Decline
    actions rather than as a plain attachment.
  - :cancel produces a cancellation (STATUS:CANCELLED) for a previously sent
    :request. Reuse the same {#uid} and bump {#sequence} so clients match it
    to the original invite instead of creating a new event.
  - :reply carries an attendee's own PARTSTAT back to the organizer.
  - :counter carries an attendee's proposed new {#start_time}/{#end_time} back
    to the organizer, keeping the original {#uid}/{#sequence}. Client support for
    rendering this as an actionable UI is inconsistent — see CONFIGURATION.md's
    "Attendee-proposed reschedules (COUNTER)".
  - :decline_counter is the organizer rejecting a :counter proposal.
@return [String] The generated calendar URL or content
@raise [ArgumentError] If required event attributes are missing or the provider is unsupported

@example Generate a Google Calendar URL
  event.generate_calendar_url(:google)

@example Generate an Outlook Calendar URL
  event.generate_calendar_url(:outlook)

@example Generate an RFC 5545 meeting request for emailing as an invite
  event.organizer = { name: "Jane Doe", email: "jane@example.com" }
  event.generate_calendar_url(:ics, method: :request)

@example Cancel a previously sent invite
  event.uid = "the-original-uid@cal-invite"  # must match the original REQUEST
  event.sequence = 1                          # incremented from the original
  event.generate_calendar_url(:ics, method: :cancel)

### `start_time()`

The event start. Without an explicit value, a multi-day event spans
from its earliest session start, so single-event URL providers (Google,
Outlook, Office 365) show the overall range.

@return [Time, nil]

### `update_attributes(new_attributes)`

Updates the event attributes with new values.

@param new_attributes [Hash] The new attributes to update
@return [void]
@raise [ArgumentError] If a key isn't an Event attribute (nothing is changed), or the updated attributes make the event invalid

@example Update event title and time
  event.update_attributes(
    title: "Updated Meeting",
    start_time: Time.now + 3600
  )
