Class: Leash::Integrations::Calendar

Inherits:
Base
  • Object
show all
Defined in:
lib/leash/integrations/calendar.rb

Overview

‘leash.integrations.calendar` — mirrors TS `leash.integrations.calendar`. Wire provider id is `google_calendar` (also aliased as `leash.integrations.google_calendar`).

Constant Summary collapse

PROVIDER =
"google_calendar"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Leash::Integrations::Base

Instance Method Details

#create_event(summary:, start:, end_time: nil, **rest) ⇒ Object

‘end_time:` keyword is used here (not `end:`) to avoid clashing with the Ruby `end` keyword — but the wire payload uses `“end”`.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/leash/integrations/calendar.rb', line 41

def create_event(summary:, start:, end_time: nil, **rest)
  # Backward-compat: accept `:end` if callers pass it via a hash splat.
  end_time = rest.delete(:end) if end_time.nil? && rest.key?(:end)

  params = {
    "summary" => summary,
    "start" => start,
    "end" => end_time
  }
  params["calendarId"] = rest[:calendar_id] if rest[:calendar_id]
  params["description"] = rest[:description] if rest[:description]
  params["location"] = rest[:location] if rest[:location]
  params["attendees"] = rest[:attendees] if rest[:attendees]
  call("create-event", params)
end

#get_event(event_id, calendar_id: nil) ⇒ Object



57
58
59
60
61
# File 'lib/leash/integrations/calendar.rb', line 57

def get_event(event_id, calendar_id: nil)
  params = { "eventId" => event_id }
  params["calendarId"] = calendar_id unless calendar_id.nil?
  call("get-event", params)
end

#list_calendarsObject



13
14
15
# File 'lib/leash/integrations/calendar.rb', line 13

def list_calendars
  call("list-calendars")
end

#list_events(calendar_id: nil, time_min: nil, time_max: nil, max_results: nil, query: nil, single_events: nil, order_by: nil) ⇒ Object

Parameters:

  • calendar_id (String, nil) (defaults to: nil)
  • time_min (String, nil) (defaults to: nil)

    ISO 8601 timestamp

  • time_max (String, nil) (defaults to: nil)

    ISO 8601 timestamp

  • max_results (Integer, nil) (defaults to: nil)
  • query (String, nil) (defaults to: nil)
  • single_events (Boolean, nil) (defaults to: nil)
  • order_by (String, nil) (defaults to: nil)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/leash/integrations/calendar.rb', line 24

def list_events(calendar_id: nil, time_min: nil, time_max: nil,
                max_results: nil, query: nil, single_events: nil,
                order_by: nil)
  params = compact_params(
    "calendarId" => calendar_id,
    "timeMin" => time_min,
    "timeMax" => time_max,
    "maxResults" => max_results,
    "query" => query,
    "singleEvents" => single_events,
    "orderBy" => order_by
  )
  call("list-events", params.empty? ? nil : params)
end