Module: GoogleOAuth::Calendar
- Included in:
- Client
- Defined in:
- lib/google_oauth/calendar.rb,
lib/google_oauth/calendar/acl.rb,
lib/google_oauth/calendar/color.rb,
lib/google_oauth/calendar/event.rb,
lib/google_oauth/calendar/setting.rb,
lib/google_oauth/calendar/calendar.rb,
lib/google_oauth/calendar/free_busy.rb,
lib/google_oauth/calendar/calendar_list.rb
Defined Under Namespace
Classes: Acl, Calendar, CalendarList, Color, Event, FreeBusy, Setting
Instance Method Summary collapse
-
#calendars ⇒ Object
Returns entries on the user’s calendar list.
-
#clear_calendar ⇒ Object
Clears a primary calendar.
-
#delete_calendar(calendar_id) ⇒ Object
Deletes a secondary calendar.
-
#delete_calendar_list(calendar_id) ⇒ Object
Deletes an entry on the user’s calendar list.
-
#delete_event(calendar_id = 'primary', event_id) ⇒ Object
Deletes an event.
-
#event_instances(calendar_id, event_id) ⇒ Object
Returns instances of the specified recurring event.
- #events(calendar_id = 'primary', options = {}) ⇒ Object
-
#get_calendar(calendar_id = 'primary') ⇒ Object
Returns metadata for a calendar.
-
#get_event(calendar_id = 'primary', event_id) ⇒ Object
Returns an event.
-
#import_event ⇒ Object
Imports an event.
-
#insert_calendar(opts = {}) ⇒ Object
Creates a secondary calendar.
-
#insert_calendar_list(opts = {}) ⇒ Object
Adds an entry to the user’s calendar list.
-
#insert_event(calendar_id = 'primary', event_hash) ⇒ Object
Creates an event.
-
#move_event(from_calendar_id = 'primary', to_calendar_id, event_id) ⇒ Object
Moves an event to another calendar, i.e.
-
#patch_calendar(opts = {}) ⇒ Object
Updates metadata for a calendar.
-
#patch_calendar_list(opts = {}) ⇒ Object
Updates an entry on the user’s calendar list.
-
#quick_add_event(calendar_id = 'primary', text) ⇒ Object
Creates an event based on a simple text string.
-
#update_calendar(opts = {}) ⇒ Object
Updates metadata for a calendar.
-
#update_calendar_list(opts = {}) ⇒ Object
Updates an entry on the user’s calendar list.
-
#update_event(calendar_id = 'primary', event_id, event_hash) ⇒ Object
(also: #patch_event)
Updates an event.
Instance Method Details
#calendars ⇒ Object
Returns entries on the user’s calendar list. CalendarList#list
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/google_oauth/calendar.rb', line 25 def calendars page_token = nil result = execute(:api_method => service.calendar_list.list) entries = [] while true entries += result.data.items if !(page_token = result.data.next_page_token) break end result = execute(:api_method => service.calendar_list.list, :parameters => {'pageToken' => page_token}) end entries end |
#clear_calendar ⇒ Object
Clears a primary calendar. This operation deletes all data associated with the primary calendar of an account and cannot be undone.
51 52 |
# File 'lib/google_oauth/calendar.rb', line 51 def clear_calendar end |
#delete_calendar(calendar_id) ⇒ Object
Deletes a secondary calendar.
55 56 |
# File 'lib/google_oauth/calendar.rb', line 55 def delete_calendar(calendar_id) end |
#delete_calendar_list(calendar_id) ⇒ Object
Deletes an entry on the user’s calendar list.
12 13 |
# File 'lib/google_oauth/calendar.rb', line 12 def delete_calendar_list(calendar_id) end |
#delete_event(calendar_id = 'primary', event_id) ⇒ Object
Deletes an event.
99 100 101 102 |
# File 'lib/google_oauth/calendar.rb', line 99 def delete_event(calendar_id = 'primary', event_id) execute(:api_method => service.events.delete, :parameters => {'calendarId' => calendar_id, 'eventId' => event_id}) end |
#event_instances(calendar_id, event_id) ⇒ Object
Returns instances of the specified recurring event.
141 142 |
# File 'lib/google_oauth/calendar.rb', line 141 def event_instances(calendar_id, event_id) end |
#events(calendar_id = 'primary', options = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/google_oauth/calendar.rb', line 76 def events(calendar_id = 'primary', = {}) %w(timeMin timeMax).each do |time| [time] = [time].xmlschema if [time] end params = { 'calendarId' => calendar_id } params.merge!() result = execute(:api_method => service.events.list, :parameters => params) events = [] while true events += result.data.items if !(params[:page_token] = result.data.next_page_token) break end result = execute(:api_method => service.events.list, :parameters => params) end events end |
#get_calendar(calendar_id = 'primary') ⇒ Object
Returns metadata for a calendar
59 60 61 |
# File 'lib/google_oauth/calendar.rb', line 59 def get_calendar(calendar_id = 'primary') execute(:api_method => service.calendars.get, :parameters => { 'calendarId' => calendar_id }).data end |
#get_event(calendar_id = 'primary', event_id) ⇒ Object
Returns an event.
105 106 107 108 |
# File 'lib/google_oauth/calendar.rb', line 105 def get_event(calendar_id = 'primary', event_id) execute(:api_method => service.events.get, :parameters => {'calendarId' => calendar_id, 'eventId' => event_id}) end |
#import_event ⇒ Object
Imports an event.
111 112 |
# File 'lib/google_oauth/calendar.rb', line 111 def import_event end |
#insert_calendar(opts = {}) ⇒ Object
Creates a secondary calendar.
64 65 |
# File 'lib/google_oauth/calendar.rb', line 64 def insert_calendar(opts = {}) end |
#insert_calendar_list(opts = {}) ⇒ Object
Adds an entry to the user’s calendar list.
20 21 |
# File 'lib/google_oauth/calendar.rb', line 20 def insert_calendar_list(opts = {}) end |
#insert_event(calendar_id = 'primary', event_hash) ⇒ Object
Creates an event. event = {
'summary' => 'Appointment',
'location' => 'Somewhere',
'start' => {
'dateTime' => '2011-06-03T10:00:00.000-07:00'
},
'end' => {
'dateTime' => '2011-06-03T10:25:00.000-07:00'
},
'attendees' => [
{
'email' => 'attendeeEmail'
},
#...
]
}
131 132 133 134 135 136 137 138 |
# File 'lib/google_oauth/calendar.rb', line 131 def insert_event(calendar_id = 'primary', event_hash) (event_hash) event = execute(:api_method => service.events.insert, :parameters => {'calendarId' => calendar_id}, :body => [JSON.dump(event_hash)], :headers => {'Content-Type' => 'application/json'}) event ? event.data : nil end |
#move_event(from_calendar_id = 'primary', to_calendar_id, event_id) ⇒ Object
Moves an event to another calendar, i.e. changes an event’s organizer.
145 146 147 148 149 |
# File 'lib/google_oauth/calendar.rb', line 145 def move_event(from_calendar_id = 'primary', to_calendar_id, event_id) execute(:api_method => service.events.move, :parameters => {'calendarId' => from_calendar_id, 'eventId' => event_id, 'destination' => to_calendar_id}) end |
#patch_calendar(opts = {}) ⇒ Object
Updates metadata for a calendar. This method supports patch semantics.
72 73 74 |
# File 'lib/google_oauth/calendar.rb', line 72 def patch_calendar(opts = {}) update_calendar(opts) end |
#patch_calendar_list(opts = {}) ⇒ Object
Updates an entry on the user’s calendar list. This method supports patch semantics
46 47 48 |
# File 'lib/google_oauth/calendar.rb', line 46 def patch_calendar_list(opts = {}) update_calendar_list end |
#quick_add_event(calendar_id = 'primary', text) ⇒ Object
Creates an event based on a simple text string.
152 153 154 155 156 157 |
# File 'lib/google_oauth/calendar.rb', line 152 def quick_add_event(calendar_id = 'primary', text) event = execute(:api_method => service.events.quick_add, :parameters => {'calendarId' => calendar_id, 'text' => text}) event ? event.data : nil end |
#update_calendar(opts = {}) ⇒ Object
Updates metadata for a calendar.
68 69 |
# File 'lib/google_oauth/calendar.rb', line 68 def update_calendar(opts = {}) end |
#update_calendar_list(opts = {}) ⇒ Object
Updates an entry on the user’s calendar list.
42 43 |
# File 'lib/google_oauth/calendar.rb', line 42 def update_calendar_list(opts = {}) end |
#update_event(calendar_id = 'primary', event_id, event_hash) ⇒ Object Also known as: patch_event
Updates an event.
160 161 162 163 164 165 166 167 |
# File 'lib/google_oauth/calendar.rb', line 160 def update_event(calendar_id = 'primary', event_id, event_hash) (event_hash) event = execute(:api_method => service.events.update, :parameters => {'calendarId' => calendar_id}, :body => [JSON.dump(event_hash)], :headers => {'Content-Type' => 'application/json'}) event ? event.data : nil end |