import 'package:adguard_home_manager/models/clients_allowed_blocked.dart'; import 'package:adguard_home_manager/models/safe_search.dart'; class Clients { List clients; final List autoClients; final List supportedTags; ClientsAllowedBlocked? clientsAllowedBlocked; Clients({ required this.clients, required this.autoClients, required this.supportedTags, this.clientsAllowedBlocked }); factory Clients.fromJson(Map json) => Clients( clients: json["clients"] != null ? List.from(json["clients"].map((x) => Client.fromJson(x))) : [], autoClients: json["auto_clients"] != null ? List.from(json["auto_clients"].map((x) => AutoClient.fromJson(x))) : [], supportedTags: json["supported_tags"] != null ? List.from(json["supported_tags"].map((x) => x)) : [], ); Map toJson() => { "clients": List.from(clients.map((x) => x.toJson())), "auto_clients": List.from(autoClients.map((x) => x.toJson())), "supported_tags": List.from(supportedTags.map((x) => x)), }; } class AutoClient { final WhoisInfo whoisInfo; final String? name; final String source; final String ip; AutoClient({ required this.whoisInfo, this.name, required this.source, required this.ip, }); factory AutoClient.fromJson(Map json) => AutoClient( whoisInfo: WhoisInfo.fromJson(json["whois_info"]), name: json["name"], source: json["source"], ip: json["ip"], ); Map toJson() => { "whois_info": whoisInfo.toJson(), "name": name, "source": source, "ip": ip, }; } class WhoisInfo { final String? country; final String? orgname; WhoisInfo({ this.country, this.orgname, }); factory WhoisInfo.fromJson(Map json) => WhoisInfo( country: json["country"], orgname: json["orgname"], ); Map toJson() => { "country": country, "orgname": orgname, }; } class Client { final String name; final List blockedServices; final List ids; final List tags; final List upstreams; final bool filteringEnabled; final bool parentalEnabled; final bool safebrowsingEnabled; final bool? safesearchEnabled; final bool useGlobalBlockedServices; final bool useGlobalSettings; final SafeSearch? safeSearch; Client({ required this.name, required this.blockedServices, required this.ids, required this.tags, required this.upstreams, required this.filteringEnabled, required this.parentalEnabled, required this.safebrowsingEnabled, required this.safesearchEnabled, required this.useGlobalBlockedServices, required this.useGlobalSettings, required this.safeSearch, }); factory Client.fromJson(Map json) => Client( name: json["name"], blockedServices: json["blocked_services"] != null ? List.from(json["blocked_services"]) : [], ids: json["ids"] != null ? List.from(json["ids"].map((x) => x)) : [], tags: json["tags"] != null ? List.from(json["tags"].map((x) => x)) : [], upstreams: json["upstreams"] != null ? List.from(json["upstreams"].map((x) => x)) : [], filteringEnabled: json["filtering_enabled"], parentalEnabled: json["parental_enabled"], safebrowsingEnabled: json["safebrowsing_enabled"], safesearchEnabled: json["safesearch_enabled"], useGlobalBlockedServices: json["use_global_blocked_services"], useGlobalSettings: json["use_global_settings"], safeSearch: json["safe_search"] != null ? SafeSearch.fromJson(json["safe_search"]) : null ); Map toJson() => { "name": name, "blocked_services": blockedServices, "ids": List.from(ids.map((x) => x)), "tags": List.from(tags.map((x) => x)), "upstreams": List.from(upstreams.map((x) => x)), "filtering_enabled": filteringEnabled, "parental_enabled": parentalEnabled, "safebrowsing_enabled": safebrowsingEnabled, "safesearch_enabled": safesearchEnabled, "safe_search": safeSearch, "use_global_blocked_services": useGlobalBlockedServices, "use_global_settings": useGlobalSettings, }; }