import 'dart:convert'; Attachment attachmentFromJson(String str) => Attachment.fromJson(json.decode(str)); String attachmentToJson(Attachment data) => json.encode(data.toJson()); class Attachment { final int? id; final String? source; final AttachmentCategory? category; final String? filename; final Subclass? subclass; final DateTime? createdAt; Attachment({ required this.id, required this.source, required this.category, required this.filename, required this.subclass, required this.createdAt, }); factory Attachment.fromJson(Map json) => Attachment( id: json["id"], source: json["source"], category: json['category'] == null ? null : AttachmentCategory.fromJson(json["category"]), filename: json["filename"], subclass: json['subclass'] == null ? null : Subclass.fromJson(json["subclass"]), createdAt: json['created_at'] == null ? null : DateTime.parse(json["created_at"]), ); Map toJson() => { "id": id, "source": source, "category": category?.toJson(), "filename": filename, "subclass": subclass?.toJson(), "created_at": createdAt?.toIso8601String(), }; } class AttachmentCategory { final int? id; final Subclass? subclass; final String? description; AttachmentCategory({ required this.id, required this.subclass, required this.description, }); factory AttachmentCategory.fromJson(Map json) => AttachmentCategory( id: json["id"], subclass:json['subclass'] == null? null: Subclass.fromJson(json["subclass"]), description: json["description"], ); Map toJson() => { "id": id, "subclass": subclass?.toJson(), "description": description, }; } class Subclass { final int? id; final String? name; final AttachmentClass? attachmentClass; Subclass({ required this.id, required this.name, required this.attachmentClass, }); factory Subclass.fromJson(Map json) => Subclass( id: json["id"], name: json["name"], attachmentClass: json['attachment_class'] == null? null: AttachmentClass.fromJson(json["attachment_class"]), ); Map toJson() => { "id": id, "name": name, "attachment_class": attachmentClass?.toJson(), }; } class AttachmentClass { final int? id; final String? name; AttachmentClass({ required this.id, required this.name, }); factory AttachmentClass.fromJson(Map json) => AttachmentClass( id: json["id"], name: json["name"], ); Map toJson() => { "id": id, "name": name, }; }