class DocumentType {
  final String id;
  final String name;
  final String? description;
  final String? regexExpression;
  final String? allowedContentType;
  final int? maxSizeAllowedInMB;
  final bool isValidationRequired;
  final bool isMandatory;
  final bool isSystem;
  final bool isActive;
  final dynamic documentCategory;
  final String? entityTypeId;

  DocumentType({
    required this.id,
    required this.name,
    this.description,
    this.regexExpression,
    this.allowedContentType,
    this.maxSizeAllowedInMB,
    this.isValidationRequired = false,
    this.isMandatory = false,
    this.isSystem = false,
    this.isActive = true,
    this.documentCategory,
    this.entityTypeId,
  });

  factory DocumentType.fromJson(Map<String, dynamic> json) {
    return DocumentType(
      id: json['id'] ?? '',
      name: json['name'] ?? '',
      description: json['description'],
      regexExpression: json['regexExpression'],
      allowedContentType: json['allowedContentType'],
      maxSizeAllowedInMB: json['maxSizeAllowedInMB'],
      isValidationRequired: json['isValidationRequired'] ?? false,
      isMandatory: json['isMandatory'] ?? false,
      isSystem: json['isSystem'] ?? false,
      isActive: json['isActive'] ?? true,
      documentCategory: json['documentCategory'],
      entityTypeId: json['entityTypeId'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'description': description,
      'regexExpression': regexExpression,
      'allowedContentType': allowedContentType,
      'maxSizeAllowedInMB': maxSizeAllowedInMB,
      'isValidationRequired': isValidationRequired,
      'isMandatory': isMandatory,
      'isSystem': isSystem,
      'isActive': isActive,
      'documentCategory': documentCategory,
      'entityTypeId': entityTypeId,
    };
  }
}

class DocumentTypesResponse {
  final bool success;
  final String? message;
  final List<DocumentType> data;

  DocumentTypesResponse({
    required this.success,
    required this.data,
    this.message,
  });

  factory DocumentTypesResponse.fromJson(Map<String, dynamic> json) {
    return DocumentTypesResponse(
      success: json['success'] ?? false,
      message: json['message'],
      data: (json['data'] as List<dynamic>?)
              ?.map((item) => DocumentType.fromJson(item))
              .toList() ??
          [],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'success': success,
      'message': message,
      'data': data.map((e) => e.toJson()).toList(),
    };
  }
}
