class AuthResponse { final String token; final String userId; final String email; AuthResponse({required this.token, required this.userId, required this.email}); factory AuthResponse.fromJson(Map json) { return AuthResponse( token: json['token'] as String, userId: json['userId'] as String, email: json['email'] as String, ); } } class AppsResponse { final List teams; AppsResponse({required this.teams}); factory AppsResponse.fromJson(Map json) { return AppsResponse( teams: (json['teams'] as List) .map((e) => TeamWithApps.fromJson(e)) .toList(), ); } List get allApps => teams.expand((t) => t.apps).toList(); } class TeamWithApps { final String id; final String name; final List apps; TeamWithApps({required this.id, required this.name, required this.apps}); factory TeamWithApps.fromJson(Map json) { return TeamWithApps( id: json['id'], name: json['name'], apps: (json['apps'] as List).map((e) => AppInfo.fromJson(e)).toList(), ); } } class AppInfo { final String id; final String title; final String packageName; final String icon; final Track release; final Track debug; final Track profile; AppInfo({ required this.id, required this.title, required this.packageName, required this.icon, required this.release, required this.debug, required this.profile, }); factory AppInfo.fromJson(Map json) { return AppInfo( id: json['id'], title: json['title'], packageName: json['packageName'], icon: json['icon'], release: Track.fromJson(json['release']), debug: Track.fromJson(json['debug']), profile: Track.fromJson(json['profile']), ); } Track track(String name) { switch (name) { case 'release': return release; case 'debug': return debug; case 'profile': return profile; default: return release; } } } class Track { final VersionInfo? current; final VersionInfo? pending; Track({this.current, this.pending}); factory Track.fromJson(Map json) { return Track( current: json['current'] != null ? VersionInfo.fromJson(json['current']) : null, pending: json['pending'] != null ? VersionInfo.fromJson(json['pending']) : null, ); } } class VersionInfo { final String id; final String version; final String name; final bool public; final bool hasFile; final DateTime created; VersionInfo({ required this.id, required this.version, required this.name, required this.public, required this.hasFile, required this.created, }); factory VersionInfo.fromJson(Map json) { return VersionInfo( id: json['id'], version: json['version'], name: json['name'] ?? '', public: json['public'] ?? false, hasFile: json['hasFile'] ?? false, created: DateTime.parse(json['created']), ); } }