import 'package:flutter/foundation.dart';

import '../../../core/contracts/library.dart';


@immutable
class PlaybackServerIdentity {
  const PlaybackServerIdentity({
    required this.serverId,
    required this.baseUrl,
    required this.token,
    required this.userId,
    required this.serverName,
  });


  factory PlaybackServerIdentity.fromCard(CrossServerSourceCard card) =>
      PlaybackServerIdentity(
        serverId: card.serverId,
        baseUrl: card.serverUrl,
        token: card.token,
        userId: card.userId,
        serverName: card.serverName,
      );

  final String serverId;
  final String baseUrl;
  final String token;
  final String userId;
  final String serverName;

  @override
  bool operator ==(Object other) =>
      other is PlaybackServerIdentity &&
      other.serverId == serverId &&
      other.baseUrl == baseUrl &&
      other.token == token &&
      other.userId == userId &&
      other.serverName == serverName;

  @override
  int get hashCode => Object.hash(serverId, baseUrl, token, userId, serverName);

  @override
  String toString() =>
      'PlaybackServerIdentity(serverId=$serverId, serverName=$serverName)';
}
