class JobCommentResponse {
  final bool? success;
  final String? message;
  final JobCommentData? data;
  final dynamic errors;
  final int? statusCode;
  final String? timestamp;

  JobCommentResponse({
    this.success,
    this.message,
    this.data,
    this.errors,
    this.statusCode,
    this.timestamp,
  });

  factory JobCommentResponse.fromJson(Map<String, dynamic> json) {
    return JobCommentResponse(
      success: json['success'] as bool?,
      message: json['message'] as String?,
      data: json['data'] != null ? JobCommentData.fromJson(json['data']) : null,
      errors: json['errors'],
      statusCode: json['statusCode'] as int?,
      timestamp: json['timestamp'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'success': success,
        'message': message,
        'data': data?.toJson(),
        'errors': errors,
        'statusCode': statusCode,
        'timestamp': timestamp,
      };
}

class JobCommentData {
  final int? currentPage;
  final int? totalPages;
  final int? totalEntities;
  final List<CommentItem>? data;

  JobCommentData({
    this.currentPage,
    this.totalPages,
    this.totalEntities,
    this.data,
  });

  factory JobCommentData.fromJson(Map<String, dynamic> json) {
    return JobCommentData(
      currentPage: json['currentPage'] as int?,
      totalPages: json['totalPages'] as int?,
      totalEntities: json['totalEntities'] as int?,
      data: json['data'] != null
          ? List<CommentItem>.from(
              (json['data'] as List).map((x) => CommentItem.fromJson(x)))
          : null,
    );
  }

  Map<String, dynamic> toJson() => {
        'currentPage': currentPage,
        'totalPages': totalPages,
        'totalEntities': totalEntities,
        'data': data?.map((x) => x.toJson()).toList(),
      };
}

class CommentItem {
  final String? id;
  final JobTicket? jobTicket;
  final String? comment;
  final bool? isActive;
  final String? createdAt;
  final User? createdBy;
  final String? updatedAt;
  final User? updatedBy;
  final List<Attachment>? attachments;

  CommentItem({
    this.id,
    this.jobTicket,
    this.comment,
    this.isActive,
    this.createdAt,
    this.createdBy,
    this.updatedAt,
    this.updatedBy,
    this.attachments,
  });

  factory CommentItem.fromJson(Map<String, dynamic> json) {
    return CommentItem(
      id: json['id'] as String?,
      jobTicket: json['jobTicket'] != null
          ? JobTicket.fromJson(json['jobTicket'])
          : null,
      comment: json['comment'] as String?,
      isActive: json['isActive'] as bool?,
      createdAt: json['createdAt'] as String?,
      createdBy:
          json['createdBy'] != null ? User.fromJson(json['createdBy']) : null,
      updatedAt: json['updatedAt'] as String?,
      updatedBy:
          json['updatedBy'] != null ? User.fromJson(json['updatedBy']) : null,
      attachments: json['attachments'] != null
          ? List<Attachment>.from(
              (json['attachments'] as List).map((x) => Attachment.fromJson(x)))
          : null,
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'jobTicket': jobTicket?.toJson(),
        'comment': comment,
        'isActive': isActive,
        'createdAt': createdAt,
        'createdBy': createdBy?.toJson(),
        'updatedAt': updatedAt,
        'updatedBy': updatedBy?.toJson(),
        'attachments': attachments?.map((x) => x.toJson()).toList(),
      };
}

class JobTicket {
  final String? id;
  final String? title;
  final String? description;
  final String? jobTicketUId;
  final String? statusName;
  final bool? isArchive;

  JobTicket({
    this.id,
    this.title,
    this.description,
    this.jobTicketUId,
    this.statusName,
    this.isArchive,
  });

  factory JobTicket.fromJson(Map<String, dynamic> json) {
    return JobTicket(
      id: json['id'] as String?,
      title: json['title'] as String?,
      description: json['description'] as String?,
      jobTicketUId: json['jobTicketUId'] as String?,
      statusName: json['statusName'] as String?,
      isArchive: json['isArchive'] as bool?,
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'title': title,
        'description': description,
        'jobTicketUId': jobTicketUId,
        'statusName': statusName,
        'isArchive': isArchive,
      };
}

class User {
  final String? id;
  final String? firstName;
  final String? lastName;
  final String? email;
  final String? photo;
  final String? jobRoleId;
  final String? jobRoleName;

  User({
    this.id,
    this.firstName,
    this.lastName,
    this.email,
    this.photo,
    this.jobRoleId,
    this.jobRoleName,
  });

  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      id: json['id'] as String?,
      firstName: json['firstName'] as String?,
      lastName: json['lastName'] as String?,
      email: json['email'] as String?,
      photo: json['photo'] as String?,
      jobRoleId: json['jobRoleId'] as String?,
      jobRoleName: json['jobRoleName'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'firstName': firstName,
        'lastName': lastName,
        'email': email,
        'photo': photo,
        'jobRoleId': jobRoleId,
        'jobRoleName': jobRoleName,
      };
}

class Attachment {
  final String? id;
  final String? batchId;
  final String? fileName;
  final String? preSignedUrl;
  final String? thumbPreSignedUrl;
  final int? fileSize;
  final String? contentType;
  final String? uploadedAt;

  Attachment({
    this.id,
    this.batchId,
    this.fileName,
    this.preSignedUrl,
    this.thumbPreSignedUrl,
    this.fileSize,
    this.contentType,
    this.uploadedAt,
  });

  factory Attachment.fromJson(Map<String, dynamic> json) {
    return Attachment(
      id: json['id'] as String?,
      batchId: json['batchId'] as String?,
      fileName: json['fileName'] as String?,
      preSignedUrl: json['preSignedUrl'] as String?,
      thumbPreSignedUrl: json['thumbPreSignedUrl'] as String?,
      fileSize: json['fileSize'] as int?,
      contentType: json['contentType'] as String?,
      uploadedAt: json['uploadedAt'] as String?,
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'batchId': batchId,
        'fileName': fileName,
        'preSignedUrl': preSignedUrl,
        'thumbPreSignedUrl': thumbPreSignedUrl,
        'fileSize': fileSize,
        'contentType': contentType,
        'uploadedAt': uploadedAt,
      };
}
