create method
Create an organization
name
The name of the organization
slug
The slug of the organization
logo
The logo of the organization
metadata
The metadata of the organization
keepCurrentActiveOrganization
Whether to keep the current active organization active after creating a new one
Implementation
Future<CreateOrganizationResponse> create({
required String name,
required String slug,
String? logo,
Map<String, dynamic>? metadata,
bool? keepCurrentActiveOrganization,
}) async {
try {
final response = await dio.post(
"/organization/create",
data: {
"name": name,
"slug": slug,
"logo": logo,
"metadata": metadata,
"keepCurrentActiveOrganization": keepCurrentActiveOrganization,
}..removeWhere((key, value) => value == null),
options: await getOptions(isTokenRequired: true),
);
return CreateOrganizationResponse.fromJson(response.data);
} catch (e) {
final message = getErrorMessage(e);
if (message == null) rethrow;
throw message;
}
}