The Reminders field does not populate correctly when I instantiate a Google::Apis::CalendarV3::Event object. This causes insert_event to fail when the :reminders option is passed, effectively preventing me from adding reminders to an event.
This is the example code I found in the API reference. There are _several_ problems with it. I have been able to send requests successfully without reminders.
event = Google::Apis::CalendarV3::Event.new{
summary: 'Google I/O 2015',
location: '800 Howard St., San Francisco, CA 94103',
description: 'A chance to hear more about Google\'s developer products.',
start: {
date_time: '2015-05-28T09:00:00-07:00',
time_zone: 'America/Los_Angeles',
},
end: {
date_time: '2015-05-28T17:00:00-07:00',
time_zone: 'America/Los_Angeles',
},
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
{email: '[email protected]'},
{email: '[email protected]'},
],
reminders: {
use_default: false,
overrides: [
{method' => 'email', 'minutes: 24 * 60},
{method' => 'popup', 'minutes: 10},
],
},
}
result = client.insert_event('primary', event)
puts "Event created: #{result.html_link}"
Also, there should not be a method named end.
Will have the sample updated. The reminders part likely should read:
reminders: {
use_default: false,
overrides: [
{method_prop: 'email', minutes: 24 * 60},
{method_prop: 'popup', minutes: 10},
],
},
I discovered, after reviewing the source, that :reminder_method will work as a replacement for :method. However, both the documentation and the source suggest that :method is perfectly valid when it is not.
I had the same issue and stop using reminder but change the default setting from Google calendar setting..
I have just found that my event reminders that were set as popup do not show in Google Calendar on the pc things seem to have changed?
@sqrrrl The reminders property on Google::Apis::CalendarV3::Event does not seem to deserialize either. Think this is a Google::Apis::CalendarV3::EventReminders problem as I am failing the deserialize default_reminders on Google::Apis::CalendarV3::Events too.
{
"kind": "calendar#events",
"etag": "\"p33k8h1e1peit60g\"",
"summary": "Hello Google",
"description": "",
"updated": "2017-04-15T04:09:06.641Z",
"timeZone": "Asia/Seoul",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 10
}
],
"nextSyncToken": "COiIhcHLpdMCEOiIhcHLpdMCGAU=",
"items": [
{
"kind": "calendar#event",
"etag": "\"2984458692589000\"",
"id": "rl6jjmphq2c3uq74c9q5h866i0",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=cmw2amptcGhxMmMzdXE3NGM5cTVoODY2aTAgY2VtdTdiOTVkbHEzbDRhNWw2MHFhdmVyYWtAZw",
"created": "2017-04-14T19:38:51.000Z",
"updated": "2017-04-15T04:09:06.392Z",
"summary": "Hi Linder",
"creator": {
"email": "[email protected]"
},
"organizer": {
"email": "[email protected]",
"displayName": "Hello Google",
"self": true
},
"start": {
"dateTime": "2017-05-09T10:00:00+09:00"
},
"end": {
"dateTime": "2017-05-09T11:00:00+09:00"
},
"transparency": "transparent",
"visibility": "public",
"iCalUID": "[email protected]",
"sequence": 1,
"reminders": {
"useDefault": false,
"overrides": [
{
"method": "popup",
"minutes": 50
},
{
"method": "popup",
"minutes": 10
}
]
}
}
]
}
serializes to
#<Google::Apis::CalendarV3::Events:0x007f8a00fd7618
@access_role="reader",
@default_reminders=[],
@description="",
@etag="\"p33k8h1e1peit60g\"",
@items=
[#<Google::Apis::CalendarV3::Event:0x007f8a00fcf440
@created=Fri, 14 Apr 2017 19:38:51 +0000,
@creator=
#<Google::Apis::CalendarV3::Event::Creator:0x007f8a00fc33e8
@email="[email protected]">,
@end=
#<Google::Apis::CalendarV3::EventDateTime:0x007f8a00fc0a08
@date_time=Tue, 09 May 2017 11:00:00 +0900>,
@etag="\"2984458692784000\"",
@html_link=
"https://www.google.com/calendar/event?eid=cmw2amptcGhxMmMzdXE3NGM5cTVoODY2aTAgY2VtdTdiOTVkbHEzbDRhNWw2MHFhdmVyYWtAZw",
@i_cal_uid="[email protected]",
@id="rl6jjmphq2c3uq74c9q5h866i0",
@kind="calendar#event",
@organizer=
#<Google::Apis::CalendarV3::Event::Organizer:0x007f8a00fa73a0
@display_name="Hello Google
",
@email="[email protected]",
@self=true>,
@reminders=
#<Google::Apis::CalendarV3::Event::Reminders:0x007f8a00f9ecc8
@use_default=true>,
@sequence=1,
@start=
#<Google::Apis::CalendarV3::EventDateTime:0x007f8a00f97270
@date_time=Tue, 09 May 2017 10:00:00 +0900>,
@status="confirmed",
@summary="Hi Linder",
@transparency="transparent",
@updated=Sat, 15 Apr 2017 04:09:06 +0000,
@visibility="public">],
@kind="calendar#events",
@next_sync_token="COiIhcHLpdMCEOiIhcHLpdMCGAE=",
@summary="Hello Google",
@time_zone="Asia/Seoul",
@updated=Sat, 15 Apr 2017 04:09:06 +0000>
Did some investigation here. The original report from @LaMarseillaise remains pertinent: the Ruby sample is completely wrong. (For starters, beyond the syntax issues, the Ruby client simply does not translate nested hashes in this way. It needs to be constructed object-by-object.) I will fix up that sample.
There appear to be several other reports piled on, but are either unrelated or cannot be reproduced. In particular, I tried reproducing @nicholaskim94 's deserialization issue but was unsuccessful. Executing the deserialization code used in the client:
Google::Apis::CalendarV3::Events::Representation.new(Google::Apis::CalendarV3::Events.new).from_json(input_string)
yields the correct result with the correct reminders. It is possible that something was fixed since that report.
I will get the Ruby sample fixed and close this issue.
No wonder I forgot! My post was Feb 2017...!
Yes, really sorry about that. This repo was bounced around a few teams since then, and a bunch of the issues got neglected. I'm trying to go through and fix and close things now.
I am not sure how to interface such code into my project. Or is this something you guys need to do?
Looks like I am not able to edit the sample directly. So I reported this upstream to the documentation team: https://issuetracker.google.com/issues/143895117 Please follow that issue for further updates.
For reference, the following corrected sample should work:
event = Google::Apis::CalendarV3::Event.new(
summary: 'Google I/O 2015',
location: '800 Howard St., San Francisco, CA 94103',
description: 'A chance to hear more about Google\'s developer products.',
start: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T09:00:00-07:00',
time_zone: 'America/Los_Angeles'
),
end: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T17:00:00-07:00',
time_zone: 'America/Los_Angeles',
),
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
Google::Apis::CalendarV3::EventAttendee.new(
email: '[email protected]'
),
Google::Apis::CalendarV3::EventAttendee.new(
email: '[email protected]'
)
],
reminders: Google::Apis::CalendarV3::Event::Reminders.new(
use_default: false,
overrides: [
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'email',
minutes: 24 * 60
),
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'popup',
minutes: 10
)
]
)
)
result = client.insert_event('primary', event)
puts "Event created: #{result.html_link}"
@ajtruckle I'm not sure what you're asking. You should be able to create a client object of type Google::Apis::CalendarV3::CalendarService, set the API key or auth credentials, and then call this or any other method as with the sample. Look at the AUTHENTICATION.md if you're not sure how to set up auth.
Most helpful comment
I discovered, after reviewing the source, that
:reminder_methodwill work as a replacement for:method. However, both the documentation and the source suggest that:methodis perfectly valid when it is not.