Class: Mobiscroll::Connect::Resources::Events
- Inherits:
-
Object
- Object
- Mobiscroll::Connect::Resources::Events
- Defined in:
- lib/mobiscroll/connect/resources/events.rb
Instance Method Summary collapse
- #create(provider:, calendar_id:, title:, start:, end:, **opts) ⇒ Object
- #delete(provider:, calendar_id:, event_id:, recurring_event_id: nil, delete_mode: nil) ⇒ Object
-
#initialize(_config, api_client) ⇒ Events
constructor
A new instance of Events.
- #list(start: nil, end: nil, calendar_ids: nil, page_size: nil, next_page_token: nil, single_events: nil) ⇒ Object
- #update(provider:, calendar_id:, event_id:, **opts) ⇒ Object
Constructor Details
#initialize(_config, api_client) ⇒ Events
Returns a new instance of Events.
9 10 11 |
# File 'lib/mobiscroll/connect/resources/events.rb', line 9 def initialize(_config, api_client) @api_client = api_client end |
Instance Method Details
#create(provider:, calendar_id:, title:, start:, end:, **opts) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mobiscroll/connect/resources/events.rb', line 32 def create(provider:, calendar_id:, title:, start:, end:, **opts) end_time = binding.local_variable_get(:end) body = build_event_body(opts.merge( provider: provider, calendar_id: calendar_id, title: title, start: start, end: end_time )) parsed = @api_client.post('/event', body: JSON.generate(body)) CalendarEvent.from_h(parsed) end |
#delete(provider:, calendar_id:, event_id:, recurring_event_id: nil, delete_mode: nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mobiscroll/connect/resources/events.rb', line 55 def delete(provider:, calendar_id:, event_id:, recurring_event_id: nil, delete_mode: nil) query = { 'provider' => provider, 'calendarId' => calendar_id, 'eventId' => event_id } query['recurringEventId'] = recurring_event_id if recurring_event_id query['deleteMode'] = delete_mode if delete_mode @api_client.delete('/event', query: query) nil end |
#list(start: nil, end: nil, calendar_ids: nil, page_size: nil, next_page_token: nil, single_events: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mobiscroll/connect/resources/events.rb', line 13 def list(start: nil, end: nil, calendar_ids: nil, page_size: nil, next_page_token: nil, single_events: nil) end_time = binding.local_variable_get(:end) query = {} query['start'] = start if start query['end'] = end_time if end_time query['pageSize'] = page_size if page_size query['nextPageToken'] = next_page_token if next_page_token query['singleEvents'] = single_events.to_s unless single_events.nil? if calendar_ids && !calendar_ids.empty? wire = calendar_ids.transform_keys(&:to_s) query['calendarIds'] = JSON.generate(wire) end parsed = @api_client.get('/events', query: query) EventsListResponse.from_h(parsed) end |
#update(provider:, calendar_id:, event_id:, **opts) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/mobiscroll/connect/resources/events.rb', line 45 def update(provider:, calendar_id:, event_id:, **opts) body = build_event_body(opts.merge( provider: provider, calendar_id: calendar_id, event_id: event_id )) parsed = @api_client.put('/event', body: JSON.generate(body)) CalendarEvent.from_h(parsed) end |