class GenericApiModel<T> {
  final int? messageStatus;
  final String? errorMessage;
  final int? statusCode;
  final T? data;

  GenericApiModel({
    this.messageStatus,
    this.errorMessage,
    this.statusCode,
    this.data,
  });

  factory GenericApiModel.fromJson(
    Map<String, dynamic> json,
    T Function(Object? json)? fromJsonT,
  ) {
    return GenericApiModel<T>(
      messageStatus: json['messageStatus'] as int?,
      errorMessage: json['errorMessage'] as String?,
      statusCode: json['statusCode'] as int?,
      data: fromJsonT != null ? fromJsonT(json['data']) : json['data'] as T?,
    );
  }

  Map<String, dynamic> toJson(Object Function(T value)? toJsonT) {
    return {
      'messageStatus': messageStatus,
      'errorMessage': errorMessage,
      'statusCode': statusCode,
      'data': toJsonT != null && data != null ? toJsonT(data as T) : data,
    };
  }
}
