-
-
Save anonymous/568de67a2a1add2e8407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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