79 lines
2.1 KiB
Dart
79 lines
2.1 KiB
Dart
import '../utils/app_time.dart';
|
|
|
|
class Ticket {
|
|
Ticket({
|
|
required this.id,
|
|
required this.subject,
|
|
required this.description,
|
|
required this.officeId,
|
|
required this.status,
|
|
required this.createdAt,
|
|
required this.creatorId,
|
|
required this.respondedAt,
|
|
required this.promotedAt,
|
|
required this.closedAt,
|
|
});
|
|
|
|
final String id;
|
|
final String subject;
|
|
final String description;
|
|
final String officeId;
|
|
final String status;
|
|
final DateTime createdAt;
|
|
final String? creatorId;
|
|
final DateTime? respondedAt;
|
|
final DateTime? promotedAt;
|
|
final DateTime? closedAt;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is Ticket &&
|
|
runtimeType == other.runtimeType &&
|
|
id == other.id &&
|
|
subject == other.subject &&
|
|
description == other.description &&
|
|
officeId == other.officeId &&
|
|
status == other.status &&
|
|
createdAt == other.createdAt &&
|
|
creatorId == other.creatorId &&
|
|
respondedAt == other.respondedAt &&
|
|
promotedAt == other.promotedAt &&
|
|
closedAt == other.closedAt;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
subject,
|
|
description,
|
|
officeId,
|
|
status,
|
|
createdAt,
|
|
creatorId,
|
|
respondedAt,
|
|
promotedAt,
|
|
closedAt,
|
|
);
|
|
|
|
factory Ticket.fromMap(Map<String, dynamic> map) {
|
|
return Ticket(
|
|
id: map['id'] as String,
|
|
subject: map['subject'] as String? ?? '',
|
|
description: map['description'] as String? ?? '',
|
|
officeId: map['office_id'] as String? ?? '',
|
|
status: map['status'] as String? ?? 'pending',
|
|
createdAt: AppTime.parse(map['created_at'] as String),
|
|
creatorId: map['creator_id'] as String?,
|
|
respondedAt: map['responded_at'] == null
|
|
? null
|
|
: AppTime.parse(map['responded_at'] as String),
|
|
promotedAt: map['promoted_at'] == null
|
|
? null
|
|
: AppTime.parse(map['promoted_at'] as String),
|
|
closedAt: map['closed_at'] == null
|
|
? null
|
|
: AppTime.parse(map['closed_at'] as String),
|
|
);
|
|
}
|
|
}
|