inviteUser static method
Invites the user with email to the project with assignRoleNames.
Throws FailureException if the user is not found, the project's plan does not include inviting users, or the request fails.
Implementation
static Future<Map<String, Object?>> inviteUser(
final Client cloudApiClient, {
required final String projectId,
required final String email,
required final List<String> assignRoleNames,
}) async {
try {
await cloudApiClient.projects.inviteUser(
cloudProjectId: projectId,
email: email,
assignRoleNames: assignRoleNames,
);
} on NotFoundException catch (e) {
throw FailureException(error: e.message);
} on ProcurementDeniedException catch (e, s) {
throw planFeatureDeniedFailure(
e,
s,
feature: PlanFeature.userInvites,
projectId: projectId,
failureMessage: 'Failed to invite user to project',
);
} on Exception catch (e, s) {
throw FailureException.nested(e, s, 'Failed to invite user to project');
}
return {'roles': assignRoleNames};
}