import method

Future<Event> import(
  1. Event request,
  2. String calendarId, {
  3. int? conferenceDataVersion,
  4. bool? supportsAttachments,
  5. String? $fields,
})

Imports an event.

This operation is used to add a private copy of an existing event to a calendar.

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".

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> import(
  Event request,
  core.String calendarId, {
  core.int? conferenceDataVersion,
  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 (supportsAttachments != null)
      'supportsAttachments': ['${supportsAttachments}'],
    if ($fields != null) 'fields': [$fields],
  };

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

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