import 'package:equatable/equatable.dart';

class EditorSession extends Equatable {
  final Uri editUrl;
  final String token;
  final bool readOnly;
  final DateTime expiresAt;

  const EditorSession({
    required this.editUrl,
    required this.token,
    required this.readOnly,
    required this.expiresAt,
  });

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

  factory EditorSession.fromJson(Map<String, dynamic> json) {
    return EditorSession(
      editUrl: Uri.parse(json['editUrl']),
      token: json['token'] ?? '',
      readOnly: json['readOnly'],
      expiresAt: DateTime.parse(json['expiresAt']),
    );
  }
}
