insert method

Future<Event> insert(
  1. Event request,
  2. String calendarId, {
  3. int? conferenceDataVersion,
  4. int? maxAttendees,
  5. bool? sendNotifications,
  6. String? sendUpdates,
  7. bool? supportsAttachments,
  8. String? $fields,
})

Creates an event.

request - The metadata request object.

Request parameters:

calendarId - Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.

conferenceDataVersion - Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0. Value must be between "0" and "1".

maxAttendees - The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.

sendNotifications - Deprecated. Please use sendUpdates instead.

Whether to send notifications about the creation of the new event. Note that some emails might still be sent even if you set the value to false. The default is false.

sendUpdates - Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false. Possible string values are:

  • "all" : Notifications are sent to all guests.
  • "externalOnly" : Notifications are sent to non-Google Calendar guests only.
  • "none" : No notifications are sent. Warning: Using the value none can have significant adverse effects, including events not syncing to external calendars or events being lost altogether for some users. For calendar migration tasks, consider using the events.import method instead.

supportsAttachments - Whether API client performing operation supports event attachments. Optional. The default is False.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Event.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Event> insert(
  Event request,
  core.String calendarId, {
  core.int? conferenceDataVersion,
  core.int? maxAttendees,
  core.bool? sendNotifications,
  core.String? sendUpdates,
  core.bool? supportsAttachments,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (conferenceDataVersion != null)
      'conferenceDataVersion': ['${conferenceDataVersion}'],
    if (maxAttendees != null) 'maxAttendees': ['${maxAttendees}'],
    if (sendNotifications != null)
      'sendNotifications': ['${sendNotifications}'],
    if (sendUpdates != null) 'sendUpdates': [sendUpdates],
    if (supportsAttachments != null)
      'supportsAttachments': ['${supportsAttachments}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'calendars/' + commons.escapeVariable('$calendarId') + '/events';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Event.fromJson(response_ as core.Map<core.String, core.dynamic>);
}