addAnnouncement method

Future<Response?> addAnnouncement({
  1. required Announcement data,
  2. GeneralCallback<Response>? callback,
  3. String? languageCode,
})

Implementation

Future<Response<dynamic>?> addAnnouncement({
  required Announcement data,
  GeneralCallback<Response<dynamic>>? callback,
  String? languageCode,
}) async {
  try {
    data.tags ??= <String>[];
    data.tags!.addAll(
      <String>[
        languageCode ?? 'zh',
        if (organization != null) organization!,
      ],
    );
    final Response<dynamic> response = await dio.post(
      '/announcements/add',
      data: data.toUpdateJson(),
    );
    if (callback != null) {
      callback.onSuccess(response);
    }
    return response;
  } on DioException catch (dioException) {
    if (callback == null) {
      rethrow;
    } else {
      handleCrudError(dioException, callback);
    }
  }
  return null;
}