/// Method Channel 標準化響應 DTO
/// 定義與原生平台通訊的標準響應格式
class MethodChannelResponse<T> {
  final bool isSuccess;
  final T? data;
  final String? error;

  const MethodChannelResponse({
    required this.isSuccess,
    this.data,
    this.error,
  });

  /// 創建成功響應
  factory MethodChannelResponse.success(T data) {
    return MethodChannelResponse(
      isSuccess: true,
      data: data,
      error: null,
    );
  }

  /// 創建失敗響應
  factory MethodChannelResponse.failure(String? error) {
    return MethodChannelResponse<T>(
      isSuccess: false,
      data: null,
      error: error,
    );
  }

  /// 檢查是否成功
  bool get succeeded => isSuccess;

  /// 獲取資料，失敗時拋出異常
  T getOrThrow() {
    if (!isSuccess || data == null) {
      throw Exception(error ?? 'Unknown error');
    }
    return data!;
  }
}

/// RSA 金鑰對響應 DTO
class RsaKeyPairResponse {
  final String publicKey;
  final String privateKey;

  const RsaKeyPairResponse({
    required this.publicKey,
    required this.privateKey,
  });
}

/// 會話金鑰響應 DTO
class SessionKeyResponse {
  final String key;
  final int round;

  const SessionKeyResponse({
    required this.key,
    required this.round,
  });
}

/// 加密訊息響應 DTO
class EncryptedMessageResponse {
  final int round;
  final String encryptedData;

  const EncryptedMessageResponse({
    required this.round,
    required this.encryptedData,
  });
}

