summaryrefslogtreecommitdiff
path: root/internal/api/google_calendar.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/google_calendar.go')
-rw-r--r--internal/api/google_calendar.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/api/google_calendar.go b/internal/api/google_calendar.go
index d2d4355..68d423b 100644
--- a/internal/api/google_calendar.go
+++ b/internal/api/google_calendar.go
@@ -175,3 +175,24 @@ func (c *GoogleCalendarClient) GetEventsByDateRange(ctx context.Context, start,
return deduplicateEvents(allEvents), nil
}
+
+// GetCalendarList returns all calendars accessible to the user
+func (c *GoogleCalendarClient) GetCalendarList(ctx context.Context) ([]models.CalendarInfo, error) {
+ list, err := c.srv.CalendarList.List().Do()
+ if err != nil {
+ return nil, fmt.Errorf("failed to fetch calendar list: %w", err)
+ }
+
+ var calendars []models.CalendarInfo
+ for _, item := range list.Items {
+ name := item.Summary
+ if name == "" {
+ name = item.Id
+ }
+ calendars = append(calendars, models.CalendarInfo{
+ ID: item.Id,
+ Name: name,
+ })
+ }
+ return calendars, nil
+}