import 'organization.dart'; import 'page.dart'; import 'role.dart'; class User { String? id; String? username; dynamic email; String? name; bool? enabled; dynamic posts; String? organizationId; Organization? organization; String? organizationName; String? organizationLevel; List? roles; List? permissions; List? pages; dynamic company; String? signatureImage; User({ this.id, this.username, this.email, this.name, this.enabled, this.posts, this.organizationId, this.organization, this.organizationName, this.organizationLevel, this.roles, this.permissions, this.pages, this.company, this.signatureImage, }); factory User.fromJson(Map json) => User( id: json['id'] as String?, username: json['username'] as String?, email: json['email'] as dynamic, name: json['name'] as String?, enabled: json['enabled'] as bool?, posts: json['posts'] as dynamic, organizationId: json['organizationId'] as String?, organization: json['organization'] == null ? null : Organization.fromJson(json['organization'] as Map), organizationName: json['organizationName'] as String?, organizationLevel: json['organizationLevel'] as String?, roles: (json['roles'] as List?) ?.map((e) => Role.fromJson(e as Map)) .toList(), permissions: json['permissions'] as List?, pages: (json['pages'] as List?) ?.map((e) => Page.fromJson(e as Map)) .toList(), company: json['company'] as dynamic, signatureImage: json['signatureImage'] as String?, ); Map toJson() => { 'id': id, 'username': username, 'email': email, 'name': name, 'enabled': enabled, 'posts': posts, 'organizationId': organizationId, 'organization': organization?.toJson(), 'organizationName': organizationName, 'organizationLevel': organizationLevel, 'roles': roles?.map((e) => e.toJson()).toList(), 'permissions': permissions, 'pages': pages?.map((e) => e.toJson()).toList(), 'company': company, 'signatureImage': signatureImage, }; }