Class: Teems::Api::Calendar
Overview
API wrapper for Microsoft Graph Calendar endpoints
Constant Summary collapse
- CALENDAR_VIEW_SELECT =
%w[ id subject start end location isAllDay organizer attendees bodyPreview onlineMeeting showAs importance isCancelled responseStatus sensitivity ].join(',').freeze
- EVENT_DETAIL_SELECT =
%w[ id subject start end location isAllDay organizer attendees body onlineMeeting showAs importance isCancelled responseStatus sensitivity ].join(',').freeze
Constants inherited from Client
Instance Method Summary collapse
-
#create_event(body) ⇒ Object
Create a new calendar event.
-
#delete_event(event_id:) ⇒ Object
Delete an event.
-
#get_event(event_id:, timezone:) ⇒ Object
Get a single event by ID with full details.
-
#list_events(time_range:, top: 50) ⇒ Object
List events in a date range using CalendarView.
-
#rsvp_event(event_id:, action:, **opts) ⇒ Object
RSVP to an event (accept, decline, or tentatively accept).
Methods inherited from Client
Constructor Details
This class inherits a constructor from Teems::Api::Client
Instance Method Details
#create_event(body) ⇒ Object
Create a new calendar event
37 38 39 40 |
# File 'lib/teems/api/calendar.rb', line 37 def create_event(body) response = post('/v1.0/me/events', body: body) Models::Event.from_api(response) end |
#delete_event(event_id:) ⇒ Object
Delete an event
43 44 45 46 |
# File 'lib/teems/api/calendar.rb', line 43 def delete_event(event_id:) encoded_id = URI.encode_www_form_component(event_id) delete("/v1.0/me/events/#{encoded_id}") end |
#get_event(event_id:, timezone:) ⇒ Object
Get a single event by ID with full details
27 28 29 30 31 32 33 34 |
# File 'lib/teems/api/calendar.rb', line 27 def get_event(event_id:, timezone:) encoded_id = URI.encode_www_form_component(event_id) params = { '$select' => EVENT_DETAIL_SELECT } headers = timezone_header(timezone) response = get("/v1.0/me/events/#{encoded_id}", params: params, headers: headers) Models::Event.from_api(response) end |
#list_events(time_range:, top: 50) ⇒ Object
List events in a date range using CalendarView
20 21 22 23 24 |
# File 'lib/teems/api/calendar.rb', line 20 def list_events(time_range:, top: 50) params = calendar_view_params(time_range[:start_dt], time_range[:end_dt], top) headers = timezone_header(time_range[:timezone]) paginate_events('/v1.0/me/calendarView', params: params, headers: headers) end |
#rsvp_event(event_id:, action:, **opts) ⇒ Object
RSVP to an event (accept, decline, or tentatively accept)
49 50 51 52 53 |
# File 'lib/teems/api/calendar.rb', line 49 def rsvp_event(event_id:, action:, **opts) encoded_id = URI.encode_www_form_component(event_id) api_action = action == 'tentative' ? 'tentativelyAccept' : action post("/v1.0/me/events/#{encoded_id}/#{api_action}", body: rsvp_body(opts)) end |