/*
 *   Famedly Matrix SDK
 *   Copyright (C) 2019, 2020 Famedly GmbH
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as
 *   published by the Free Software Foundation, either version 3 of the
 *   License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see .
 */
class SupportedProtocol {
  List userFields;
  List locationFields;
  String icon;
  Map fieldTypes;
  List instances;
  SupportedProtocol.fromJson(Map json) {
    userFields = json['user_fields'].cast();
    locationFields = json['location_fields'].cast();
    icon = json['icon'];
    fieldTypes = (json['field_types'] as Map)
        .map((k, v) => MapEntry(k, ProtocolFieldType.fromJson(v)));
    instances = [];
    json['instances'].forEach((v) {
      instances.add(ProtocolInstance.fromJson(v));
    });
  }
  Map toJson() {
    final data = {};
    data['user_fields'] = userFields;
    data['location_fields'] = locationFields;
    data['icon'] = icon;
    data['field_types'] = fieldTypes.map((k, v) => MapEntry(k, v.toJson()));
    data['instances'] = instances.map((v) => v.toJson()).toList();
    return data;
  }
}
class ProtocolFieldType {
  String regexp;
  String placeholder;
  ProtocolFieldType.fromJson(Map json) {
    regexp = json['regexp'];
    placeholder = json['placeholder'];
  }
  Map toJson() {
    final data = {};
    data['regexp'] = regexp;
    data['placeholder'] = placeholder;
    return data;
  }
}
class ProtocolInstance {
  String networkId;
  String desc;
  String icon;
  dynamic fields;
  ProtocolInstance.fromJson(Map json) {
    networkId = json['network_id'];
    desc = json['desc'];
    icon = json['icon'];
    fields = json['fields'];
  }
  Map toJson() {
    final data = {};
    data['network_id'] = networkId;
    data['desc'] = desc;
    if (icon != null) {
      data['icon'] = icon;
    }
    data['fields'] = fields;
    return data;
  }
}