Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created July 20, 2015 09:43
Show Gist options
  • Save anonymous/568de67a2a1add2e8407 to your computer and use it in GitHub Desktop.
Save anonymous/568de67a2a1add2e8407 to your computer and use it in GitHub Desktop.
results.data.items.group_by {|event| event.attendees[1].reponseStatus}
by_status["needsAction"]. each do |important_event|
by_status["accepted"].select {|event| event.start.dateTime.between?(important_event.start.dateTime, important_event.end.dateTime) || event.end.between?(...)}.each do |conflicting_event| #ERROR HERE ?!
drop = client.execute!(:api_method => calendar_api.events.get,
:parameters => {'calendarId' => 'primary', 'eventId' => conflicting_event.id})
drop_event = drop.data
drop_event.attendees[0].responseStatus = 'declined'
drop = client.execute!(:api_method => calendar_api.event.update,
:parameters => {'calendarId' => 'primary', 'eventId' => conflicting_event.id},
:body_object => drop_event,
:headers => {'Content-Type' => 'application/json'})
m = Gmail::Message.new(to: conflicting_event.organizer.email, subjet: "Status: OK", html: "Booking OK")
m.deliver
end
accept = client.execute!(:api_method => calendar_api.events.get,
:parameters => {'calendarId' => 'primary', 'eventId' => important_event.id})
accept_event = accept.data
accept_event.attendees[0].responseStatus = 'accepted'
accept = client.execute!(:api_method => calendar_api.event.update,
:parameters => {'calendarId' => 'primary', 'eventId' => important_event.id},
:body_object => accept_event,
:headers => {'Content-Type' => 'application/json'})
m = Gmail::Message.new(to: important_event.organizer.email, subjet: "Status: OK", html: "Booking OK")
m.deliver
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment