Class: Leash::CalendarClient
- Inherits:
-
Object
- Object
- Leash::CalendarClient
- Defined in:
- lib/leash/calendar.rb
Overview
Client for Google Calendar operations via the Leash platform proxy.
Not instantiated directly – use Integrations#calendar instead.
Constant Summary collapse
- PROVIDER =
"google_calendar"
Instance Method Summary collapse
-
#create_event(summary:, start:, end_time:, calendar_id: nil, description: nil, location: nil, attendees: nil) ⇒ Hash
Create a new calendar event.
-
#get_event(event_id, calendar_id: nil) ⇒ Hash
Get a single event by ID.
-
#initialize(call_fn) ⇒ CalendarClient
constructor
private
A new instance of CalendarClient.
-
#list_calendars ⇒ Hash
List all calendars accessible to the user.
-
#list_events(calendar_id: nil, time_min: nil, time_max: nil, max_results: nil, single_events: nil, order_by: nil) ⇒ Hash
List events on a calendar.
Constructor Details
#initialize(call_fn) ⇒ CalendarClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CalendarClient.
11 12 13 |
# File 'lib/leash/calendar.rb', line 11 def initialize(call_fn) @call = call_fn end |
Instance Method Details
#create_event(summary:, start:, end_time:, calendar_id: nil, description: nil, location: nil, attendees: nil) ⇒ Hash
Create a new calendar event.
53 54 55 56 57 58 59 60 |
# File 'lib/leash/calendar.rb', line 53 def create_event(summary:, start:, end_time:, calendar_id: nil, description: nil, location: nil, attendees: nil) params = { "summary" => summary, "start" => start, "end" => end_time } params["calendarId"] = calendar_id if calendar_id params["description"] = description if description params["location"] = location if location params["attendees"] = attendees if attendees @call.call(PROVIDER, "create-event", params) end |
#get_event(event_id, calendar_id: nil) ⇒ Hash
Get a single event by ID.
67 68 69 70 71 |
# File 'lib/leash/calendar.rb', line 67 def get_event(event_id, calendar_id: nil) params = { "eventId" => event_id } params["calendarId"] = calendar_id if calendar_id @call.call(PROVIDER, "get-event", params) end |
#list_calendars ⇒ Hash
List all calendars accessible to the user.
18 19 20 |
# File 'lib/leash/calendar.rb', line 18 def list_calendars @call.call(PROVIDER, "list-calendars", {}) end |
#list_events(calendar_id: nil, time_min: nil, time_max: nil, max_results: nil, single_events: nil, order_by: nil) ⇒ Hash
List events on a calendar.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/leash/calendar.rb', line 31 def list_events(calendar_id: nil, time_min: nil, time_max: nil, max_results: nil, single_events: nil, order_by: nil) params = {} params["calendarId"] = calendar_id if calendar_id params["timeMin"] = time_min if time_min params["timeMax"] = time_max if time_max params["maxResults"] = max_results if max_results params["singleEvents"] = single_events unless single_events.nil? params["orderBy"] = order_by if order_by @call.call(PROVIDER, "list-events", params) end |