/* * 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 WhoIsInfo { String userId; Map devices; WhoIsInfo.fromJson(Map json) { userId = json['user_id']; devices = json['devices'] != null ? (json['devices'] as Map) .map((k, v) => MapEntry(k, DeviceInfo.fromJson(v))) : null; } Map toJson() { final data = {}; data['user_id'] = userId; if (devices != null) { data['devices'] = devices.map((k, v) => MapEntry(k, v.toJson())); } return data; } } class DeviceInfo { List sessions; DeviceInfo.fromJson(Map json) { if (json['sessions'] != null) { sessions = []; json['sessions'].forEach((v) { sessions.add(Sessions.fromJson(v)); }); } } Map toJson() { final data = {}; if (sessions != null) { data['sessions'] = sessions.map((v) => v.toJson()).toList(); } return data; } } class Sessions { List connections; Sessions.fromJson(Map json) { if (json['connections'] != null) { connections = []; json['connections'].forEach((v) { connections.add(Connections.fromJson(v)); }); } } Map toJson() { final data = {}; if (connections != null) { data['connections'] = connections.map((v) => v.toJson()).toList(); } return data; } } class Connections { String ip; int lastSeen; String userAgent; Connections.fromJson(Map json) { ip = json['ip']; lastSeen = json['last_seen']; userAgent = json['user_agent']; } Map toJson() { final data = {}; if (ip != null) { data['ip'] = ip; } if (lastSeen != null) { data['last_seen'] = lastSeen; } if (userAgent != null) { data['user_agent'] = userAgent; } return data; } }