inviteMember method

Future<Invitation> inviteMember({
  1. required String email,
  2. required String role,
  3. String? organizationId,
  4. bool? resend,
  5. String? teamId,
})

Invite a member to an organization

email The email of the member to invite role The role of the member to invite organizationId The ID of the organization to invite the member to, optional. resend Whether to resend the invitation, optional. teamId The ID of the team to invite the member to, optional.

Implementation

Future<Invitation> inviteMember({
  required String email,
  required String role,
  String? organizationId,
  bool? resend,
  String? teamId,
}) async {
  try {
    final response = await dio.post(
      "/organization/invite-member",
      data: {
        "email": email,
        "role": role,
        "organizationId": organizationId,
        "resend": resend,
        "teamId": teamId,
      }..removeWhere((key, value) => value == null),
      options: await getOptions(isTokenRequired: true),
    );
    return Invitation.fromJson(response.data);
  } catch (e) {
    final message = getErrorMessage(e);
    if (message == null) rethrow;
    throw message;
  }
}