86 lines
1.9 KiB
Dart
86 lines
1.9 KiB
Dart
class JobStatusResponse {
|
|
final bool? success;
|
|
final String? message;
|
|
final List<JobStatus>? data;
|
|
final dynamic errors;
|
|
final int? statusCode;
|
|
final String? timestamp;
|
|
|
|
JobStatusResponse({
|
|
this.success,
|
|
this.message,
|
|
this.data,
|
|
this.errors,
|
|
this.statusCode,
|
|
this.timestamp,
|
|
});
|
|
|
|
factory JobStatusResponse.fromJson(Map<String, dynamic> json) {
|
|
return JobStatusResponse(
|
|
success: json['success'] as bool?,
|
|
message: json['message'] as String?,
|
|
data: (json['data'] as List<dynamic>?)
|
|
?.map((e) => JobStatus.fromJson(e))
|
|
.toList(),
|
|
errors: json['errors'],
|
|
statusCode: json['statusCode'] as int?,
|
|
timestamp: json['timestamp'] as String?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'success': success,
|
|
'message': message,
|
|
'data': data?.map((e) => e.toJson()).toList(),
|
|
'errors': errors,
|
|
'statusCode': statusCode,
|
|
'timestamp': timestamp,
|
|
};
|
|
}
|
|
}
|
|
|
|
// --------------------------
|
|
// Single Job Status Model
|
|
// --------------------------
|
|
class JobStatus {
|
|
final String? id;
|
|
final String? name;
|
|
final String? displayName;
|
|
final int? level;
|
|
|
|
JobStatus({
|
|
this.id,
|
|
this.name,
|
|
this.displayName,
|
|
this.level,
|
|
});
|
|
|
|
factory JobStatus.fromJson(Map<String, dynamic> json) {
|
|
return JobStatus(
|
|
id: json['id'] as String?,
|
|
name: json['name'] as String?,
|
|
displayName: json['displayName'] as String?,
|
|
level: json['level'] as int?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'displayName': displayName,
|
|
'level': level,
|
|
};
|
|
}
|
|
|
|
// ✅ Add equality by id
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is JobStatus && runtimeType == other.runtimeType && id == other.id;
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
}
|