createInvitation method
Create an invitation
Creates a new invitation for the given email address and sends the invitation email. Keep in mind that you cannot create an invitation if there is already one for the given email address. Also, trying to create an invitation for an email address that already exists in your application will result to an error.
Parameters:
- CreateInvitationRequest createInvitationRequest: Required parameters
Implementation
Future<Invitation?> createInvitation({
CreateInvitationRequest? createInvitationRequest,
}) async {
final response = await createInvitationWithHttpInfo(
createInvitationRequest: createInvitationRequest,
);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty &&
response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(
await _decodeBodyBytes(response),
'Invitation',
) as Invitation;
}
return null;
}