Class: GoogleAPI::Calendar
- Inherits:
-
Base
- Object
- Base
- GoogleAPI::Calendar
show all
- Includes:
- ClearTestCalendar, Conference
- Defined in:
- lib/google_api/calendar.rb,
lib/google_api/calendar/conference.rb,
lib/google_api/calendar/clear_test_calendar.rb
Defined Under Namespace
Modules: ClearTestCalendar, Conference
Constant Summary
collapse
- SERVICE_CLASS =
Google::Apis::CalendarV3::CalendarService
Class Method Summary
collapse
Instance Method Summary
collapse
-
#create(calendar_id, event_options = {}) ⇒ Object
-
#delete(calendar_id, event_id) ⇒ Object
-
#get(calendar_id, event_id) ⇒ Object
-
#list(calendar_id, max_results: 2500, page_token: nil) ⇒ Object
-
#list_all(calendar_id, verbose: false) ⇒ Object
-
#patch(calendar_id, event_id, patch_options = {}) ⇒ Object
-
#permit(calendar, user = nil, email: nil) ⇒ Object
-
#unpermit(calendar, user = nil, calendar_rule_id: nil) ⇒ Object
-
#update(calendar_id, event_id, event_options = {}) ⇒ Object
#clear_test_calendar
Methods included from Conference
#add_conference, #conference_info
Methods inherited from Base
#initialize
#authorize!
Class Method Details
.last_token_path ⇒ Object
20
21
22
|
# File 'lib/google_api/calendar.rb', line 20
def self.last_token_path
GoogleAPI.configuration.local_path('tmp', 'run', 'last_page_token')
end
|
Instance Method Details
#create(calendar_id, event_options = {}) ⇒ Object
24
25
26
|
# File 'lib/google_api/calendar.rb', line 24
def create(calendar_id, event_options = {})
call(:insert_event, calendar_id, event(event_options), conference_data_version: 1)
end
|
#delete(calendar_id, event_id) ⇒ Object
60
61
62
63
64
|
# File 'lib/google_api/calendar.rb', line 60
def delete(calendar_id, event_id)
call(:delete_event, calendar_id, event_id)
rescue Google::Apis::ClientError
:event_not_found
end
|
#get(calendar_id, event_id) ⇒ Object
48
49
50
|
# File 'lib/google_api/calendar.rb', line 48
def get(calendar_id, event_id)
call(:get_event, calendar_id, event_id)
end
|
#list(calendar_id, max_results: 2500, page_token: nil) ⇒ Object
28
29
30
|
# File 'lib/google_api/calendar.rb', line 28
def list(calendar_id, max_results: 2500, page_token: nil)
call(:list_events, calendar_id, max_results: max_results, page_token: page_token)
end
|
#list_all(calendar_id, verbose: false) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/google_api/calendar.rb', line 32
def list_all(calendar_id, verbose: false)
events = []
list = call(:list_events, calendar_id)
events += list.items
while (page_token = list.next_page_token)
list = call(:list_events, calendar_id, page_token: page_token)
page_token = list.next_page_token
events += list.items
print('.') if verbose
end
events
end
|
#patch(calendar_id, event_id, patch_options = {}) ⇒ Object
52
53
54
|
# File 'lib/google_api/calendar.rb', line 52
def patch(calendar_id, event_id, patch_options = {})
call(:patch_event, calendar_id, event_id, patch_options, conference_data_version: 1)
end
|
#permit(calendar, user = nil, email: nil) ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/google_api/calendar.rb', line 66
def permit(calendar, user = nil, email: nil)
email ||= user&.email
rule = Google::Apis::CalendarV3::AclRule.new(
scope: { type: 'user', value: email }, role: 'writer'
)
user&.update(calendar_rule_id: call(:insert_acl, calendar, rule).id)
end
|
#unpermit(calendar, user = nil, calendar_rule_id: nil) ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/google_api/calendar.rb', line 76
def unpermit(calendar, user = nil, calendar_rule_id: nil)
calendar_rule_id ||= user&.calendar_rule_id
call(:delete_acl, calendar, calendar_rule_id)
rescue Google::Apis::ClientError
:permission_not_found
ensure
user&.update(calendar_rule_id: nil)
end
|
#update(calendar_id, event_id, event_options = {}) ⇒ Object
56
57
58
|
# File 'lib/google_api/calendar.rb', line 56
def update(calendar_id, event_id, event_options = {})
call(:update_event, calendar_id, event_id, event(event_options), conference_data_version: 1)
end
|