class ServiceProjectDetailModel { final bool success; final String message; final ProjectDetail? data; final dynamic errors; final int statusCode; final DateTime timestamp; ServiceProjectDetailModel({ required this.success, required this.message, this.data, this.errors, required this.statusCode, required this.timestamp, }); factory ServiceProjectDetailModel.fromJson(Map json) { return ServiceProjectDetailModel( success: json['success'] ?? false, message: json['message'] ?? '', data: json['data'] != null ? ProjectDetail.fromJson(json['data']) : null, errors: json['errors'], statusCode: json['statusCode'] ?? 0, timestamp: DateTime.parse(json['timestamp'] ?? DateTime.now().toIso8601String()), ); } Map toJson() => { 'success': success, 'message': message, 'data': data?.toJson(), 'errors': errors, 'statusCode': statusCode, 'timestamp': timestamp.toIso8601String(), }; } class ProjectDetail { final String id; final String name; final String shortName; final String address; final DateTime assignedDate; final Status? status; final Client? client; final List? services; final int numberOfJobs; final String contactName; final String contactPhone; final String contactEmail; final DateTime createdAt; final User? createdBy; final DateTime updatedAt; final User? updatedBy; ProjectDetail({ required this.id, required this.name, required this.shortName, required this.address, required this.assignedDate, this.status, this.client, this.services, required this.numberOfJobs, required this.contactName, required this.contactPhone, required this.contactEmail, required this.createdAt, this.createdBy, required this.updatedAt, this.updatedBy, }); factory ProjectDetail.fromJson(Map json) { return ProjectDetail( id: json['id'] ?? '', name: json['name'] ?? '', shortName: json['shortName'] ?? '', address: json['address'] ?? '', assignedDate: DateTime.parse(json['assignedDate'] ?? DateTime.now().toIso8601String()), status: json['status'] != null ? Status.fromJson(json['status']) : null, client: json['client'] != null ? Client.fromJson(json['client']) : null, services: json['services'] != null ? List.from(json['services'].map((x) => Service.fromJson(x))) : [], numberOfJobs: json['numberOfJobs'] ?? 0, contactName: json['contactName'] ?? '', contactPhone: json['contactPhone'] ?? '', contactEmail: json['contactEmail'] ?? '', createdAt: DateTime.parse(json['createdAt'] ?? DateTime.now().toIso8601String()), createdBy: json['createdBy'] != null ? User.fromJson(json['createdBy']) : null, updatedAt: DateTime.parse(json['updatedAt'] ?? DateTime.now().toIso8601String()), updatedBy: json['updatedBy'] != null ? User.fromJson(json['updatedBy']) : null, ); } Map toJson() => { 'id': id, 'name': name, 'shortName': shortName, 'address': address, 'assignedDate': assignedDate.toIso8601String(), 'status': status?.toJson(), 'client': client?.toJson(), 'services': services?.map((x) => x.toJson()).toList(), 'numberOfJobs': numberOfJobs, 'contactName': contactName, 'contactPhone': contactPhone, 'contactEmail': contactEmail, 'createdAt': createdAt.toIso8601String(), 'createdBy': createdBy?.toJson(), 'updatedAt': updatedAt.toIso8601String(), 'updatedBy': updatedBy?.toJson(), }; } class Status { final String id; final String status; Status({required this.id, required this.status}); factory Status.fromJson(Map json) => Status(id: json['id'] ?? '', status: json['status'] ?? ''); Map toJson() => {'id': id, 'status': status}; } class Client { final String id; final String name; final String? email; final String? contactPerson; final String? address; final String? contactNumber; final int? sprid; Client({ required this.id, required this.name, this.email, this.contactPerson, this.address, this.contactNumber, this.sprid, }); factory Client.fromJson(Map json) => Client( id: json['id'] ?? '', name: json['name'] ?? '', email: json['email'], contactPerson: json['contactPerson'], address: json['address'], contactNumber: json['contactNumber'], sprid: json['sprid'], ); Map toJson() => { 'id': id, 'name': name, 'email': email, 'contactPerson': contactPerson, 'address': address, 'contactNumber': contactNumber, 'sprid': sprid, }; } class Service { final String id; final String name; final String? description; final bool isSystem; final bool isActive; Service({ required this.id, required this.name, this.description, required this.isSystem, required this.isActive, }); factory Service.fromJson(Map json) => Service( id: json['id'] ?? '', name: json['name'] ?? '', description: json['description'], isSystem: json['isSystem'] ?? false, isActive: json['isActive'] ?? false, ); Map toJson() => { 'id': id, 'name': name, 'description': description, 'isSystem': isSystem, 'isActive': isActive, }; } class User { final String id; final String firstName; final String lastName; final String email; final String? photo; final String? jobRoleId; final String? jobRoleName; User({ required this.id, required this.firstName, required this.lastName, required this.email, this.photo, this.jobRoleId, this.jobRoleName, }); factory User.fromJson(Map json) => User( id: json['id'] ?? '', firstName: json['firstName'] ?? '', lastName: json['lastName'] ?? '', email: json['email'] ?? '', photo: json['photo'], jobRoleId: json['jobRoleId'], jobRoleName: json['jobRoleName'], ); Map toJson() => { 'id': id, 'firstName': firstName, 'lastName': lastName, 'email': email, 'photo': photo, 'jobRoleId': jobRoleId, 'jobRoleName': jobRoleName, }; }