calendar

package
v1.0.40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package calendar provides a client for the Google Calendar API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalendarInfo

type CalendarInfo struct {
	ID          string `json:"id"`
	Summary     string `json:"summary"`
	Description string `json:"description,omitempty"`
	Primary     bool   `json:"primary"`
	AccessRole  string `json:"accessRole"`
	TimeZone    string `json:"timeZone,omitempty"`
}

CalendarInfo represents a simplified calendar for output

func ParseCalendar

func ParseCalendar(c *calendar.CalendarListEntry) *CalendarInfo

ParseCalendar converts a Google Calendar API calendar entry to our simplified CalendarInfo

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Google Calendar API service

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Calendar client with OAuth2 authentication

func (*Client) GetEvent

func (c *Client) GetEvent(ctx context.Context, calendarID, eventID string) (*calendar.Event, error)

GetEvent retrieves a single event by ID

func (*Client) ListCalendars

func (c *Client) ListCalendars(ctx context.Context) ([]*calendar.CalendarListEntry, error)

ListCalendars returns all calendars the user has access to

func (*Client) ListEvents

func (c *Client) ListEvents(ctx context.Context, calendarID string, timeMin, timeMax string, maxResults int64) ([]*calendar.Event, error)

ListEvents returns events from the specified calendar within the given time range

func (*Client) RSVPEvent added in v1.0.36

func (c *Client) RSVPEvent(ctx context.Context, calendarID, eventID, response string) error

RSVPEvent updates the current user's RSVP status on an event. The response must be "accepted", "declined", or "tentative".

func (*Client) SetEventColor added in v1.0.36

func (c *Client) SetEventColor(ctx context.Context, calendarID, eventID, colorID string) error

SetEventColor sets the color of a calendar event. The colorID must be a valid Google Calendar event color ID (1-11).

type Event

type Event struct {
	ID          string     `json:"id"`
	Summary     string     `json:"summary"`
	Description string     `json:"description,omitempty"`
	Location    string     `json:"location,omitempty"`
	Start       *EventTime `json:"start"`
	End         *EventTime `json:"end"`
	Status      string     `json:"status"`
	HTMLLink    string     `json:"htmlLink,omitempty"`
	HangoutLink string     `json:"hangoutLink,omitempty"`
	Organizer   *Person    `json:"organizer,omitempty"`
	Attendees   []Person   `json:"attendees,omitempty"`
	AllDay      bool       `json:"allDay"`
}

Event represents a simplified calendar event for output

func ParseEvent

func ParseEvent(e *calendar.Event) *Event

ParseEvent converts a Google Calendar API event to our simplified Event

func (*Event) FormatStartTime

func (e *Event) FormatStartTime() string

FormatStartTime returns a human-readable start time string

func (*Event) FormatTimeRange

func (e *Event) FormatTimeRange() string

FormatTimeRange returns a human-readable time range string

func (*Event) GetEndTime

func (e *Event) GetEndTime() (time.Time, error)

GetEndTime returns the event end time as a time.Time

func (*Event) GetStartTime

func (e *Event) GetStartTime() (time.Time, error)

GetStartTime returns the event start time as a time.Time

type EventTime

type EventTime struct {
	DateTime string `json:"dateTime,omitempty"`
	Date     string `json:"date,omitempty"`
	TimeZone string `json:"timeZone,omitempty"`
}

EventTime represents a date or datetime

type Person

type Person struct {
	Email       string `json:"email"`
	DisplayName string `json:"displayName,omitempty"`
	Self        bool   `json:"self,omitempty"`
	Optional    bool   `json:"optional,omitempty"`
	Status      string `json:"responseStatus,omitempty"`
}

Person represents an attendee or organizer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL