create method

Future<Invitation> create(
  1. Invitation request, {
  2. String? $fields,
})

Creates an invitation.

Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * PERMISSION_DENIED if the requesting user is not permitted to create invitations for this course or for access errors. * NOT_FOUND if the course or the user does not exist. * FAILED_PRECONDITION: * if the requested user's account is disabled. * if the user already has this role or a role with greater permissions. * for the following request errors: * IneligibleOwner * ALREADY_EXISTS if an invitation for the specified user and course already exists.

request - The metadata request object.

Request parameters:

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

Completes with a Invitation.

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<Invitation> create(
  Invitation request, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'v1/invitations';

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