import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';

class ImResult<T> {
  final bool success;
  final int code;
  final String desc;
  final T? data;

  ImResult({
    required this.success,
    required this.code,
    required this.desc,
    this.data,
  });
  static ImResult<T> wrap<T>(V2TimValueCallback<T> res) {
    return ImResult(
      success: res.code == 0,
      code: res.code,
      desc: res.desc,
      data: res.data,
    );
  }

  static ImResult<void> wrapNoData(V2TimCallback res) {
    return ImResult<void>(
      success: res.code == 0,
      code: res.code,
      desc: res.desc,
      data: null,
    );
  }
}
