Class: ConnpassToCalendar::Api::GoogleApis::Calendar
- Inherits:
-
Object
- Object
- ConnpassToCalendar::Api::GoogleApis::Calendar
- Defined in:
- lib/connpass_to_calendar/api/google_apis/calendar.rb
Constant Summary collapse
- OOB_URI =
"urn:ietf:wg:oauth:2.0:oob".freeze
- SCOPE =
"https://www.googleapis.com/auth/calendar"
Instance Method Summary collapse
- #create_event(summary, location, description, start_date_time, end_date_time) ⇒ Object
-
#initialize(application_name, credentials_path, token_path, user_id) ⇒ Calendar
constructor
A new instance of Calendar.
Constructor Details
#initialize(application_name, credentials_path, token_path, user_id) ⇒ Calendar
Returns a new instance of Calendar.
12 13 14 15 16 17 |
# File 'lib/connpass_to_calendar/api/google_apis/calendar.rb', line 12 def initialize(application_name, credentials_path, token_path, user_id) @application_name = application_name @credentials_path = credentials_path @token_path = token_path @user_id = user_id end |
Instance Method Details
#create_event(summary, location, description, start_date_time, end_date_time) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/connpass_to_calendar/api/google_apis/calendar.rb', line 41 def create_event(summary, location, description, start_date_time, end_date_time) client = Google::Apis::CalendarV3::CalendarService.new client..application_name = @application_name client. = event = Google::Apis::CalendarV3::Event.new({ summary: summary, location: location, description: description, start: { date_time: start_date_time, time_zone: "Japan", }, end: { date_time: end_date_time, time_zone: "Japan", }, }) result = client.insert_event("primary", event) puts "Event created: #{result.html_link}" end |