Class: Readiness::GoogleCalendar::Events
- Defined in:
- lib/support_readiness/google_calendar/events.rb
Overview
Defines the class Events within the module Readiness::GoogleCalendar.
Instance Attribute Summary collapse
- #attachments ⇒ Object
- #attendees ⇒ Object
- #created ⇒ Object
- #creator ⇒ Object
- #description ⇒ Object
-
#end ⇒ Object
The time to use for the end of the event.
- #id ⇒ Object
- #location ⇒ Object
-
#start ⇒ Object
The time to use for the start of the event.
- #summary ⇒ Object
- #updated ⇒ Object
Class Method Summary collapse
-
.create!(client, event) ⇒ Object
Creates an event on a calendar.
-
.delete!(client, event) ⇒ Boolean
Deletes an event on a calendar.
-
.list(client, start_time, end_time, max = 1000) ⇒ Array
Lists all events on a calendar within specified time range.
-
.to_google_event(event) ⇒ Object
Converts an instance of Events to Google::Apis::CalendarV3::Event.
Instance Method Summary collapse
-
#initialize(object = {}) ⇒ Events
constructor
Creates a new Events instance.
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Constructor Details
#initialize(object = {}) ⇒ Events
Creates a new Readiness::GoogleCalendar::Events instance
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/support_readiness/google_calendar/events.rb', line 49 def initialize(object = {}) @attachments = object['attachments'] @attendees = object['attendees'] @created = object['created'] @creator = object['creator'] @description = object['description'] @end = object['end'] @id = object['id'] @location = object['location'] @start = object['start'] @summary = object['summary'] @updated = object['updated'] end |
Instance Attribute Details
#attachments ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def @attachments end |
#attendees ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def attendees @attendees end |
#created ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def created @created end |
#creator ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def creator @creator end |
#description ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def description @description end |
#end ⇒ Object
The time to use for the end of the event. When creating an event, you need to pass a Time/DateTime object for this.
38 39 40 |
# File 'lib/support_readiness/google_calendar/events.rb', line 38 def end @end end |
#id ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def id @id end |
#location ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def location @location end |
#start ⇒ Object
The time to use for the start of the event. When creating an event, you need to pass a Time/DateTime object for this.
26 27 28 |
# File 'lib/support_readiness/google_calendar/events.rb', line 26 def start @start end |
#summary ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def summary @summary end |
#updated ⇒ Object
14 15 16 |
# File 'lib/support_readiness/google_calendar/events.rb', line 14 def updated @updated end |
Class Method Details
.create!(client, event) ⇒ Object
Creates an event on a calendar
123 124 125 126 |
# File 'lib/support_readiness/google_calendar/events.rb', line 123 def self.create!(client, event) google_event = to_google_event(event) client.service.insert_event(client.calendar_id, google_event) end |
.delete!(client, event) ⇒ Boolean
Deletes an event on a calendar
146 147 148 149 |
# File 'lib/support_readiness/google_calendar/events.rb', line 146 def self.delete!(client, event) client.service.delete_event(client.calendar_id, event.id) true end |
.list(client, start_time, end_time, max = 1000) ⇒ Array
Lists all events on a calendar within specified time range
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/support_readiness/google_calendar/events.rb', line 81 def self.list(client, start_time, end_time, max = 1000) items = [] page_token = nil loop do response = client.service.list_events( client.calendar_id, max_results: max, single_events: true, order_by: 'startTime', page_token: page_token, time_min: start_time.rfc3339, time_max: end_time.rfc3339 ) items += response.items break if response.next_page_token.nil? page_token = response.next_page_token end items end |
.to_google_event(event) ⇒ Object
Converts an instance of Readiness::GoogleCalendar::Events to Google::Apis::CalendarV3::Event
158 159 160 161 162 163 164 165 166 |
# File 'lib/support_readiness/google_calendar/events.rb', line 158 def self.to_google_event(event) Google::Apis::CalendarV3::Event.new( description: event.description, end: Google::Apis::CalendarV3::EventDateTime.new(date_time: event.end.rfc3339), location: event.location, start: Google::Apis::CalendarV3::EventDateTime.new(date_time: event.start.rfc3339), summary: event.summary ) end |