import 'dart:convert'; class LogsList { int loadStatus = 0; LogsData? logsData; LogsList({ required this.loadStatus, this.logsData }); } LogsData logsFromJson(String str) => LogsData.fromJson(json.decode(str)); String logsToJson(LogsData data) => json.encode(data.toJson()); class LogsData { List data; final DateTime? oldest; LogsData({ required this.data, this.oldest, }); factory LogsData.fromJson(Map json) => LogsData( data: List.from(json["data"].map((x) => Log.fromJson(x))), oldest: json["oldest"] != '' ? DateTime.parse(json["oldest"]) : null, ); Map toJson() => { "data": List.from(data.map((x) => x.toJson())), "oldest": oldest != null ? oldest!.toIso8601String() : null, }; } class Log { final bool? answerDnssec; final bool cached; final String client; final ClientInfo? clientInfo; final String? clientProto; final String elapsedMs; final Question question; final String reason; final List rules; final String? status; final DateTime time; final String? upstream; final List answer; final int? filterId; final String? rule; final List? originalAnswer; Log({ this.answerDnssec, required this.cached, required this.client, this.clientInfo, required this.clientProto, required this.elapsedMs, required this.question, required this.reason, required this.rules, this.status, required this.time, required this.upstream, required this.answer, this.filterId, this.rule, this.originalAnswer, }); factory Log.fromJson(Map json) => Log( answerDnssec: json["answer_dnssec"], cached: json["cached"] ?? false, client: json["client"], clientInfo: json["client_info"] != null ? ClientInfo.fromJson(json["client_info"]) : null, clientProto: json["client_proto"], elapsedMs: json["elapsedMs"], question: Question.fromJson(json["question"]), reason: json["reason"], rules: json["rules"] != null ? List.from(json["rules"].map((x) => Rule.fromJson(x))) : [], status: json["status"], time: DateTime.parse(json["time"]), upstream: json["upstream"], answer: json["answer"] != null ? List.from(json["answer"].map((x) => Answer.fromJson(x))) : [], filterId: json["filterId"], rule: json["rule"], originalAnswer: json["original_answer"] == null ? null : List.from(json["original_answer"].map((x) => Answer.fromJson(x))), ); Map toJson() => { "answer_dnssec": answerDnssec, "cached": cached, "client": client, "client_info": clientInfo?.toJson(), "client_proto": clientProto, "elapsedMs": elapsedMs, "question": question.toJson(), "reason":reason, "rules": List.from(rules.map((x) => x.toJson())), "status": status, "time": time.toIso8601String(), "upstream": upstream, "answer": List.from(answer.map((x) => x.toJson())), "filterId": filterId, "rule": rule, "original_answer": originalAnswer == null ? null : List.from(originalAnswer!.map((x) => x.toJson())), }; } class Answer { final String type; final String value; final int ttl; Answer({ required this.type, required this.value, required this.ttl, }); factory Answer.fromJson(Map json) => Answer( type: json["type"], value: json["value"], ttl: json["ttl"], ); Map toJson() => { "type": type, "value": value, "ttl": ttl, }; } class ClientInfo { final Whois whois; final String name; final String disallowedRule; final bool disallowed; ClientInfo({ required this.whois, required this.name, required this.disallowedRule, required this.disallowed, }); factory ClientInfo.fromJson(Map json) => ClientInfo( whois: Whois.fromJson(Map.from(json["whois"])), name: json["name"], disallowedRule: json["disallowed_rule"], disallowed: json["disallowed"], ); Map toJson() => { "whois": whois.toJson(), "name": name, "disallowed_rule": disallowedRule, "disallowed": disallowed, }; } class Whois { Whois(); factory Whois.fromJson(Map json) => Whois(); Map toJson() => {}; } class Question { final String questionClass; final String? name; final String type; Question({ required this.questionClass, required this.name, required this.type, }); factory Question.fromJson(Map json) => Question( questionClass: json["class"], name: json["name"], type: json["type"], ); Map toJson() => { "class": questionClass, "name": name, "type": type, }; } class Rule { final int filterListId; final String text; Rule({ required this.filterListId, required this.text, }); factory Rule.fromJson(Map json) => Rule( filterListId: json["filter_list_id"], text: json["text"], ); Map toJson() => { "filter_list_id": filterListId, "text": text, }; }