class ApiInfo {
  bool? canExecute;
  List<ApiInfo>? children;
  String? description;
  String? displayValue;
  String? parentDescription;
  String? valuesMapString;

  ApiInfo({
    this.canExecute,
    this.children,
    this.description,
    this.displayValue,
    this.parentDescription,
    this.valuesMapString,
  });

  factory ApiInfo.fromJson(Map<String, dynamic> json) {
    return ApiInfo(
      canExecute:
          json.containsKey('CanExecute') ? json['CanExecute'] == true : null,
      children: json.containsKey('Children')
          ? (json['Children'] as List<dynamic>)
              .map((e) => ApiInfo.fromJson(e))
              .toList()
          : null,
      description: json['Description'],
      displayValue: json['DisplayValue'],
      parentDescription: json['ParentDescription'],
      valuesMapString: json['ValuesMapString'],
    );
  }

  Map<String, dynamic> toJson() => {
        'CanExecute': canExecute.toString(),
        'Children': children?.map((e) => e.toJson()).toList(),
        'Description': description,
        'DisplayValue': displayValue,
        'ParentDescription': parentDescription,
        'ValuesMapString': valuesMapString,
      };
}

class UltrasoundSystem {
  late List<Probe> probes;
  late String activeProbe;
  late String activeApplication;

  UltrasoundSystem.fromJson(Map<String, dynamic> json) {
    List<dynamic> jsonProbeList = json['Probes'];
    probes = [];
    for (var jsonProbe in jsonProbeList) {
      Probe probe = Probe.fromJson(jsonProbe);
      probes.add(probe);
    }
    activeProbe = json['ActiveProbe'] ?? '';
    activeApplication = json['ActiveApplication'] ?? '';
  }
}

class Probe {
  late String name;
  late List<ApplicationInfo> applicationInfos;

  Probe.fromJson(Map<String, dynamic> json) {
    name = json['Name'];
    List<dynamic> jsonAppInfoList = json['ApplicationInfos'];
    applicationInfos = [];
    for (var jsonAppInfo in jsonAppInfoList) {
      ApplicationInfo appInfo = ApplicationInfo.fromJson(jsonAppInfo);
      applicationInfos.add(appInfo);
    }
  }
  Map<String, dynamic> toJson() => {
        'Name': name.toString(),
        'ApplicationInfos': applicationInfos.map((e) => e.toJson()).toList()
      };
}

class ApplicationInfo {
  late String id;
  late String name;
  late bool isPreferred;
  late bool isUserDefined;
  late bool isHidden;

  ApplicationInfo.fromJson(Map<String, dynamic> json) {
    id = json['Id'];
    name = json['Name'];
    isPreferred = json['IsPreferred'];
    isUserDefined = json['IsUserDefined'];
    isHidden = json['IsHidden'];
  }

  Map<String, dynamic> toJson() => {
        'Id': id,
        'Name': name,
        'IsPreferred': isPreferred,
        'IsUserDefined': isUserDefined,
        'IsHidden': isHidden,
      };
}
