import 'package:equatable/equatable.dart';
import 'document_capabilities.dart';

class ViewerSession extends Equatable {
  final Uri viewUrl;
  final DocumentCapabilities capabilities;
  final String token;
  final DateTime expiresAt;

  const ViewerSession({
    required this.viewUrl,
    required this.capabilities,
    required this.token,
    required this.expiresAt,
  });

  @override
  List<Object?> get props => [viewUrl, capabilities, token, expiresAt];

  factory ViewerSession.fromJson(Map<String, dynamic> json) {
    return ViewerSession(
      viewUrl: Uri.parse(json['viewUrl']),
      capabilities: DocumentCapabilities.fromJson(json['capabilities']),
      token: json['token'],
      expiresAt: DateTime.parse(json['expiresAt']),
    );
  }
}
