Class: GcalMapper::Calendar
- Inherits:
-
Object
- Object
- GcalMapper::Calendar
- Defined in:
- lib/gcal_mapper/calendar.rb
Overview
Provide methods to get google calendar data
Instance Method Summary collapse
-
#get_calendars_list(access_token) ⇒ Array
Get the calendar list for the connected user.
-
#get_events_list(access_token, calendar_id) ⇒ Array
Get all events from specified calendar(s).
Instance Method Details
#get_calendars_list(access_token) ⇒ Array
Get the calendar list for the connected user.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gcal_mapper/calendar.rb', line 11 def get_calendars_list(access_token) url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList' = { :method => :get, :headers => {'Authorization' => 'Bearer ' + access_token} } req = GcalMapper::RestRequest.new(url, ) response = req.execute tab_cal=response['items'] ids = [] tab_cal.each do |t| t.each do |k, v| if k == 'id' ids.push(v) end end end ids end |
#get_events_list(access_token, calendar_id) ⇒ Array
Get all events from specified calendar(s).
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gcal_mapper/calendar.rb', line 39 def get_events_list(access_token, calendar_id) url = 'https://www.googleapis.com/calendar/v3/calendars/'+calendar_id+'/events?showDeleted=true' = { :method => :get, :headers => {'Authorization' => 'Bearer ' + access_token}, } req = GcalMapper::RestRequest.new(url, ) response = req.execute response['items'] end |