class TourTask { late int sId; late int type; late String topic; bool? opt; bool? reenter; int? min; int? max; int? maxLen; bool? rt; bool? track; String? txt; int? taskArrival; int? taskFinWork; List? entries; /// Auswahloptionen eines Status-Tasks (Typ 11). List? choices; /// Eingabefelder einer Text-/Zahlen-Liste (Typ 12/13). List? fields; TourTask(); factory TourTask.fromJson(Map json) { final task = TourTask(); task.sId = json['s_id'] as int; task.type = json['type'] as int; task.topic = json['topic'] as String; task.opt = json['opt'] as bool? ?? false; task.reenter = json['reenter'] as bool? ?? false; task.min = json['min'] as int?; task.max = json['max'] as int?; task.maxLen = json['max_len'] as int?; task.rt = json['rt'] as bool?; task.track = json['track'] as bool?; task.txt = json['txt'] as String?; task.taskArrival = json['task_arrival'] as int?; task.taskFinWork = json['task_fin_work'] as int?; task.entries = json['entries'] != null ? (json['entries'] as List) .map((e) => TourEntry.fromJson(e as Map)) .toList() : null; task.choices = json['choices'] != null ? (json['choices'] as List) .map((e) => TourChoice.fromJson(e as Map)) .toList() : null; task.fields = json['fields'] != null ? (json['fields'] as List) .map((e) => TourField.fromJson(e as Map)) .toList() : null; return task; } Map toJson() { return { 's_id': sId, 'type': type, 'topic': topic, 'opt': opt, 'reenter': reenter, 'min': min, 'max': max, 'max_len': maxLen, 'rt': rt, 'track': track, 'txt': txt, 'task_arrival': taskArrival, 'task_fin_work': taskFinWork, 'entries': entries?.map((e) => e.toJson()).toList(), 'choices': choices?.map((e) => e.toJson()).toList(), 'fields': fields?.map((e) => e.toJson()).toList(), }; } } class TourEntry { late int code; late String text; late bool queryRemark; TourEntry(); factory TourEntry.fromJson(Map json) { final entry = TourEntry(); entry.code = json['code'] as int; entry.text = json['text'] as String; entry.queryRemark = json['query_remark'] as bool? ?? false; return entry; } Map toJson() { return { 'code': code, 'text': text, 'query_remark': queryRemark, }; } } /// Eine Auswahloption eines Status-Tasks (Typ 11). Entspricht {@code Choice} /// im App-JSON (txt, ret, term, quest, action, price). class TourChoice { late String txt; late int ret; bool? term; String? quest; String? action; String? price; TourChoice(); factory TourChoice.fromJson(Map json) { final choice = TourChoice(); choice.txt = json['txt'] as String? ?? ''; choice.ret = json['ret'] as int? ?? 0; choice.term = json['term'] as bool?; choice.quest = json['quest'] as String?; choice.action = json['action'] as String?; choice.price = json['price'] as String?; return choice; } Map toJson() { return { 'txt': txt, 'ret': ret, 'term': term, 'quest': quest, 'action': action, 'price': price, }; } /// Ob nach Auswahl dieser Option eine zusätzliche Bemerkung erfragt wird. bool get requiresRemark => (quest != null && quest!.trim().isNotEmpty); } /// Ein Eingabefeld einer Text-/Zahlen-Liste (Typ 12/13). class TourField { String? title; String? placeholder; TourField(); factory TourField.fromJson(Map json) { final field = TourField(); field.title = json['title'] as String?; field.placeholder = json['placeholder'] as String?; return field; } Map toJson() { return { 'title': title, 'placeholder': placeholder, }; } }