create method

Future<CreateOrganizationResponse> create({
  1. required String name,
  2. required String slug,
  3. Map<String, dynamic>? metadata,
  4. bool? keepCurrentActiveOrganization,
})

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;
  }
}