LCOV - code coverage report
Current view: top level - lib/matrix_api_lite/generated - model.dart (source / functions) Hit Total Coverage
Test: merged.info Lines: 226 1474 15.3 %
Date: 2024-09-27 11:38:01 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:enhanced_enum/enhanced_enum.dart';
       2             : 
       3             : import 'package:matrix/matrix_api_lite/model/children_state.dart';
       4             : import 'package:matrix/matrix_api_lite/model/matrix_event.dart';
       5             : import 'package:matrix/matrix_api_lite/model/matrix_keys.dart';
       6             : 
       7             : part 'model.g.dart';
       8             : 
       9             : class _NameSource {
      10             :   final String source;
      11          82 :   const _NameSource(this.source);
      12             : }
      13             : 
      14             : ///
      15             : @_NameSource('spec')
      16             : class HomeserverInformation {
      17           0 :   HomeserverInformation({
      18             :     required this.baseUrl,
      19             :   });
      20             : 
      21           4 :   HomeserverInformation.fromJson(Map<String, Object?> json)
      22           8 :       : baseUrl = Uri.parse(json['base_url'] as String);
      23           2 :   Map<String, Object?> toJson() => {
      24           2 :         'base_url': baseUrl.toString(),
      25             :       };
      26             : 
      27             :   /// The base URL for the homeserver for client-server connections.
      28             :   Uri baseUrl;
      29             : }
      30             : 
      31             : ///
      32             : @_NameSource('spec')
      33             : class IdentityServerInformation {
      34           0 :   IdentityServerInformation({
      35             :     required this.baseUrl,
      36             :   });
      37             : 
      38           4 :   IdentityServerInformation.fromJson(Map<String, Object?> json)
      39           8 :       : baseUrl = Uri.parse(json['base_url'] as String);
      40           2 :   Map<String, Object?> toJson() => {
      41           2 :         'base_url': baseUrl.toString(),
      42             :       };
      43             : 
      44             :   /// The base URL for the identity server for client-server connections.
      45             :   Uri baseUrl;
      46             : }
      47             : 
      48             : /// Used by clients to determine the homeserver, identity server, and other
      49             : /// optional components they should be interacting with.
      50             : @_NameSource('spec')
      51             : class DiscoveryInformation {
      52           0 :   DiscoveryInformation({
      53             :     required this.mHomeserver,
      54             :     this.mIdentityServer,
      55             :     this.additionalProperties = const {},
      56             :   });
      57             : 
      58           4 :   DiscoveryInformation.fromJson(Map<String, Object?> json)
      59           4 :       : mHomeserver = HomeserverInformation.fromJson(
      60           4 :             json['m.homeserver'] as Map<String, Object?>),
      61           4 :         mIdentityServer = ((v) => v != null
      62           4 :             ? IdentityServerInformation.fromJson(v as Map<String, Object?>)
      63           8 :             : null)(json['m.identity_server']),
      64           8 :         additionalProperties = Map.fromEntries(json.entries
      65           4 :             .where(
      66          16 :                 (e) => !['m.homeserver', 'm.identity_server'].contains(e.key))
      67           8 :             .map((e) => MapEntry(e.key, e.value as Map<String, Object?>)));
      68           1 :   Map<String, Object?> toJson() {
      69           1 :     final mIdentityServer = this.mIdentityServer;
      70           1 :     return {
      71           1 :       ...additionalProperties,
      72           3 :       'm.homeserver': mHomeserver.toJson(),
      73             :       if (mIdentityServer != null)
      74           2 :         'm.identity_server': mIdentityServer.toJson(),
      75             :     };
      76             :   }
      77             : 
      78             :   /// Used by clients to discover homeserver information.
      79             :   HomeserverInformation mHomeserver;
      80             : 
      81             :   /// Used by clients to discover identity server information.
      82             :   IdentityServerInformation? mIdentityServer;
      83             : 
      84             :   Map<String, Map<String, Object?>> additionalProperties;
      85             : }
      86             : 
      87             : ///
      88             : @_NameSource('generated')
      89             : @EnhancedEnum()
      90             : enum Role {
      91             :   @EnhancedEnumValue(name: 'm.role.admin')
      92             :   mRoleAdmin,
      93             :   @EnhancedEnumValue(name: 'm.role.security')
      94             :   mRoleSecurity
      95             : }
      96             : 
      97             : /// A way to contact the server administrator.
      98             : @_NameSource('spec')
      99             : class Contact {
     100           0 :   Contact({
     101             :     this.emailAddress,
     102             :     this.matrixId,
     103             :     required this.role,
     104             :   });
     105             : 
     106           0 :   Contact.fromJson(Map<String, Object?> json)
     107             :       : emailAddress =
     108           0 :             ((v) => v != null ? v as String : null)(json['email_address']),
     109           0 :         matrixId = ((v) => v != null ? v as String : null)(json['matrix_id']),
     110           0 :         role = Role.values.fromString(json['role'] as String)!;
     111           0 :   Map<String, Object?> toJson() {
     112           0 :     final emailAddress = this.emailAddress;
     113           0 :     final matrixId = this.matrixId;
     114           0 :     return {
     115           0 :       if (emailAddress != null) 'email_address': emailAddress,
     116           0 :       if (matrixId != null) 'matrix_id': matrixId,
     117           0 :       'role': role.name,
     118             :     };
     119             :   }
     120             : 
     121             :   /// An email address to reach the administrator.
     122             :   ///
     123             :   /// At least one of `matrix_id` or `email_address` is
     124             :   /// required.
     125             :   String? emailAddress;
     126             : 
     127             :   /// A [Matrix User ID](https://spec.matrix.org/unstable/appendices/#user-identifiers)
     128             :   /// representing the administrator.
     129             :   ///
     130             :   /// It could be an account registered on a different
     131             :   /// homeserver so the administrator can be contacted
     132             :   /// when the homeserver is down.
     133             :   ///
     134             :   /// At least one of `matrix_id` or `email_address` is
     135             :   /// required.
     136             :   String? matrixId;
     137             : 
     138             :   /// An informal description of what the contact methods
     139             :   /// are used for.
     140             :   ///
     141             :   /// `m.role.admin` is a catch-all role for any queries
     142             :   /// and `m.role.security` is intended for sensitive
     143             :   /// requests.
     144             :   ///
     145             :   /// Unspecified roles are permitted through the use of
     146             :   /// [Namespaced Identifiers](https://spec.matrix.org/unstable/appendices/#common-namespaced-identifier-grammar).
     147             :   Role role;
     148             : }
     149             : 
     150             : ///
     151             : @_NameSource('generated')
     152             : class GetWellknownSupportResponse {
     153           0 :   GetWellknownSupportResponse({
     154             :     this.contacts,
     155             :     this.supportPage,
     156             :   });
     157             : 
     158           0 :   GetWellknownSupportResponse.fromJson(Map<String, Object?> json)
     159           0 :       : contacts = ((v) => v != null
     160             :             ? (v as List)
     161           0 :                 .map((v) => Contact.fromJson(v as Map<String, Object?>))
     162           0 :                 .toList()
     163           0 :             : null)(json['contacts']),
     164             :         supportPage =
     165           0 :             ((v) => v != null ? v as String : null)(json['support_page']);
     166           0 :   Map<String, Object?> toJson() {
     167           0 :     final contacts = this.contacts;
     168           0 :     final supportPage = this.supportPage;
     169           0 :     return {
     170             :       if (contacts != null)
     171           0 :         'contacts': contacts.map((v) => v.toJson()).toList(),
     172           0 :       if (supportPage != null) 'support_page': supportPage,
     173             :     };
     174             :   }
     175             : 
     176             :   /// Ways to contact the server administrator.
     177             :   ///
     178             :   /// At least one of `contacts` or `support_page` is required.
     179             :   /// If only `contacts` is set, it must contain at least one
     180             :   /// item.
     181             :   List<Contact>? contacts;
     182             : 
     183             :   /// The URL of a page to give users help specific to the
     184             :   /// homeserver, like extra login/registration steps.
     185             :   ///
     186             :   /// At least one of `contacts` or `support_page` is required.
     187             :   String? supportPage;
     188             : }
     189             : 
     190             : ///
     191             : @_NameSource('generated')
     192             : class GenerateLoginTokenResponse {
     193           0 :   GenerateLoginTokenResponse({
     194             :     required this.expiresInMs,
     195             :     required this.loginToken,
     196             :   });
     197             : 
     198           0 :   GenerateLoginTokenResponse.fromJson(Map<String, Object?> json)
     199           0 :       : expiresInMs = json['expires_in_ms'] as int,
     200           0 :         loginToken = json['login_token'] as String;
     201           0 :   Map<String, Object?> toJson() => {
     202           0 :         'expires_in_ms': expiresInMs,
     203           0 :         'login_token': loginToken,
     204             :       };
     205             : 
     206             :   /// The time remaining in milliseconds until the homeserver will no longer accept the token. `120000`
     207             :   /// (2 minutes) is recommended as a default.
     208             :   int expiresInMs;
     209             : 
     210             :   /// The login token for the `m.login.token` login flow.
     211             :   String loginToken;
     212             : }
     213             : 
     214             : ///
     215             : @_NameSource('rule override generated')
     216             : class MediaConfig {
     217           0 :   MediaConfig({
     218             :     this.mUploadSize,
     219             :   });
     220             : 
     221           4 :   MediaConfig.fromJson(Map<String, Object?> json)
     222             :       : mUploadSize =
     223          12 :             ((v) => v != null ? v as int : null)(json['m.upload.size']);
     224           0 :   Map<String, Object?> toJson() {
     225           0 :     final mUploadSize = this.mUploadSize;
     226           0 :     return {
     227           0 :       if (mUploadSize != null) 'm.upload.size': mUploadSize,
     228             :     };
     229             :   }
     230             : 
     231             :   /// The maximum size an upload can be in bytes.
     232             :   /// Clients SHOULD use this as a guide when uploading content.
     233             :   /// If not listed or null, the size limit should be treated as unknown.
     234             :   int? mUploadSize;
     235             : }
     236             : 
     237             : ///
     238             : @_NameSource('rule override generated')
     239             : class PreviewForUrl {
     240           0 :   PreviewForUrl({
     241             :     this.matrixImageSize,
     242             :     this.ogImage,
     243             :   });
     244             : 
     245           0 :   PreviewForUrl.fromJson(Map<String, Object?> json)
     246             :       : matrixImageSize =
     247           0 :             ((v) => v != null ? v as int : null)(json['matrix:image:size']),
     248           0 :         ogImage = ((v) =>
     249           0 :             v != null ? Uri.parse(v as String) : null)(json['og:image']);
     250           0 :   Map<String, Object?> toJson() {
     251           0 :     final matrixImageSize = this.matrixImageSize;
     252           0 :     final ogImage = this.ogImage;
     253           0 :     return {
     254           0 :       if (matrixImageSize != null) 'matrix:image:size': matrixImageSize,
     255           0 :       if (ogImage != null) 'og:image': ogImage.toString(),
     256             :     };
     257             :   }
     258             : 
     259             :   /// The byte-size of the image. Omitted if there is no image attached.
     260             :   int? matrixImageSize;
     261             : 
     262             :   /// An [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris) to the image. Omitted if there is no image.
     263             :   Uri? ogImage;
     264             : }
     265             : 
     266             : ///
     267             : @_NameSource('generated')
     268             : @EnhancedEnum()
     269             : enum Method {
     270             :   @EnhancedEnumValue(name: 'crop')
     271             :   crop,
     272             :   @EnhancedEnumValue(name: 'scale')
     273             :   scale
     274             : }
     275             : 
     276             : ///
     277             : @_NameSource('spec')
     278             : class PublicRoomsChunk {
     279           0 :   PublicRoomsChunk({
     280             :     this.avatarUrl,
     281             :     this.canonicalAlias,
     282             :     required this.guestCanJoin,
     283             :     this.joinRule,
     284             :     this.name,
     285             :     required this.numJoinedMembers,
     286             :     required this.roomId,
     287             :     this.roomType,
     288             :     this.topic,
     289             :     required this.worldReadable,
     290             :   });
     291             : 
     292           0 :   PublicRoomsChunk.fromJson(Map<String, Object?> json)
     293           0 :       : avatarUrl = ((v) =>
     294           0 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
     295             :         canonicalAlias =
     296           0 :             ((v) => v != null ? v as String : null)(json['canonical_alias']),
     297           0 :         guestCanJoin = json['guest_can_join'] as bool,
     298           0 :         joinRule = ((v) => v != null ? v as String : null)(json['join_rule']),
     299           0 :         name = ((v) => v != null ? v as String : null)(json['name']),
     300           0 :         numJoinedMembers = json['num_joined_members'] as int,
     301           0 :         roomId = json['room_id'] as String,
     302           0 :         roomType = ((v) => v != null ? v as String : null)(json['room_type']),
     303           0 :         topic = ((v) => v != null ? v as String : null)(json['topic']),
     304           0 :         worldReadable = json['world_readable'] as bool;
     305           0 :   Map<String, Object?> toJson() {
     306           0 :     final avatarUrl = this.avatarUrl;
     307           0 :     final canonicalAlias = this.canonicalAlias;
     308           0 :     final joinRule = this.joinRule;
     309           0 :     final name = this.name;
     310           0 :     final roomType = this.roomType;
     311           0 :     final topic = this.topic;
     312           0 :     return {
     313           0 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
     314           0 :       if (canonicalAlias != null) 'canonical_alias': canonicalAlias,
     315           0 :       'guest_can_join': guestCanJoin,
     316           0 :       if (joinRule != null) 'join_rule': joinRule,
     317           0 :       if (name != null) 'name': name,
     318           0 :       'num_joined_members': numJoinedMembers,
     319           0 :       'room_id': roomId,
     320           0 :       if (roomType != null) 'room_type': roomType,
     321           0 :       if (topic != null) 'topic': topic,
     322           0 :       'world_readable': worldReadable,
     323             :     };
     324             :   }
     325             : 
     326             :   /// The URL for the room's avatar, if one is set.
     327             :   Uri? avatarUrl;
     328             : 
     329             :   /// The canonical alias of the room, if any.
     330             :   String? canonicalAlias;
     331             : 
     332             :   /// Whether guest users may join the room and participate in it.
     333             :   /// If they can, they will be subject to ordinary power level
     334             :   /// rules like any other user.
     335             :   bool guestCanJoin;
     336             : 
     337             :   /// The room's join rule. When not present, the room is assumed to
     338             :   /// be `public`.
     339             :   String? joinRule;
     340             : 
     341             :   /// The name of the room, if any.
     342             :   String? name;
     343             : 
     344             :   /// The number of members joined to the room.
     345             :   int numJoinedMembers;
     346             : 
     347             :   /// The ID of the room.
     348             :   String roomId;
     349             : 
     350             :   /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
     351             :   String? roomType;
     352             : 
     353             :   /// The topic of the room, if any.
     354             :   String? topic;
     355             : 
     356             :   /// Whether the room may be viewed by guest users without joining.
     357             :   bool worldReadable;
     358             : }
     359             : 
     360             : ///
     361             : @_NameSource('spec')
     362             : class SpaceHierarchyRoomsChunk {
     363           0 :   SpaceHierarchyRoomsChunk({
     364             :     required this.childrenState,
     365             :     this.roomType,
     366             :   });
     367             : 
     368           0 :   SpaceHierarchyRoomsChunk.fromJson(Map<String, Object?> json)
     369           0 :       : childrenState = (json['children_state'] as List)
     370           0 :             .map((v) => ChildrenState.fromJson(v as Map<String, Object?>))
     371           0 :             .toList(),
     372           0 :         roomType = ((v) => v != null ? v as String : null)(json['room_type']);
     373           0 :   Map<String, Object?> toJson() {
     374           0 :     final roomType = this.roomType;
     375           0 :     return {
     376           0 :       'children_state': childrenState.map((v) => v.toJson()).toList(),
     377           0 :       if (roomType != null) 'room_type': roomType,
     378             :     };
     379             :   }
     380             : 
     381             :   /// The [`m.space.child`](#mspacechild) events of the space-room, represented
     382             :   /// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key.
     383             :   ///
     384             :   /// If the room is not a space-room, this should be empty.
     385             :   List<ChildrenState> childrenState;
     386             : 
     387             :   /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
     388             :   String? roomType;
     389             : }
     390             : 
     391             : ///
     392             : @_NameSource('rule override generated')
     393             : class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk {
     394           0 :   SpaceRoomsChunk({
     395             :     this.avatarUrl,
     396             :     this.canonicalAlias,
     397             :     required this.guestCanJoin,
     398             :     this.joinRule,
     399             :     this.name,
     400             :     required this.numJoinedMembers,
     401             :     required this.roomId,
     402             :     this.roomType,
     403             :     this.topic,
     404             :     required this.worldReadable,
     405             :     required this.childrenState,
     406             :   });
     407             : 
     408           0 :   SpaceRoomsChunk.fromJson(Map<String, Object?> json)
     409           0 :       : avatarUrl = ((v) =>
     410           0 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
     411             :         canonicalAlias =
     412           0 :             ((v) => v != null ? v as String : null)(json['canonical_alias']),
     413           0 :         guestCanJoin = json['guest_can_join'] as bool,
     414           0 :         joinRule = ((v) => v != null ? v as String : null)(json['join_rule']),
     415           0 :         name = ((v) => v != null ? v as String : null)(json['name']),
     416           0 :         numJoinedMembers = json['num_joined_members'] as int,
     417           0 :         roomId = json['room_id'] as String,
     418           0 :         roomType = ((v) => v != null ? v as String : null)(json['room_type']),
     419           0 :         topic = ((v) => v != null ? v as String : null)(json['topic']),
     420           0 :         worldReadable = json['world_readable'] as bool,
     421           0 :         childrenState = (json['children_state'] as List)
     422           0 :             .map((v) => ChildrenState.fromJson(v as Map<String, Object?>))
     423           0 :             .toList();
     424           0 :   @override
     425             :   Map<String, Object?> toJson() {
     426           0 :     final avatarUrl = this.avatarUrl;
     427           0 :     final canonicalAlias = this.canonicalAlias;
     428           0 :     final joinRule = this.joinRule;
     429           0 :     final name = this.name;
     430           0 :     final roomType = this.roomType;
     431           0 :     final topic = this.topic;
     432           0 :     return {
     433           0 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
     434           0 :       if (canonicalAlias != null) 'canonical_alias': canonicalAlias,
     435           0 :       'guest_can_join': guestCanJoin,
     436           0 :       if (joinRule != null) 'join_rule': joinRule,
     437           0 :       if (name != null) 'name': name,
     438           0 :       'num_joined_members': numJoinedMembers,
     439           0 :       'room_id': roomId,
     440           0 :       if (roomType != null) 'room_type': roomType,
     441           0 :       if (topic != null) 'topic': topic,
     442           0 :       'world_readable': worldReadable,
     443           0 :       'children_state': childrenState.map((v) => v.toJson()).toList(),
     444             :     };
     445             :   }
     446             : 
     447             :   /// The URL for the room's avatar, if one is set.
     448             :   @override
     449             :   Uri? avatarUrl;
     450             : 
     451             :   /// The canonical alias of the room, if any.
     452             :   @override
     453             :   String? canonicalAlias;
     454             : 
     455             :   /// Whether guest users may join the room and participate in it.
     456             :   /// If they can, they will be subject to ordinary power level
     457             :   /// rules like any other user.
     458             :   @override
     459             :   bool guestCanJoin;
     460             : 
     461             :   /// The room's join rule. When not present, the room is assumed to
     462             :   /// be `public`.
     463             :   @override
     464             :   String? joinRule;
     465             : 
     466             :   /// The name of the room, if any.
     467             :   @override
     468             :   String? name;
     469             : 
     470             :   /// The number of members joined to the room.
     471             :   @override
     472             :   int numJoinedMembers;
     473             : 
     474             :   /// The ID of the room.
     475             :   @override
     476             :   String roomId;
     477             : 
     478             :   /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
     479             :   @override
     480             :   String? roomType;
     481             : 
     482             :   /// The topic of the room, if any.
     483             :   @override
     484             :   String? topic;
     485             : 
     486             :   /// Whether the room may be viewed by guest users without joining.
     487             :   @override
     488             :   bool worldReadable;
     489             : 
     490             :   /// The [`m.space.child`](#mspacechild) events of the space-room, represented
     491             :   /// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key.
     492             :   ///
     493             :   /// If the room is not a space-room, this should be empty.
     494             :   @override
     495             :   List<ChildrenState> childrenState;
     496             : }
     497             : 
     498             : ///
     499             : @_NameSource('generated')
     500             : class GetSpaceHierarchyResponse {
     501           0 :   GetSpaceHierarchyResponse({
     502             :     this.nextBatch,
     503             :     required this.rooms,
     504             :   });
     505             : 
     506           0 :   GetSpaceHierarchyResponse.fromJson(Map<String, Object?> json)
     507           0 :       : nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
     508           0 :         rooms = (json['rooms'] as List)
     509           0 :             .map((v) => SpaceRoomsChunk.fromJson(v as Map<String, Object?>))
     510           0 :             .toList();
     511           0 :   Map<String, Object?> toJson() {
     512           0 :     final nextBatch = this.nextBatch;
     513           0 :     return {
     514           0 :       if (nextBatch != null) 'next_batch': nextBatch,
     515           0 :       'rooms': rooms.map((v) => v.toJson()).toList(),
     516             :     };
     517             :   }
     518             : 
     519             :   /// A token to supply to `from` to keep paginating the responses. Not present when there are
     520             :   /// no further results.
     521             :   String? nextBatch;
     522             : 
     523             :   /// The rooms for the current page, with the current filters.
     524             :   List<SpaceRoomsChunk> rooms;
     525             : }
     526             : 
     527             : ///
     528             : @_NameSource('rule override generated')
     529             : @EnhancedEnum()
     530             : enum Direction {
     531             :   @EnhancedEnumValue(name: 'b')
     532             :   b,
     533             :   @EnhancedEnumValue(name: 'f')
     534             :   f
     535             : }
     536             : 
     537             : ///
     538             : @_NameSource('generated')
     539             : class GetRelatingEventsResponse {
     540           0 :   GetRelatingEventsResponse({
     541             :     required this.chunk,
     542             :     this.nextBatch,
     543             :     this.prevBatch,
     544             :     this.recursionDepth,
     545             :   });
     546             : 
     547           0 :   GetRelatingEventsResponse.fromJson(Map<String, Object?> json)
     548           0 :       : chunk = (json['chunk'] as List)
     549           0 :             .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
     550           0 :             .toList(),
     551           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
     552           0 :         prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']),
     553             :         recursionDepth =
     554           0 :             ((v) => v != null ? v as int : null)(json['recursion_depth']);
     555           0 :   Map<String, Object?> toJson() {
     556           0 :     final nextBatch = this.nextBatch;
     557           0 :     final prevBatch = this.prevBatch;
     558           0 :     final recursionDepth = this.recursionDepth;
     559           0 :     return {
     560           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
     561           0 :       if (nextBatch != null) 'next_batch': nextBatch,
     562           0 :       if (prevBatch != null) 'prev_batch': prevBatch,
     563           0 :       if (recursionDepth != null) 'recursion_depth': recursionDepth,
     564             :     };
     565             :   }
     566             : 
     567             :   /// The child events of the requested event, ordered topologically most-recent
     568             :   /// first. The events returned will match the `relType` and `eventType` supplied
     569             :   /// in the URL.
     570             :   List<MatrixEvent> chunk;
     571             : 
     572             :   /// An opaque string representing a pagination token. The absence of this token
     573             :   /// means there are no more results to fetch and the client should stop paginating.
     574             :   String? nextBatch;
     575             : 
     576             :   /// An opaque string representing a pagination token. The absence of this token
     577             :   /// means this is the start of the result set, i.e. this is the first batch/page.
     578             :   String? prevBatch;
     579             : 
     580             :   /// If the `recurse` parameter was supplied by the client, this response field is
     581             :   /// mandatory and gives the actual depth to which the server recursed. If the client
     582             :   /// did not specify the `recurse` parameter, this field must be absent.
     583             :   int? recursionDepth;
     584             : }
     585             : 
     586             : ///
     587             : @_NameSource('generated')
     588             : class GetRelatingEventsWithRelTypeResponse {
     589           0 :   GetRelatingEventsWithRelTypeResponse({
     590             :     required this.chunk,
     591             :     this.nextBatch,
     592             :     this.prevBatch,
     593             :     this.recursionDepth,
     594             :   });
     595             : 
     596           0 :   GetRelatingEventsWithRelTypeResponse.fromJson(Map<String, Object?> json)
     597           0 :       : chunk = (json['chunk'] as List)
     598           0 :             .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
     599           0 :             .toList(),
     600           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
     601           0 :         prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']),
     602             :         recursionDepth =
     603           0 :             ((v) => v != null ? v as int : null)(json['recursion_depth']);
     604           0 :   Map<String, Object?> toJson() {
     605           0 :     final nextBatch = this.nextBatch;
     606           0 :     final prevBatch = this.prevBatch;
     607           0 :     final recursionDepth = this.recursionDepth;
     608           0 :     return {
     609           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
     610           0 :       if (nextBatch != null) 'next_batch': nextBatch,
     611           0 :       if (prevBatch != null) 'prev_batch': prevBatch,
     612           0 :       if (recursionDepth != null) 'recursion_depth': recursionDepth,
     613             :     };
     614             :   }
     615             : 
     616             :   /// The child events of the requested event, ordered topologically most-recent
     617             :   /// first. The events returned will match the `relType` and `eventType` supplied
     618             :   /// in the URL.
     619             :   List<MatrixEvent> chunk;
     620             : 
     621             :   /// An opaque string representing a pagination token. The absence of this token
     622             :   /// means there are no more results to fetch and the client should stop paginating.
     623             :   String? nextBatch;
     624             : 
     625             :   /// An opaque string representing a pagination token. The absence of this token
     626             :   /// means this is the start of the result set, i.e. this is the first batch/page.
     627             :   String? prevBatch;
     628             : 
     629             :   /// If the `recurse` parameter was supplied by the client, this response field is
     630             :   /// mandatory and gives the actual depth to which the server recursed. If the client
     631             :   /// did not specify the `recurse` parameter, this field must be absent.
     632             :   int? recursionDepth;
     633             : }
     634             : 
     635             : ///
     636             : @_NameSource('generated')
     637             : class GetRelatingEventsWithRelTypeAndEventTypeResponse {
     638           0 :   GetRelatingEventsWithRelTypeAndEventTypeResponse({
     639             :     required this.chunk,
     640             :     this.nextBatch,
     641             :     this.prevBatch,
     642             :     this.recursionDepth,
     643             :   });
     644             : 
     645           0 :   GetRelatingEventsWithRelTypeAndEventTypeResponse.fromJson(
     646             :       Map<String, Object?> json)
     647           0 :       : chunk = (json['chunk'] as List)
     648           0 :             .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
     649           0 :             .toList(),
     650           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
     651           0 :         prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']),
     652             :         recursionDepth =
     653           0 :             ((v) => v != null ? v as int : null)(json['recursion_depth']);
     654           0 :   Map<String, Object?> toJson() {
     655           0 :     final nextBatch = this.nextBatch;
     656           0 :     final prevBatch = this.prevBatch;
     657           0 :     final recursionDepth = this.recursionDepth;
     658           0 :     return {
     659           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
     660           0 :       if (nextBatch != null) 'next_batch': nextBatch,
     661           0 :       if (prevBatch != null) 'prev_batch': prevBatch,
     662           0 :       if (recursionDepth != null) 'recursion_depth': recursionDepth,
     663             :     };
     664             :   }
     665             : 
     666             :   /// The child events of the requested event, ordered topologically most-recent
     667             :   /// first. The events returned will match the `relType` and `eventType` supplied
     668             :   /// in the URL.
     669             :   List<MatrixEvent> chunk;
     670             : 
     671             :   /// An opaque string representing a pagination token. The absence of this token
     672             :   /// means there are no more results to fetch and the client should stop paginating.
     673             :   String? nextBatch;
     674             : 
     675             :   /// An opaque string representing a pagination token. The absence of this token
     676             :   /// means this is the start of the result set, i.e. this is the first batch/page.
     677             :   String? prevBatch;
     678             : 
     679             :   /// If the `recurse` parameter was supplied by the client, this response field is
     680             :   /// mandatory and gives the actual depth to which the server recursed. If the client
     681             :   /// did not specify the `recurse` parameter, this field must be absent.
     682             :   int? recursionDepth;
     683             : }
     684             : 
     685             : ///
     686             : @_NameSource('generated')
     687             : @EnhancedEnum()
     688             : enum Include {
     689             :   @EnhancedEnumValue(name: 'all')
     690             :   all,
     691             :   @EnhancedEnumValue(name: 'participated')
     692             :   participated
     693             : }
     694             : 
     695             : ///
     696             : @_NameSource('generated')
     697             : class GetThreadRootsResponse {
     698           0 :   GetThreadRootsResponse({
     699             :     required this.chunk,
     700             :     this.nextBatch,
     701             :   });
     702             : 
     703           0 :   GetThreadRootsResponse.fromJson(Map<String, Object?> json)
     704           0 :       : chunk = (json['chunk'] as List)
     705           0 :             .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
     706           0 :             .toList(),
     707           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']);
     708           0 :   Map<String, Object?> toJson() {
     709           0 :     final nextBatch = this.nextBatch;
     710           0 :     return {
     711           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
     712           0 :       if (nextBatch != null) 'next_batch': nextBatch,
     713             :     };
     714             :   }
     715             : 
     716             :   /// The thread roots, ordered by the `latest_event` in each event's aggregated children. All events
     717             :   /// returned include bundled [aggregations](https://spec.matrix.org/unstable/client-server-api/#aggregations-of-child-events).
     718             :   ///
     719             :   /// If the thread root event was sent by an [ignored user](https://spec.matrix.org/unstable/client-server-api/#ignoring-users), the
     720             :   /// event is returned redacted to the caller. This is to simulate the same behaviour of a client doing
     721             :   /// aggregation locally on the thread.
     722             :   List<MatrixEvent> chunk;
     723             : 
     724             :   /// A token to supply to `from` to keep paginating the responses. Not present when there are
     725             :   /// no further results.
     726             :   String? nextBatch;
     727             : }
     728             : 
     729             : ///
     730             : @_NameSource('generated')
     731             : class GetEventByTimestampResponse {
     732           0 :   GetEventByTimestampResponse({
     733             :     required this.eventId,
     734             :     required this.originServerTs,
     735             :   });
     736             : 
     737           0 :   GetEventByTimestampResponse.fromJson(Map<String, Object?> json)
     738           0 :       : eventId = json['event_id'] as String,
     739           0 :         originServerTs = json['origin_server_ts'] as int;
     740           0 :   Map<String, Object?> toJson() => {
     741           0 :         'event_id': eventId,
     742           0 :         'origin_server_ts': originServerTs,
     743             :       };
     744             : 
     745             :   /// The ID of the event found
     746             :   String eventId;
     747             : 
     748             :   /// The event's timestamp, in milliseconds since the Unix epoch.
     749             :   /// This makes it easy to do a quick comparison to see if the
     750             :   /// `event_id` fetched is too far out of range to be useful for your
     751             :   /// use case.
     752             :   int originServerTs;
     753             : }
     754             : 
     755             : ///
     756             : @_NameSource('rule override generated')
     757             : @EnhancedEnum()
     758             : enum ThirdPartyIdentifierMedium {
     759             :   @EnhancedEnumValue(name: 'email')
     760             :   email,
     761             :   @EnhancedEnumValue(name: 'msisdn')
     762             :   msisdn
     763             : }
     764             : 
     765             : ///
     766             : @_NameSource('spec')
     767             : class ThirdPartyIdentifier {
     768           0 :   ThirdPartyIdentifier({
     769             :     required this.addedAt,
     770             :     required this.address,
     771             :     required this.medium,
     772             :     required this.validatedAt,
     773             :   });
     774             : 
     775           0 :   ThirdPartyIdentifier.fromJson(Map<String, Object?> json)
     776           0 :       : addedAt = json['added_at'] as int,
     777           0 :         address = json['address'] as String,
     778             :         medium = ThirdPartyIdentifierMedium.values
     779           0 :             .fromString(json['medium'] as String)!,
     780           0 :         validatedAt = json['validated_at'] as int;
     781           0 :   Map<String, Object?> toJson() => {
     782           0 :         'added_at': addedAt,
     783           0 :         'address': address,
     784           0 :         'medium': medium.name,
     785           0 :         'validated_at': validatedAt,
     786             :       };
     787             : 
     788             :   /// The timestamp, in milliseconds, when the homeserver associated the third-party identifier with the user.
     789             :   int addedAt;
     790             : 
     791             :   /// The third-party identifier address.
     792             :   String address;
     793             : 
     794             :   /// The medium of the third-party identifier.
     795             :   ThirdPartyIdentifierMedium medium;
     796             : 
     797             :   /// The timestamp, in milliseconds, when the identifier was
     798             :   /// validated by the identity server.
     799             :   int validatedAt;
     800             : }
     801             : 
     802             : ///
     803             : @_NameSource('spec')
     804             : class ThreePidCredentials {
     805           0 :   ThreePidCredentials({
     806             :     required this.clientSecret,
     807             :     required this.idAccessToken,
     808             :     required this.idServer,
     809             :     required this.sid,
     810             :   });
     811             : 
     812           0 :   ThreePidCredentials.fromJson(Map<String, Object?> json)
     813           0 :       : clientSecret = json['client_secret'] as String,
     814           0 :         idAccessToken = json['id_access_token'] as String,
     815           0 :         idServer = json['id_server'] as String,
     816           0 :         sid = json['sid'] as String;
     817           0 :   Map<String, Object?> toJson() => {
     818           0 :         'client_secret': clientSecret,
     819           0 :         'id_access_token': idAccessToken,
     820           0 :         'id_server': idServer,
     821           0 :         'sid': sid,
     822             :       };
     823             : 
     824             :   /// The client secret used in the session with the identity server.
     825             :   String clientSecret;
     826             : 
     827             :   /// An access token previously registered with the identity server. Servers
     828             :   /// can treat this as optional to distinguish between r0.5-compatible clients
     829             :   /// and this specification version.
     830             :   String idAccessToken;
     831             : 
     832             :   /// The identity server to use.
     833             :   String idServer;
     834             : 
     835             :   /// The session identifier given by the identity server.
     836             :   String sid;
     837             : }
     838             : 
     839             : ///
     840             : @_NameSource('generated')
     841             : @EnhancedEnum()
     842             : enum IdServerUnbindResult {
     843             :   @EnhancedEnumValue(name: 'no-support')
     844             :   noSupport,
     845             :   @EnhancedEnumValue(name: 'success')
     846             :   success
     847             : }
     848             : 
     849             : ///
     850             : @_NameSource('spec')
     851             : class RequestTokenResponse {
     852           0 :   RequestTokenResponse({
     853             :     required this.sid,
     854             :     this.submitUrl,
     855             :   });
     856             : 
     857           0 :   RequestTokenResponse.fromJson(Map<String, Object?> json)
     858           0 :       : sid = json['sid'] as String,
     859           0 :         submitUrl = ((v) =>
     860           0 :             v != null ? Uri.parse(v as String) : null)(json['submit_url']);
     861           0 :   Map<String, Object?> toJson() {
     862           0 :     final submitUrl = this.submitUrl;
     863           0 :     return {
     864           0 :       'sid': sid,
     865           0 :       if (submitUrl != null) 'submit_url': submitUrl.toString(),
     866             :     };
     867             :   }
     868             : 
     869             :   /// The session ID. Session IDs are opaque strings that must consist entirely
     870             :   /// of the characters `[0-9a-zA-Z.=_-]`. Their length must not exceed 255
     871             :   /// characters and they must not be empty.
     872             :   String sid;
     873             : 
     874             :   /// An optional field containing a URL where the client must submit the
     875             :   /// validation token to, with identical parameters to the Identity Service
     876             :   /// API's `POST /validate/email/submitToken` endpoint (without the requirement
     877             :   /// for an access token). The homeserver must send this token to the user (if
     878             :   /// applicable), who should then be prompted to provide it to the client.
     879             :   ///
     880             :   /// If this field is not present, the client can assume that verification
     881             :   /// will happen without the client's involvement provided the homeserver
     882             :   /// advertises this specification version in the `/versions` response
     883             :   /// (ie: r0.5.0).
     884             :   Uri? submitUrl;
     885             : }
     886             : 
     887             : ///
     888             : @_NameSource('rule override generated')
     889             : class TokenOwnerInfo {
     890           0 :   TokenOwnerInfo({
     891             :     this.deviceId,
     892             :     this.isGuest,
     893             :     required this.userId,
     894             :   });
     895             : 
     896           0 :   TokenOwnerInfo.fromJson(Map<String, Object?> json)
     897           0 :       : deviceId = ((v) => v != null ? v as String : null)(json['device_id']),
     898           0 :         isGuest = ((v) => v != null ? v as bool : null)(json['is_guest']),
     899           0 :         userId = json['user_id'] as String;
     900           0 :   Map<String, Object?> toJson() {
     901           0 :     final deviceId = this.deviceId;
     902           0 :     final isGuest = this.isGuest;
     903           0 :     return {
     904           0 :       if (deviceId != null) 'device_id': deviceId,
     905           0 :       if (isGuest != null) 'is_guest': isGuest,
     906           0 :       'user_id': userId,
     907             :     };
     908             :   }
     909             : 
     910             :   /// Device ID associated with the access token. If no device
     911             :   /// is associated with the access token (such as in the case
     912             :   /// of application services) then this field can be omitted.
     913             :   /// Otherwise this is required.
     914             :   String? deviceId;
     915             : 
     916             :   /// When `true`, the user is a [Guest User](#guest-access). When
     917             :   /// not present or `false`, the user is presumed to be a non-guest
     918             :   /// user.
     919             :   bool? isGuest;
     920             : 
     921             :   /// The user ID that owns the access token.
     922             :   String userId;
     923             : }
     924             : 
     925             : ///
     926             : @_NameSource('spec')
     927             : class ConnectionInfo {
     928           0 :   ConnectionInfo({
     929             :     this.ip,
     930             :     this.lastSeen,
     931             :     this.userAgent,
     932             :   });
     933             : 
     934           0 :   ConnectionInfo.fromJson(Map<String, Object?> json)
     935           0 :       : ip = ((v) => v != null ? v as String : null)(json['ip']),
     936           0 :         lastSeen = ((v) => v != null ? v as int : null)(json['last_seen']),
     937           0 :         userAgent = ((v) => v != null ? v as String : null)(json['user_agent']);
     938           0 :   Map<String, Object?> toJson() {
     939           0 :     final ip = this.ip;
     940           0 :     final lastSeen = this.lastSeen;
     941           0 :     final userAgent = this.userAgent;
     942           0 :     return {
     943           0 :       if (ip != null) 'ip': ip,
     944           0 :       if (lastSeen != null) 'last_seen': lastSeen,
     945           0 :       if (userAgent != null) 'user_agent': userAgent,
     946             :     };
     947             :   }
     948             : 
     949             :   /// Most recently seen IP address of the session.
     950             :   String? ip;
     951             : 
     952             :   /// Unix timestamp that the session was last active.
     953             :   int? lastSeen;
     954             : 
     955             :   /// User agent string last seen in the session.
     956             :   String? userAgent;
     957             : }
     958             : 
     959             : ///
     960             : @_NameSource('spec')
     961             : class SessionInfo {
     962           0 :   SessionInfo({
     963             :     this.connections,
     964             :   });
     965             : 
     966           0 :   SessionInfo.fromJson(Map<String, Object?> json)
     967           0 :       : connections = ((v) => v != null
     968             :             ? (v as List)
     969           0 :                 .map((v) => ConnectionInfo.fromJson(v as Map<String, Object?>))
     970           0 :                 .toList()
     971           0 :             : null)(json['connections']);
     972           0 :   Map<String, Object?> toJson() {
     973           0 :     final connections = this.connections;
     974           0 :     return {
     975             :       if (connections != null)
     976           0 :         'connections': connections.map((v) => v.toJson()).toList(),
     977             :     };
     978             :   }
     979             : 
     980             :   /// Information particular connections in the session.
     981             :   List<ConnectionInfo>? connections;
     982             : }
     983             : 
     984             : ///
     985             : @_NameSource('spec')
     986             : class DeviceInfo {
     987           0 :   DeviceInfo({
     988             :     this.sessions,
     989             :   });
     990             : 
     991           0 :   DeviceInfo.fromJson(Map<String, Object?> json)
     992           0 :       : sessions = ((v) => v != null
     993             :             ? (v as List)
     994           0 :                 .map((v) => SessionInfo.fromJson(v as Map<String, Object?>))
     995           0 :                 .toList()
     996           0 :             : null)(json['sessions']);
     997           0 :   Map<String, Object?> toJson() {
     998           0 :     final sessions = this.sessions;
     999           0 :     return {
    1000             :       if (sessions != null)
    1001           0 :         'sessions': sessions.map((v) => v.toJson()).toList(),
    1002             :     };
    1003             :   }
    1004             : 
    1005             :   /// A user's sessions (i.e. what they did with an access token from one login).
    1006             :   List<SessionInfo>? sessions;
    1007             : }
    1008             : 
    1009             : ///
    1010             : @_NameSource('rule override generated')
    1011             : class WhoIsInfo {
    1012           0 :   WhoIsInfo({
    1013             :     this.devices,
    1014             :     this.userId,
    1015             :   });
    1016             : 
    1017           0 :   WhoIsInfo.fromJson(Map<String, Object?> json)
    1018           0 :       : devices = ((v) => v != null
    1019           0 :             ? (v as Map<String, Object?>).map((k, v) =>
    1020           0 :                 MapEntry(k, DeviceInfo.fromJson(v as Map<String, Object?>)))
    1021           0 :             : null)(json['devices']),
    1022           0 :         userId = ((v) => v != null ? v as String : null)(json['user_id']);
    1023           0 :   Map<String, Object?> toJson() {
    1024           0 :     final devices = this.devices;
    1025           0 :     final userId = this.userId;
    1026           0 :     return {
    1027             :       if (devices != null)
    1028           0 :         'devices': devices.map((k, v) => MapEntry(k, v.toJson())),
    1029           0 :       if (userId != null) 'user_id': userId,
    1030             :     };
    1031             :   }
    1032             : 
    1033             :   /// Each key is an identifier for one of the user's devices.
    1034             :   Map<String, DeviceInfo>? devices;
    1035             : 
    1036             :   /// The Matrix user ID of the user.
    1037             :   String? userId;
    1038             : }
    1039             : 
    1040             : ///
    1041             : @_NameSource('spec')
    1042             : class ChangePasswordCapability {
    1043           0 :   ChangePasswordCapability({
    1044             :     required this.enabled,
    1045             :   });
    1046             : 
    1047           0 :   ChangePasswordCapability.fromJson(Map<String, Object?> json)
    1048           0 :       : enabled = json['enabled'] as bool;
    1049           0 :   Map<String, Object?> toJson() => {
    1050           0 :         'enabled': enabled,
    1051             :       };
    1052             : 
    1053             :   /// True if the user can change their password, false otherwise.
    1054             :   bool enabled;
    1055             : }
    1056             : 
    1057             : /// The stability of the room version.
    1058             : @_NameSource('rule override generated')
    1059             : @EnhancedEnum()
    1060             : enum RoomVersionAvailable {
    1061             :   @EnhancedEnumValue(name: 'stable')
    1062             :   stable,
    1063             :   @EnhancedEnumValue(name: 'unstable')
    1064             :   unstable
    1065             : }
    1066             : 
    1067             : ///
    1068             : @_NameSource('spec')
    1069             : class RoomVersionsCapability {
    1070           0 :   RoomVersionsCapability({
    1071             :     required this.available,
    1072             :     required this.default$,
    1073             :   });
    1074             : 
    1075           0 :   RoomVersionsCapability.fromJson(Map<String, Object?> json)
    1076           0 :       : available = (json['available'] as Map<String, Object?>).map((k, v) =>
    1077           0 :             MapEntry(k, RoomVersionAvailable.values.fromString(v as String)!)),
    1078           0 :         default$ = json['default'] as String;
    1079           0 :   Map<String, Object?> toJson() => {
    1080           0 :         'available': available.map((k, v) => MapEntry(k, v.name)),
    1081           0 :         'default': default$,
    1082             :       };
    1083             : 
    1084             :   /// A detailed description of the room versions the server supports.
    1085             :   Map<String, RoomVersionAvailable> available;
    1086             : 
    1087             :   /// The default room version the server is using for new rooms.
    1088             :   String default$;
    1089             : }
    1090             : 
    1091             : ///
    1092             : @_NameSource('spec')
    1093             : class Capabilities {
    1094           0 :   Capabilities({
    1095             :     this.mChangePassword,
    1096             :     this.mRoomVersions,
    1097             :     this.additionalProperties = const {},
    1098             :   });
    1099             : 
    1100           0 :   Capabilities.fromJson(Map<String, Object?> json)
    1101           0 :       : mChangePassword = ((v) => v != null
    1102           0 :             ? ChangePasswordCapability.fromJson(v as Map<String, Object?>)
    1103           0 :             : null)(json['m.change_password']),
    1104           0 :         mRoomVersions = ((v) => v != null
    1105           0 :             ? RoomVersionsCapability.fromJson(v as Map<String, Object?>)
    1106           0 :             : null)(json['m.room_versions']),
    1107           0 :         additionalProperties = Map.fromEntries(json.entries
    1108           0 :             .where((e) =>
    1109           0 :                 !['m.change_password', 'm.room_versions'].contains(e.key))
    1110           0 :             .map((e) => MapEntry(e.key, e.value as Map<String, Object?>)));
    1111           0 :   Map<String, Object?> toJson() {
    1112           0 :     final mChangePassword = this.mChangePassword;
    1113           0 :     final mRoomVersions = this.mRoomVersions;
    1114           0 :     return {
    1115           0 :       ...additionalProperties,
    1116             :       if (mChangePassword != null)
    1117           0 :         'm.change_password': mChangePassword.toJson(),
    1118           0 :       if (mRoomVersions != null) 'm.room_versions': mRoomVersions.toJson(),
    1119             :     };
    1120             :   }
    1121             : 
    1122             :   /// Capability to indicate if the user can change their password.
    1123             :   ChangePasswordCapability? mChangePassword;
    1124             : 
    1125             :   /// The room versions the server supports.
    1126             :   RoomVersionsCapability? mRoomVersions;
    1127             : 
    1128             :   Map<String, Map<String, Object?>> additionalProperties;
    1129             : }
    1130             : 
    1131             : ///
    1132             : @_NameSource('spec')
    1133             : class StateEvent {
    1134           2 :   StateEvent({
    1135             :     required this.content,
    1136             :     this.stateKey,
    1137             :     required this.type,
    1138             :   });
    1139             : 
    1140           0 :   StateEvent.fromJson(Map<String, Object?> json)
    1141           0 :       : content = json['content'] as Map<String, Object?>,
    1142           0 :         stateKey = ((v) => v != null ? v as String : null)(json['state_key']),
    1143           0 :         type = json['type'] as String;
    1144           2 :   Map<String, Object?> toJson() {
    1145           2 :     final stateKey = this.stateKey;
    1146           2 :     return {
    1147           4 :       'content': content,
    1148           0 :       if (stateKey != null) 'state_key': stateKey,
    1149           4 :       'type': type,
    1150             :     };
    1151             :   }
    1152             : 
    1153             :   /// The content of the event.
    1154             :   Map<String, Object?> content;
    1155             : 
    1156             :   /// The state_key of the state event. Defaults to an empty string.
    1157             :   String? stateKey;
    1158             : 
    1159             :   /// The type of event to send.
    1160             :   String type;
    1161             : }
    1162             : 
    1163             : ///
    1164             : @_NameSource('spec')
    1165             : class Invite3pid {
    1166           0 :   Invite3pid({
    1167             :     required this.address,
    1168             :     required this.idAccessToken,
    1169             :     required this.idServer,
    1170             :     required this.medium,
    1171             :   });
    1172             : 
    1173           0 :   Invite3pid.fromJson(Map<String, Object?> json)
    1174           0 :       : address = json['address'] as String,
    1175           0 :         idAccessToken = json['id_access_token'] as String,
    1176           0 :         idServer = json['id_server'] as String,
    1177           0 :         medium = json['medium'] as String;
    1178           0 :   Map<String, Object?> toJson() => {
    1179           0 :         'address': address,
    1180           0 :         'id_access_token': idAccessToken,
    1181           0 :         'id_server': idServer,
    1182           0 :         'medium': medium,
    1183             :       };
    1184             : 
    1185             :   /// The invitee's third-party identifier.
    1186             :   String address;
    1187             : 
    1188             :   /// An access token previously registered with the identity server. Servers
    1189             :   /// can treat this as optional to distinguish between r0.5-compatible clients
    1190             :   /// and this specification version.
    1191             :   String idAccessToken;
    1192             : 
    1193             :   /// The hostname+port of the identity server which should be used for third-party identifier lookups.
    1194             :   String idServer;
    1195             : 
    1196             :   /// The kind of address being passed in the address field, for example `email`
    1197             :   /// (see [the list of recognised values](https://spec.matrix.org/unstable/appendices/#3pid-types)).
    1198             :   String medium;
    1199             : }
    1200             : 
    1201             : ///
    1202             : @_NameSource('rule override generated')
    1203             : @EnhancedEnum()
    1204             : enum CreateRoomPreset {
    1205             :   @EnhancedEnumValue(name: 'private_chat')
    1206             :   privateChat,
    1207             :   @EnhancedEnumValue(name: 'public_chat')
    1208             :   publicChat,
    1209             :   @EnhancedEnumValue(name: 'trusted_private_chat')
    1210             :   trustedPrivateChat
    1211             : }
    1212             : 
    1213             : ///
    1214             : @_NameSource('generated')
    1215             : @EnhancedEnum()
    1216             : enum Visibility {
    1217             :   @EnhancedEnumValue(name: 'private')
    1218             :   private,
    1219             :   @EnhancedEnumValue(name: 'public')
    1220             :   public
    1221             : }
    1222             : 
    1223             : /// A client device
    1224             : @_NameSource('spec')
    1225             : class Device {
    1226           0 :   Device({
    1227             :     required this.deviceId,
    1228             :     this.displayName,
    1229             :     this.lastSeenIp,
    1230             :     this.lastSeenTs,
    1231             :   });
    1232             : 
    1233           0 :   Device.fromJson(Map<String, Object?> json)
    1234           0 :       : deviceId = json['device_id'] as String,
    1235             :         displayName =
    1236           0 :             ((v) => v != null ? v as String : null)(json['display_name']),
    1237             :         lastSeenIp =
    1238           0 :             ((v) => v != null ? v as String : null)(json['last_seen_ip']),
    1239           0 :         lastSeenTs = ((v) => v != null ? v as int : null)(json['last_seen_ts']);
    1240           0 :   Map<String, Object?> toJson() {
    1241           0 :     final displayName = this.displayName;
    1242           0 :     final lastSeenIp = this.lastSeenIp;
    1243           0 :     final lastSeenTs = this.lastSeenTs;
    1244           0 :     return {
    1245           0 :       'device_id': deviceId,
    1246           0 :       if (displayName != null) 'display_name': displayName,
    1247           0 :       if (lastSeenIp != null) 'last_seen_ip': lastSeenIp,
    1248           0 :       if (lastSeenTs != null) 'last_seen_ts': lastSeenTs,
    1249             :     };
    1250             :   }
    1251             : 
    1252             :   /// Identifier of this device.
    1253             :   String deviceId;
    1254             : 
    1255             :   /// Display name set by the user for this device. Absent if no name has been
    1256             :   /// set.
    1257             :   String? displayName;
    1258             : 
    1259             :   /// The IP address where this device was last seen. (May be a few minutes out
    1260             :   /// of date, for efficiency reasons).
    1261             :   String? lastSeenIp;
    1262             : 
    1263             :   /// The timestamp (in milliseconds since the unix epoch) when this devices
    1264             :   /// was last seen. (May be a few minutes out of date, for efficiency
    1265             :   /// reasons).
    1266             :   int? lastSeenTs;
    1267             : }
    1268             : 
    1269             : ///
    1270             : @_NameSource('generated')
    1271             : class GetRoomIdByAliasResponse {
    1272           0 :   GetRoomIdByAliasResponse({
    1273             :     this.roomId,
    1274             :     this.servers,
    1275             :   });
    1276             : 
    1277           0 :   GetRoomIdByAliasResponse.fromJson(Map<String, Object?> json)
    1278           0 :       : roomId = ((v) => v != null ? v as String : null)(json['room_id']),
    1279           0 :         servers = ((v) => v != null
    1280           0 :             ? (v as List).map((v) => v as String).toList()
    1281           0 :             : null)(json['servers']);
    1282           0 :   Map<String, Object?> toJson() {
    1283           0 :     final roomId = this.roomId;
    1284           0 :     final servers = this.servers;
    1285           0 :     return {
    1286           0 :       if (roomId != null) 'room_id': roomId,
    1287           0 :       if (servers != null) 'servers': servers.map((v) => v).toList(),
    1288             :     };
    1289             :   }
    1290             : 
    1291             :   /// The room ID for this room alias.
    1292             :   String? roomId;
    1293             : 
    1294             :   /// A list of servers that are aware of this room alias.
    1295             :   List<String>? servers;
    1296             : }
    1297             : 
    1298             : ///
    1299             : @_NameSource('generated')
    1300             : class GetEventsResponse {
    1301           0 :   GetEventsResponse({
    1302             :     this.chunk,
    1303             :     this.end,
    1304             :     this.start,
    1305             :   });
    1306             : 
    1307           0 :   GetEventsResponse.fromJson(Map<String, Object?> json)
    1308           0 :       : chunk = ((v) => v != null
    1309             :             ? (v as List)
    1310           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    1311           0 :                 .toList()
    1312           0 :             : null)(json['chunk']),
    1313           0 :         end = ((v) => v != null ? v as String : null)(json['end']),
    1314           0 :         start = ((v) => v != null ? v as String : null)(json['start']);
    1315           0 :   Map<String, Object?> toJson() {
    1316           0 :     final chunk = this.chunk;
    1317           0 :     final end = this.end;
    1318           0 :     final start = this.start;
    1319           0 :     return {
    1320           0 :       if (chunk != null) 'chunk': chunk.map((v) => v.toJson()).toList(),
    1321           0 :       if (end != null) 'end': end,
    1322           0 :       if (start != null) 'start': start,
    1323             :     };
    1324             :   }
    1325             : 
    1326             :   /// An array of events.
    1327             :   List<MatrixEvent>? chunk;
    1328             : 
    1329             :   /// A token which correlates to the end of `chunk`. This
    1330             :   /// token should be used in the next request to `/events`.
    1331             :   String? end;
    1332             : 
    1333             :   /// A token which correlates to the start of `chunk`. This
    1334             :   /// is usually the same token supplied to `from=`.
    1335             :   String? start;
    1336             : }
    1337             : 
    1338             : ///
    1339             : @_NameSource('generated')
    1340             : class PeekEventsResponse {
    1341           0 :   PeekEventsResponse({
    1342             :     this.chunk,
    1343             :     this.end,
    1344             :     this.start,
    1345             :   });
    1346             : 
    1347           0 :   PeekEventsResponse.fromJson(Map<String, Object?> json)
    1348           0 :       : chunk = ((v) => v != null
    1349             :             ? (v as List)
    1350           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    1351           0 :                 .toList()
    1352           0 :             : null)(json['chunk']),
    1353           0 :         end = ((v) => v != null ? v as String : null)(json['end']),
    1354           0 :         start = ((v) => v != null ? v as String : null)(json['start']);
    1355           0 :   Map<String, Object?> toJson() {
    1356           0 :     final chunk = this.chunk;
    1357           0 :     final end = this.end;
    1358           0 :     final start = this.start;
    1359           0 :     return {
    1360           0 :       if (chunk != null) 'chunk': chunk.map((v) => v.toJson()).toList(),
    1361           0 :       if (end != null) 'end': end,
    1362           0 :       if (start != null) 'start': start,
    1363             :     };
    1364             :   }
    1365             : 
    1366             :   /// An array of events.
    1367             :   List<MatrixEvent>? chunk;
    1368             : 
    1369             :   /// A token which correlates to the last value in `chunk`. This
    1370             :   /// token should be used in the next request to `/events`.
    1371             :   String? end;
    1372             : 
    1373             :   /// A token which correlates to the first value in `chunk`. This
    1374             :   /// is usually the same token supplied to `from=`.
    1375             :   String? start;
    1376             : }
    1377             : 
    1378             : /// A signature of an `m.third_party_invite` token to prove that this user
    1379             : /// owns a third-party identity which has been invited to the room.
    1380             : @_NameSource('spec')
    1381             : class ThirdPartySigned {
    1382           0 :   ThirdPartySigned({
    1383             :     required this.mxid,
    1384             :     required this.sender,
    1385             :     required this.signatures,
    1386             :     required this.token,
    1387             :   });
    1388             : 
    1389           0 :   ThirdPartySigned.fromJson(Map<String, Object?> json)
    1390           0 :       : mxid = json['mxid'] as String,
    1391           0 :         sender = json['sender'] as String,
    1392           0 :         signatures = (json['signatures'] as Map<String, Object?>).map((k, v) =>
    1393           0 :             MapEntry(
    1394             :                 k,
    1395             :                 (v as Map<String, Object?>)
    1396           0 :                     .map((k, v) => MapEntry(k, v as String)))),
    1397           0 :         token = json['token'] as String;
    1398           0 :   Map<String, Object?> toJson() => {
    1399           0 :         'mxid': mxid,
    1400           0 :         'sender': sender,
    1401           0 :         'signatures': signatures
    1402           0 :             .map((k, v) => MapEntry(k, v.map((k, v) => MapEntry(k, v)))),
    1403           0 :         'token': token,
    1404             :       };
    1405             : 
    1406             :   /// The Matrix ID of the invitee.
    1407             :   String mxid;
    1408             : 
    1409             :   /// The Matrix ID of the user who issued the invite.
    1410             :   String sender;
    1411             : 
    1412             :   /// A signatures object containing a signature of the entire signed object.
    1413             :   Map<String, Map<String, String>> signatures;
    1414             : 
    1415             :   /// The state key of the m.third_party_invite event.
    1416             :   String token;
    1417             : }
    1418             : 
    1419             : ///
    1420             : @_NameSource('generated')
    1421             : class GetKeysChangesResponse {
    1422           0 :   GetKeysChangesResponse({
    1423             :     this.changed,
    1424             :     this.left,
    1425             :   });
    1426             : 
    1427           0 :   GetKeysChangesResponse.fromJson(Map<String, Object?> json)
    1428           0 :       : changed = ((v) => v != null
    1429           0 :             ? (v as List).map((v) => v as String).toList()
    1430           0 :             : null)(json['changed']),
    1431           0 :         left = ((v) => v != null
    1432           0 :             ? (v as List).map((v) => v as String).toList()
    1433           0 :             : null)(json['left']);
    1434           0 :   Map<String, Object?> toJson() {
    1435           0 :     final changed = this.changed;
    1436           0 :     final left = this.left;
    1437           0 :     return {
    1438           0 :       if (changed != null) 'changed': changed.map((v) => v).toList(),
    1439           0 :       if (left != null) 'left': left.map((v) => v).toList(),
    1440             :     };
    1441             :   }
    1442             : 
    1443             :   /// The Matrix User IDs of all users who updated their device
    1444             :   /// identity keys.
    1445             :   List<String>? changed;
    1446             : 
    1447             :   /// The Matrix User IDs of all users who may have left all
    1448             :   /// the end-to-end encrypted rooms they previously shared
    1449             :   /// with the user.
    1450             :   List<String>? left;
    1451             : }
    1452             : 
    1453             : ///
    1454             : @_NameSource('generated')
    1455             : class ClaimKeysResponse {
    1456           0 :   ClaimKeysResponse({
    1457             :     this.failures,
    1458             :     required this.oneTimeKeys,
    1459             :   });
    1460             : 
    1461          10 :   ClaimKeysResponse.fromJson(Map<String, Object?> json)
    1462          10 :       : failures = ((v) => v != null
    1463             :             ? (v as Map<String, Object?>)
    1464          10 :                 .map((k, v) => MapEntry(k, v as Map<String, Object?>))
    1465          20 :             : null)(json['failures']),
    1466          20 :         oneTimeKeys = (json['one_time_keys'] as Map<String, Object?>).map(
    1467          20 :             (k, v) => MapEntry(
    1468             :                 k,
    1469             :                 (v as Map<String, Object?>)
    1470          30 :                     .map((k, v) => MapEntry(k, v as Map<String, Object?>))));
    1471           0 :   Map<String, Object?> toJson() {
    1472           0 :     final failures = this.failures;
    1473           0 :     return {
    1474           0 :       if (failures != null) 'failures': failures.map((k, v) => MapEntry(k, v)),
    1475           0 :       'one_time_keys': oneTimeKeys
    1476           0 :           .map((k, v) => MapEntry(k, v.map((k, v) => MapEntry(k, v)))),
    1477             :     };
    1478             :   }
    1479             : 
    1480             :   /// If any remote homeservers could not be reached, they are
    1481             :   /// recorded here. The names of the properties are the names of
    1482             :   /// the unreachable servers.
    1483             :   ///
    1484             :   /// If the homeserver could be reached, but the user or device
    1485             :   /// was unknown, no failure is recorded. Instead, the corresponding
    1486             :   /// user or device is missing from the `one_time_keys` result.
    1487             :   Map<String, Map<String, Object?>>? failures;
    1488             : 
    1489             :   /// One-time keys for the queried devices. A map from user ID, to a
    1490             :   /// map from devices to a map from `<algorithm>:<key_id>` to the key object.
    1491             :   ///
    1492             :   /// See the [key algorithms](https://spec.matrix.org/unstable/client-server-api/#key-algorithms) section for information
    1493             :   /// on the Key Object format.
    1494             :   ///
    1495             :   /// If necessary, the claimed key might be a fallback key. Fallback
    1496             :   /// keys are re-used by the server until replaced by the device.
    1497             :   Map<String, Map<String, Map<String, Object?>>> oneTimeKeys;
    1498             : }
    1499             : 
    1500             : ///
    1501             : @_NameSource('generated')
    1502             : class QueryKeysResponse {
    1503           0 :   QueryKeysResponse({
    1504             :     this.deviceKeys,
    1505             :     this.failures,
    1506             :     this.masterKeys,
    1507             :     this.selfSigningKeys,
    1508             :     this.userSigningKeys,
    1509             :   });
    1510             : 
    1511          31 :   QueryKeysResponse.fromJson(Map<String, Object?> json)
    1512          31 :       : deviceKeys = ((v) => v != null
    1513          93 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    1514             :                 k,
    1515          93 :                 (v as Map<String, Object?>).map((k, v) => MapEntry(
    1516          31 :                     k, MatrixDeviceKeys.fromJson(v as Map<String, Object?>)))))
    1517          62 :             : null)(json['device_keys']),
    1518          31 :         failures = ((v) => v != null
    1519             :             ? (v as Map<String, Object?>)
    1520          31 :                 .map((k, v) => MapEntry(k, v as Map<String, Object?>))
    1521          62 :             : null)(json['failures']),
    1522          31 :         masterKeys = ((v) => v != null
    1523          93 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    1524          31 :                 k, MatrixCrossSigningKey.fromJson(v as Map<String, Object?>)))
    1525          62 :             : null)(json['master_keys']),
    1526          31 :         selfSigningKeys = ((v) => v != null
    1527          93 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    1528          31 :                 k, MatrixCrossSigningKey.fromJson(v as Map<String, Object?>)))
    1529          62 :             : null)(json['self_signing_keys']),
    1530          31 :         userSigningKeys = ((v) => v != null
    1531          93 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    1532          31 :                 k, MatrixCrossSigningKey.fromJson(v as Map<String, Object?>)))
    1533          62 :             : null)(json['user_signing_keys']);
    1534           0 :   Map<String, Object?> toJson() {
    1535           0 :     final deviceKeys = this.deviceKeys;
    1536           0 :     final failures = this.failures;
    1537           0 :     final masterKeys = this.masterKeys;
    1538           0 :     final selfSigningKeys = this.selfSigningKeys;
    1539           0 :     final userSigningKeys = this.userSigningKeys;
    1540           0 :     return {
    1541             :       if (deviceKeys != null)
    1542           0 :         'device_keys': deviceKeys.map(
    1543           0 :             (k, v) => MapEntry(k, v.map((k, v) => MapEntry(k, v.toJson())))),
    1544           0 :       if (failures != null) 'failures': failures.map((k, v) => MapEntry(k, v)),
    1545             :       if (masterKeys != null)
    1546           0 :         'master_keys': masterKeys.map((k, v) => MapEntry(k, v.toJson())),
    1547             :       if (selfSigningKeys != null)
    1548           0 :         'self_signing_keys':
    1549           0 :             selfSigningKeys.map((k, v) => MapEntry(k, v.toJson())),
    1550             :       if (userSigningKeys != null)
    1551           0 :         'user_signing_keys':
    1552           0 :             userSigningKeys.map((k, v) => MapEntry(k, v.toJson())),
    1553             :     };
    1554             :   }
    1555             : 
    1556             :   /// Information on the queried devices. A map from user ID, to a
    1557             :   /// map from device ID to device information.  For each device,
    1558             :   /// the information returned will be the same as uploaded via
    1559             :   /// `/keys/upload`, with the addition of an `unsigned`
    1560             :   /// property.
    1561             :   Map<String, Map<String, MatrixDeviceKeys>>? deviceKeys;
    1562             : 
    1563             :   /// If any remote homeservers could not be reached, they are
    1564             :   /// recorded here. The names of the properties are the names of
    1565             :   /// the unreachable servers.
    1566             :   ///
    1567             :   /// If the homeserver could be reached, but the user or device
    1568             :   /// was unknown, no failure is recorded. Instead, the corresponding
    1569             :   /// user or device is missing from the `device_keys` result.
    1570             :   Map<String, Map<String, Object?>>? failures;
    1571             : 
    1572             :   /// Information on the master cross-signing keys of the queried users.
    1573             :   /// A map from user ID, to master key information.  For each key, the
    1574             :   /// information returned will be the same as uploaded via
    1575             :   /// `/keys/device_signing/upload`, along with the signatures
    1576             :   /// uploaded via `/keys/signatures/upload` that the requesting user
    1577             :   /// is allowed to see.
    1578             :   Map<String, MatrixCrossSigningKey>? masterKeys;
    1579             : 
    1580             :   /// Information on the self-signing keys of the queried users. A map
    1581             :   /// from user ID, to self-signing key information.  For each key, the
    1582             :   /// information returned will be the same as uploaded via
    1583             :   /// `/keys/device_signing/upload`.
    1584             :   Map<String, MatrixCrossSigningKey>? selfSigningKeys;
    1585             : 
    1586             :   /// Information on the user-signing key of the user making the
    1587             :   /// request, if they queried their own device information. A map
    1588             :   /// from user ID, to user-signing key information.  The
    1589             :   /// information returned will be the same as uploaded via
    1590             :   /// `/keys/device_signing/upload`.
    1591             :   Map<String, MatrixCrossSigningKey>? userSigningKeys;
    1592             : }
    1593             : 
    1594             : ///
    1595             : @_NameSource('spec')
    1596             : class LoginFlow {
    1597           0 :   LoginFlow({
    1598             :     this.getLoginToken,
    1599             :     required this.type,
    1600             :   });
    1601             : 
    1602          34 :   LoginFlow.fromJson(Map<String, Object?> json)
    1603             :       : getLoginToken =
    1604         102 :             ((v) => v != null ? v as bool : null)(json['get_login_token']),
    1605          34 :         type = json['type'] as String;
    1606           0 :   Map<String, Object?> toJson() {
    1607           0 :     final getLoginToken = this.getLoginToken;
    1608           0 :     return {
    1609           0 :       if (getLoginToken != null) 'get_login_token': getLoginToken,
    1610           0 :       'type': type,
    1611             :     };
    1612             :   }
    1613             : 
    1614             :   /// If `type` is `m.login.token`, an optional field to indicate
    1615             :   /// to the unauthenticated client that the homeserver supports
    1616             :   /// the [`POST /login/get_token`](https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv1loginget_token)
    1617             :   /// endpoint. Note that supporting the endpoint does not
    1618             :   /// necessarily indicate that the user attempting to log in will
    1619             :   /// be able to generate such a token.
    1620             :   bool? getLoginToken;
    1621             : 
    1622             :   /// The login type. This is supplied as the `type` when
    1623             :   /// logging in.
    1624             :   String type;
    1625             : }
    1626             : 
    1627             : ///
    1628             : @_NameSource('generated')
    1629             : class LoginResponse {
    1630           0 :   LoginResponse({
    1631             :     required this.accessToken,
    1632             :     required this.deviceId,
    1633             :     this.expiresInMs,
    1634             :     this.homeServer,
    1635             :     this.refreshToken,
    1636             :     required this.userId,
    1637             :     this.wellKnown,
    1638             :   });
    1639             : 
    1640           4 :   LoginResponse.fromJson(Map<String, Object?> json)
    1641           4 :       : accessToken = json['access_token'] as String,
    1642           4 :         deviceId = json['device_id'] as String,
    1643             :         expiresInMs =
    1644          12 :             ((v) => v != null ? v as int : null)(json['expires_in_ms']),
    1645             :         homeServer =
    1646          12 :             ((v) => v != null ? v as String : null)(json['home_server']),
    1647             :         refreshToken =
    1648          12 :             ((v) => v != null ? v as String : null)(json['refresh_token']),
    1649           4 :         userId = json['user_id'] as String,
    1650           4 :         wellKnown = ((v) => v != null
    1651           4 :             ? DiscoveryInformation.fromJson(v as Map<String, Object?>)
    1652           8 :             : null)(json['well_known']);
    1653           0 :   Map<String, Object?> toJson() {
    1654           0 :     final expiresInMs = this.expiresInMs;
    1655           0 :     final homeServer = this.homeServer;
    1656           0 :     final refreshToken = this.refreshToken;
    1657           0 :     final wellKnown = this.wellKnown;
    1658           0 :     return {
    1659           0 :       'access_token': accessToken,
    1660           0 :       'device_id': deviceId,
    1661           0 :       if (expiresInMs != null) 'expires_in_ms': expiresInMs,
    1662           0 :       if (homeServer != null) 'home_server': homeServer,
    1663           0 :       if (refreshToken != null) 'refresh_token': refreshToken,
    1664           0 :       'user_id': userId,
    1665           0 :       if (wellKnown != null) 'well_known': wellKnown.toJson(),
    1666             :     };
    1667             :   }
    1668             : 
    1669             :   /// An access token for the account.
    1670             :   /// This access token can then be used to authorize other requests.
    1671             :   String accessToken;
    1672             : 
    1673             :   /// ID of the logged-in device. Will be the same as the
    1674             :   /// corresponding parameter in the request, if one was specified.
    1675             :   String deviceId;
    1676             : 
    1677             :   /// The lifetime of the access token, in milliseconds. Once
    1678             :   /// the access token has expired a new access token can be
    1679             :   /// obtained by using the provided refresh token. If no
    1680             :   /// refresh token is provided, the client will need to re-log in
    1681             :   /// to obtain a new access token. If not given, the client can
    1682             :   /// assume that the access token will not expire.
    1683             :   int? expiresInMs;
    1684             : 
    1685             :   /// The server_name of the homeserver on which the account has
    1686             :   /// been registered.
    1687             :   ///
    1688             :   /// **Deprecated**. Clients should extract the server_name from
    1689             :   /// `user_id` (by splitting at the first colon) if they require
    1690             :   /// it. Note also that `homeserver` is not spelt this way.
    1691             :   String? homeServer;
    1692             : 
    1693             :   /// A refresh token for the account. This token can be used to
    1694             :   /// obtain a new access token when it expires by calling the
    1695             :   /// `/refresh` endpoint.
    1696             :   String? refreshToken;
    1697             : 
    1698             :   /// The fully-qualified Matrix ID for the account.
    1699             :   String userId;
    1700             : 
    1701             :   /// Optional client configuration provided by the server. If present,
    1702             :   /// clients SHOULD use the provided object to reconfigure themselves,
    1703             :   /// optionally validating the URLs within. This object takes the same
    1704             :   /// form as the one returned from .well-known autodiscovery.
    1705             :   DiscoveryInformation? wellKnown;
    1706             : }
    1707             : 
    1708             : ///
    1709             : @_NameSource('spec')
    1710             : class Notification {
    1711           0 :   Notification({
    1712             :     required this.actions,
    1713             :     required this.event,
    1714             :     this.profileTag,
    1715             :     required this.read,
    1716             :     required this.roomId,
    1717             :     required this.ts,
    1718             :   });
    1719             : 
    1720           0 :   Notification.fromJson(Map<String, Object?> json)
    1721           0 :       : actions = (json['actions'] as List).map((v) => v as Object?).toList(),
    1722           0 :         event = MatrixEvent.fromJson(json['event'] as Map<String, Object?>),
    1723             :         profileTag =
    1724           0 :             ((v) => v != null ? v as String : null)(json['profile_tag']),
    1725           0 :         read = json['read'] as bool,
    1726           0 :         roomId = json['room_id'] as String,
    1727           0 :         ts = json['ts'] as int;
    1728           0 :   Map<String, Object?> toJson() {
    1729           0 :     final profileTag = this.profileTag;
    1730           0 :     return {
    1731           0 :       'actions': actions.map((v) => v).toList(),
    1732           0 :       'event': event.toJson(),
    1733           0 :       if (profileTag != null) 'profile_tag': profileTag,
    1734           0 :       'read': read,
    1735           0 :       'room_id': roomId,
    1736           0 :       'ts': ts,
    1737             :     };
    1738             :   }
    1739             : 
    1740             :   /// The action(s) to perform when the conditions for this rule are met.
    1741             :   /// See [Push Rules: API](https://spec.matrix.org/unstable/client-server-api/#push-rules-api).
    1742             :   List<Object?> actions;
    1743             : 
    1744             :   /// The Event object for the event that triggered the notification.
    1745             :   MatrixEvent event;
    1746             : 
    1747             :   /// The profile tag of the rule that matched this event.
    1748             :   String? profileTag;
    1749             : 
    1750             :   /// Indicates whether the user has sent a read receipt indicating
    1751             :   /// that they have read this message.
    1752             :   bool read;
    1753             : 
    1754             :   /// The ID of the room in which the event was posted.
    1755             :   String roomId;
    1756             : 
    1757             :   /// The unix timestamp at which the event notification was sent,
    1758             :   /// in milliseconds.
    1759             :   int ts;
    1760             : }
    1761             : 
    1762             : ///
    1763             : @_NameSource('generated')
    1764             : class GetNotificationsResponse {
    1765           0 :   GetNotificationsResponse({
    1766             :     this.nextToken,
    1767             :     required this.notifications,
    1768             :   });
    1769             : 
    1770           0 :   GetNotificationsResponse.fromJson(Map<String, Object?> json)
    1771           0 :       : nextToken = ((v) => v != null ? v as String : null)(json['next_token']),
    1772           0 :         notifications = (json['notifications'] as List)
    1773           0 :             .map((v) => Notification.fromJson(v as Map<String, Object?>))
    1774           0 :             .toList();
    1775           0 :   Map<String, Object?> toJson() {
    1776           0 :     final nextToken = this.nextToken;
    1777           0 :     return {
    1778           0 :       if (nextToken != null) 'next_token': nextToken,
    1779           0 :       'notifications': notifications.map((v) => v.toJson()).toList(),
    1780             :     };
    1781             :   }
    1782             : 
    1783             :   /// The token to supply in the `from` param of the next
    1784             :   /// `/notifications` request in order to request more
    1785             :   /// events. If this is absent, there are no more results.
    1786             :   String? nextToken;
    1787             : 
    1788             :   /// The list of events that triggered notifications.
    1789             :   List<Notification> notifications;
    1790             : }
    1791             : 
    1792             : ///
    1793             : @_NameSource('rule override generated')
    1794             : @EnhancedEnum()
    1795             : enum PresenceType {
    1796             :   @EnhancedEnumValue(name: 'offline')
    1797             :   offline,
    1798             :   @EnhancedEnumValue(name: 'online')
    1799             :   online,
    1800             :   @EnhancedEnumValue(name: 'unavailable')
    1801             :   unavailable
    1802             : }
    1803             : 
    1804             : ///
    1805             : @_NameSource('generated')
    1806             : class GetPresenceResponse {
    1807           0 :   GetPresenceResponse({
    1808             :     this.currentlyActive,
    1809             :     this.lastActiveAgo,
    1810             :     required this.presence,
    1811             :     this.statusMsg,
    1812             :   });
    1813             : 
    1814           0 :   GetPresenceResponse.fromJson(Map<String, Object?> json)
    1815             :       : currentlyActive =
    1816           0 :             ((v) => v != null ? v as bool : null)(json['currently_active']),
    1817             :         lastActiveAgo =
    1818           0 :             ((v) => v != null ? v as int : null)(json['last_active_ago']),
    1819           0 :         presence = PresenceType.values.fromString(json['presence'] as String)!,
    1820           0 :         statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']);
    1821           0 :   Map<String, Object?> toJson() {
    1822           0 :     final currentlyActive = this.currentlyActive;
    1823           0 :     final lastActiveAgo = this.lastActiveAgo;
    1824           0 :     final statusMsg = this.statusMsg;
    1825           0 :     return {
    1826           0 :       if (currentlyActive != null) 'currently_active': currentlyActive,
    1827           0 :       if (lastActiveAgo != null) 'last_active_ago': lastActiveAgo,
    1828           0 :       'presence': presence.name,
    1829           0 :       if (statusMsg != null) 'status_msg': statusMsg,
    1830             :     };
    1831             :   }
    1832             : 
    1833             :   /// Whether the user is currently active
    1834             :   bool? currentlyActive;
    1835             : 
    1836             :   /// The length of time in milliseconds since an action was performed
    1837             :   /// by this user.
    1838             :   int? lastActiveAgo;
    1839             : 
    1840             :   /// This user's presence.
    1841             :   PresenceType presence;
    1842             : 
    1843             :   /// The state message for this user if one was set.
    1844             :   String? statusMsg;
    1845             : }
    1846             : 
    1847             : ///
    1848             : @_NameSource('rule override generated')
    1849             : class ProfileInformation {
    1850           4 :   ProfileInformation({
    1851             :     this.avatarUrl,
    1852             :     this.displayname,
    1853             :   });
    1854             : 
    1855           4 :   ProfileInformation.fromJson(Map<String, Object?> json)
    1856           4 :       : avatarUrl = ((v) =>
    1857          12 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
    1858             :         displayname =
    1859          12 :             ((v) => v != null ? v as String : null)(json['displayname']);
    1860           4 :   Map<String, Object?> toJson() {
    1861           4 :     final avatarUrl = this.avatarUrl;
    1862           4 :     final displayname = this.displayname;
    1863           4 :     return {
    1864           8 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
    1865           4 :       if (displayname != null) 'displayname': displayname,
    1866             :     };
    1867             :   }
    1868             : 
    1869             :   /// The user's avatar URL if they have set one, otherwise not present.
    1870             :   Uri? avatarUrl;
    1871             : 
    1872             :   /// The user's display name if they have set one, otherwise not present.
    1873             :   String? displayname;
    1874             : }
    1875             : 
    1876             : /// A list of the rooms on the server.
    1877             : @_NameSource('generated')
    1878             : class GetPublicRoomsResponse {
    1879           0 :   GetPublicRoomsResponse({
    1880             :     required this.chunk,
    1881             :     this.nextBatch,
    1882             :     this.prevBatch,
    1883             :     this.totalRoomCountEstimate,
    1884             :   });
    1885             : 
    1886           0 :   GetPublicRoomsResponse.fromJson(Map<String, Object?> json)
    1887           0 :       : chunk = (json['chunk'] as List)
    1888           0 :             .map((v) => PublicRoomsChunk.fromJson(v as Map<String, Object?>))
    1889           0 :             .toList(),
    1890           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
    1891           0 :         prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']),
    1892           0 :         totalRoomCountEstimate = ((v) =>
    1893           0 :             v != null ? v as int : null)(json['total_room_count_estimate']);
    1894           0 :   Map<String, Object?> toJson() {
    1895           0 :     final nextBatch = this.nextBatch;
    1896           0 :     final prevBatch = this.prevBatch;
    1897           0 :     final totalRoomCountEstimate = this.totalRoomCountEstimate;
    1898           0 :     return {
    1899           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
    1900           0 :       if (nextBatch != null) 'next_batch': nextBatch,
    1901           0 :       if (prevBatch != null) 'prev_batch': prevBatch,
    1902             :       if (totalRoomCountEstimate != null)
    1903           0 :         'total_room_count_estimate': totalRoomCountEstimate,
    1904             :     };
    1905             :   }
    1906             : 
    1907             :   /// A paginated chunk of public rooms.
    1908             :   List<PublicRoomsChunk> chunk;
    1909             : 
    1910             :   /// A pagination token for the response. The absence of this token
    1911             :   /// means there are no more results to fetch and the client should
    1912             :   /// stop paginating.
    1913             :   String? nextBatch;
    1914             : 
    1915             :   /// A pagination token that allows fetching previous results. The
    1916             :   /// absence of this token means there are no results before this
    1917             :   /// batch, i.e. this is the first batch.
    1918             :   String? prevBatch;
    1919             : 
    1920             :   /// An estimate on the total number of public rooms, if the
    1921             :   /// server has an estimate.
    1922             :   int? totalRoomCountEstimate;
    1923             : }
    1924             : 
    1925             : ///
    1926             : @_NameSource('rule override spec')
    1927             : class PublicRoomQueryFilter {
    1928           0 :   PublicRoomQueryFilter({
    1929             :     this.genericSearchTerm,
    1930             :     this.roomTypes,
    1931             :   });
    1932             : 
    1933           0 :   PublicRoomQueryFilter.fromJson(Map<String, Object?> json)
    1934           0 :       : genericSearchTerm = ((v) =>
    1935           0 :             v != null ? v as String : null)(json['generic_search_term']),
    1936           0 :         roomTypes = ((v) => v != null
    1937             :             ? (v as List)
    1938           0 :                 .map((v) => ((v) => v != null ? v as String : null)(v))
    1939           0 :                 .toList()
    1940           0 :             : null)(json['room_types']);
    1941           0 :   Map<String, Object?> toJson() {
    1942           0 :     final genericSearchTerm = this.genericSearchTerm;
    1943           0 :     final roomTypes = this.roomTypes;
    1944           0 :     return {
    1945           0 :       if (genericSearchTerm != null) 'generic_search_term': genericSearchTerm,
    1946           0 :       if (roomTypes != null) 'room_types': roomTypes.map((v) => v).toList(),
    1947             :     };
    1948             :   }
    1949             : 
    1950             :   /// An optional string to search for in the room metadata, e.g. name,
    1951             :   /// topic, canonical alias, etc.
    1952             :   String? genericSearchTerm;
    1953             : 
    1954             :   /// An optional list of [room types](https://spec.matrix.org/unstable/client-server-api/#types) to search
    1955             :   /// for. To include rooms without a room type, specify `null` within this
    1956             :   /// list. When not specified, all applicable rooms (regardless of type)
    1957             :   /// are returned.
    1958             :   List<String?>? roomTypes;
    1959             : }
    1960             : 
    1961             : /// A list of the rooms on the server.
    1962             : @_NameSource('generated')
    1963             : class QueryPublicRoomsResponse {
    1964           0 :   QueryPublicRoomsResponse({
    1965             :     required this.chunk,
    1966             :     this.nextBatch,
    1967             :     this.prevBatch,
    1968             :     this.totalRoomCountEstimate,
    1969             :   });
    1970             : 
    1971           0 :   QueryPublicRoomsResponse.fromJson(Map<String, Object?> json)
    1972           0 :       : chunk = (json['chunk'] as List)
    1973           0 :             .map((v) => PublicRoomsChunk.fromJson(v as Map<String, Object?>))
    1974           0 :             .toList(),
    1975           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
    1976           0 :         prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']),
    1977           0 :         totalRoomCountEstimate = ((v) =>
    1978           0 :             v != null ? v as int : null)(json['total_room_count_estimate']);
    1979           0 :   Map<String, Object?> toJson() {
    1980           0 :     final nextBatch = this.nextBatch;
    1981           0 :     final prevBatch = this.prevBatch;
    1982           0 :     final totalRoomCountEstimate = this.totalRoomCountEstimate;
    1983           0 :     return {
    1984           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
    1985           0 :       if (nextBatch != null) 'next_batch': nextBatch,
    1986           0 :       if (prevBatch != null) 'prev_batch': prevBatch,
    1987             :       if (totalRoomCountEstimate != null)
    1988           0 :         'total_room_count_estimate': totalRoomCountEstimate,
    1989             :     };
    1990             :   }
    1991             : 
    1992             :   /// A paginated chunk of public rooms.
    1993             :   List<PublicRoomsChunk> chunk;
    1994             : 
    1995             :   /// A pagination token for the response. The absence of this token
    1996             :   /// means there are no more results to fetch and the client should
    1997             :   /// stop paginating.
    1998             :   String? nextBatch;
    1999             : 
    2000             :   /// A pagination token that allows fetching previous results. The
    2001             :   /// absence of this token means there are no results before this
    2002             :   /// batch, i.e. this is the first batch.
    2003             :   String? prevBatch;
    2004             : 
    2005             :   /// An estimate on the total number of public rooms, if the
    2006             :   /// server has an estimate.
    2007             :   int? totalRoomCountEstimate;
    2008             : }
    2009             : 
    2010             : ///
    2011             : @_NameSource('spec')
    2012             : class PusherData {
    2013           0 :   PusherData({
    2014             :     this.format,
    2015             :     this.url,
    2016             :     this.additionalProperties = const {},
    2017             :   });
    2018             : 
    2019           0 :   PusherData.fromJson(Map<String, Object?> json)
    2020           0 :       : format = ((v) => v != null ? v as String : null)(json['format']),
    2021           0 :         url = ((v) => v != null ? Uri.parse(v as String) : null)(json['url']),
    2022           0 :         additionalProperties = Map.fromEntries(json.entries
    2023           0 :             .where((e) => !['format', 'url'].contains(e.key))
    2024           0 :             .map((e) => MapEntry(e.key, e.value)));
    2025           0 :   Map<String, Object?> toJson() {
    2026           0 :     final format = this.format;
    2027           0 :     final url = this.url;
    2028           0 :     return {
    2029           0 :       ...additionalProperties,
    2030           0 :       if (format != null) 'format': format,
    2031           0 :       if (url != null) 'url': url.toString(),
    2032             :     };
    2033             :   }
    2034             : 
    2035             :   /// The format to use when sending notifications to the Push
    2036             :   /// Gateway.
    2037             :   String? format;
    2038             : 
    2039             :   /// Required if `kind` is `http`. The URL to use to send
    2040             :   /// notifications to.
    2041             :   Uri? url;
    2042             : 
    2043             :   Map<String, Object?> additionalProperties;
    2044             : }
    2045             : 
    2046             : ///
    2047             : @_NameSource('spec')
    2048             : class PusherId {
    2049           0 :   PusherId({
    2050             :     required this.appId,
    2051             :     required this.pushkey,
    2052             :   });
    2053             : 
    2054           0 :   PusherId.fromJson(Map<String, Object?> json)
    2055           0 :       : appId = json['app_id'] as String,
    2056           0 :         pushkey = json['pushkey'] as String;
    2057           0 :   Map<String, Object?> toJson() => {
    2058           0 :         'app_id': appId,
    2059           0 :         'pushkey': pushkey,
    2060             :       };
    2061             : 
    2062             :   /// This is a reverse-DNS style identifier for the application.
    2063             :   /// Max length, 64 chars.
    2064             :   String appId;
    2065             : 
    2066             :   /// This is a unique identifier for this pusher. See `/set` for
    2067             :   /// more detail.
    2068             :   /// Max length, 512 bytes.
    2069             :   String pushkey;
    2070             : }
    2071             : 
    2072             : ///
    2073             : @_NameSource('spec')
    2074             : class Pusher implements PusherId {
    2075           0 :   Pusher({
    2076             :     required this.appId,
    2077             :     required this.pushkey,
    2078             :     required this.appDisplayName,
    2079             :     required this.data,
    2080             :     required this.deviceDisplayName,
    2081             :     required this.kind,
    2082             :     required this.lang,
    2083             :     this.profileTag,
    2084             :   });
    2085             : 
    2086           0 :   Pusher.fromJson(Map<String, Object?> json)
    2087           0 :       : appId = json['app_id'] as String,
    2088           0 :         pushkey = json['pushkey'] as String,
    2089           0 :         appDisplayName = json['app_display_name'] as String,
    2090           0 :         data = PusherData.fromJson(json['data'] as Map<String, Object?>),
    2091           0 :         deviceDisplayName = json['device_display_name'] as String,
    2092           0 :         kind = json['kind'] as String,
    2093           0 :         lang = json['lang'] as String,
    2094             :         profileTag =
    2095           0 :             ((v) => v != null ? v as String : null)(json['profile_tag']);
    2096           0 :   @override
    2097             :   Map<String, Object?> toJson() {
    2098           0 :     final profileTag = this.profileTag;
    2099           0 :     return {
    2100           0 :       'app_id': appId,
    2101           0 :       'pushkey': pushkey,
    2102           0 :       'app_display_name': appDisplayName,
    2103           0 :       'data': data.toJson(),
    2104           0 :       'device_display_name': deviceDisplayName,
    2105           0 :       'kind': kind,
    2106           0 :       'lang': lang,
    2107           0 :       if (profileTag != null) 'profile_tag': profileTag,
    2108             :     };
    2109             :   }
    2110             : 
    2111             :   /// This is a reverse-DNS style identifier for the application.
    2112             :   /// Max length, 64 chars.
    2113             :   @override
    2114             :   String appId;
    2115             : 
    2116             :   /// This is a unique identifier for this pusher. See `/set` for
    2117             :   /// more detail.
    2118             :   /// Max length, 512 bytes.
    2119             :   @override
    2120             :   String pushkey;
    2121             : 
    2122             :   /// A string that will allow the user to identify what application
    2123             :   /// owns this pusher.
    2124             :   String appDisplayName;
    2125             : 
    2126             :   /// A dictionary of information for the pusher implementation
    2127             :   /// itself.
    2128             :   PusherData data;
    2129             : 
    2130             :   /// A string that will allow the user to identify what device owns
    2131             :   /// this pusher.
    2132             :   String deviceDisplayName;
    2133             : 
    2134             :   /// The kind of pusher. `"http"` is a pusher that
    2135             :   /// sends HTTP pokes.
    2136             :   String kind;
    2137             : 
    2138             :   /// The preferred language for receiving notifications (e.g. 'en'
    2139             :   /// or 'en-US')
    2140             :   String lang;
    2141             : 
    2142             :   /// This string determines which set of device specific rules this
    2143             :   /// pusher executes.
    2144             :   String? profileTag;
    2145             : }
    2146             : 
    2147             : ///
    2148             : @_NameSource('spec')
    2149             : class PushCondition {
    2150          32 :   PushCondition({
    2151             :     this.is$,
    2152             :     this.key,
    2153             :     required this.kind,
    2154             :     this.pattern,
    2155             :     this.value,
    2156             :   });
    2157             : 
    2158          32 :   PushCondition.fromJson(Map<String, Object?> json)
    2159          96 :       : is$ = ((v) => v != null ? v as String : null)(json['is']),
    2160          96 :         key = ((v) => v != null ? v as String : null)(json['key']),
    2161          32 :         kind = json['kind'] as String,
    2162          96 :         pattern = ((v) => v != null ? v as String : null)(json['pattern']),
    2163          96 :         value = ((v) => v != null ? v as Object? : null)(json['value']);
    2164           0 :   Map<String, Object?> toJson() {
    2165           0 :     final is$ = this.is$;
    2166           0 :     final key = this.key;
    2167           0 :     final pattern = this.pattern;
    2168           0 :     final value = this.value;
    2169           0 :     return {
    2170           0 :       if (is$ != null) 'is': is$,
    2171           0 :       if (key != null) 'key': key,
    2172           0 :       'kind': kind,
    2173           0 :       if (pattern != null) 'pattern': pattern,
    2174           0 :       if (value != null) 'value': value,
    2175             :     };
    2176             :   }
    2177             : 
    2178             :   /// Required for `room_member_count` conditions. A decimal integer
    2179             :   /// optionally prefixed by one of, ==, <, >, >= or <=. A prefix of < matches
    2180             :   /// rooms where the member count is strictly less than the given number and
    2181             :   /// so forth. If no prefix is present, this parameter defaults to ==.
    2182             :   String? is$;
    2183             : 
    2184             :   /// Required for `event_match`, `event_property_is` and `event_property_contains`
    2185             :   /// conditions. The dot-separated field of the event to match.
    2186             :   ///
    2187             :   /// Required for `sender_notification_permission` conditions. The field in
    2188             :   /// the power level event the user needs a minimum power level for. Fields
    2189             :   /// must be specified under the `notifications` property in the power level
    2190             :   /// event's `content`.
    2191             :   String? key;
    2192             : 
    2193             :   /// The kind of condition to apply. See [conditions](https://spec.matrix.org/unstable/client-server-api/#conditions-1) for
    2194             :   /// more information on the allowed kinds and how they work.
    2195             :   String kind;
    2196             : 
    2197             :   /// Required for `event_match` conditions. The [glob-style pattern](https://spec.matrix.org/unstable/appendices#glob-style-matching)
    2198             :   /// to match against.
    2199             :   String? pattern;
    2200             : 
    2201             :   /// Required for `event_property_is` and `event_property_contains` conditions.
    2202             :   /// A non-compound [canonical JSON](https://spec.matrix.org/unstable/appendices#canonical-json) value to match
    2203             :   /// against.
    2204             :   Object? value;
    2205             : }
    2206             : 
    2207             : ///
    2208             : @_NameSource('spec')
    2209             : class PushRule {
    2210          32 :   PushRule({
    2211             :     required this.actions,
    2212             :     this.conditions,
    2213             :     required this.default$,
    2214             :     required this.enabled,
    2215             :     this.pattern,
    2216             :     required this.ruleId,
    2217             :   });
    2218             : 
    2219          32 :   PushRule.fromJson(Map<String, Object?> json)
    2220         128 :       : actions = (json['actions'] as List).map((v) => v as Object?).toList(),
    2221          32 :         conditions = ((v) => v != null
    2222             :             ? (v as List)
    2223          96 :                 .map((v) => PushCondition.fromJson(v as Map<String, Object?>))
    2224          32 :                 .toList()
    2225          64 :             : null)(json['conditions']),
    2226          32 :         default$ = json['default'] as bool,
    2227          32 :         enabled = json['enabled'] as bool,
    2228          96 :         pattern = ((v) => v != null ? v as String : null)(json['pattern']),
    2229          32 :         ruleId = json['rule_id'] as String;
    2230           0 :   Map<String, Object?> toJson() {
    2231           0 :     final conditions = this.conditions;
    2232           0 :     final pattern = this.pattern;
    2233           0 :     return {
    2234           0 :       'actions': actions.map((v) => v).toList(),
    2235             :       if (conditions != null)
    2236           0 :         'conditions': conditions.map((v) => v.toJson()).toList(),
    2237           0 :       'default': default$,
    2238           0 :       'enabled': enabled,
    2239           0 :       if (pattern != null) 'pattern': pattern,
    2240           0 :       'rule_id': ruleId,
    2241             :     };
    2242             :   }
    2243             : 
    2244             :   /// The actions to perform when this rule is matched.
    2245             :   List<Object?> actions;
    2246             : 
    2247             :   /// The conditions that must hold true for an event in order for a rule to be
    2248             :   /// applied to an event. A rule with no conditions always matches. Only
    2249             :   /// applicable to `underride` and `override` rules.
    2250             :   List<PushCondition>? conditions;
    2251             : 
    2252             :   /// Whether this is a default rule, or has been set explicitly.
    2253             :   bool default$;
    2254             : 
    2255             :   /// Whether the push rule is enabled or not.
    2256             :   bool enabled;
    2257             : 
    2258             :   /// The [glob-style pattern](https://spec.matrix.org/unstable/appendices#glob-style-matching) to match against.
    2259             :   /// Only applicable to `content` rules.
    2260             :   String? pattern;
    2261             : 
    2262             :   /// The ID of this rule.
    2263             :   String ruleId;
    2264             : }
    2265             : 
    2266             : ///
    2267             : @_NameSource('rule override generated')
    2268             : class PushRuleSet {
    2269           2 :   PushRuleSet({
    2270             :     this.content,
    2271             :     this.override,
    2272             :     this.room,
    2273             :     this.sender,
    2274             :     this.underride,
    2275             :   });
    2276             : 
    2277          32 :   PushRuleSet.fromJson(Map<String, Object?> json)
    2278          32 :       : content = ((v) => v != null
    2279             :             ? (v as List)
    2280          96 :                 .map((v) => PushRule.fromJson(v as Map<String, Object?>))
    2281          32 :                 .toList()
    2282          64 :             : null)(json['content']),
    2283          32 :         override = ((v) => v != null
    2284             :             ? (v as List)
    2285          96 :                 .map((v) => PushRule.fromJson(v as Map<String, Object?>))
    2286          32 :                 .toList()
    2287          64 :             : null)(json['override']),
    2288          32 :         room = ((v) => v != null
    2289             :             ? (v as List)
    2290          96 :                 .map((v) => PushRule.fromJson(v as Map<String, Object?>))
    2291          32 :                 .toList()
    2292          64 :             : null)(json['room']),
    2293          32 :         sender = ((v) => v != null
    2294             :             ? (v as List)
    2295          32 :                 .map((v) => PushRule.fromJson(v as Map<String, Object?>))
    2296          32 :                 .toList()
    2297          64 :             : null)(json['sender']),
    2298          32 :         underride = ((v) => v != null
    2299             :             ? (v as List)
    2300          96 :                 .map((v) => PushRule.fromJson(v as Map<String, Object?>))
    2301          32 :                 .toList()
    2302          64 :             : null)(json['underride']);
    2303           0 :   Map<String, Object?> toJson() {
    2304           0 :     final content = this.content;
    2305           0 :     final override = this.override;
    2306           0 :     final room = this.room;
    2307           0 :     final sender = this.sender;
    2308           0 :     final underride = this.underride;
    2309           0 :     return {
    2310           0 :       if (content != null) 'content': content.map((v) => v.toJson()).toList(),
    2311             :       if (override != null)
    2312           0 :         'override': override.map((v) => v.toJson()).toList(),
    2313           0 :       if (room != null) 'room': room.map((v) => v.toJson()).toList(),
    2314           0 :       if (sender != null) 'sender': sender.map((v) => v.toJson()).toList(),
    2315             :       if (underride != null)
    2316           0 :         'underride': underride.map((v) => v.toJson()).toList(),
    2317             :     };
    2318             :   }
    2319             : 
    2320             :   ///
    2321             :   List<PushRule>? content;
    2322             : 
    2323             :   ///
    2324             :   List<PushRule>? override;
    2325             : 
    2326             :   ///
    2327             :   List<PushRule>? room;
    2328             : 
    2329             :   ///
    2330             :   List<PushRule>? sender;
    2331             : 
    2332             :   ///
    2333             :   List<PushRule>? underride;
    2334             : }
    2335             : 
    2336             : ///
    2337             : @_NameSource('rule override generated')
    2338             : @EnhancedEnum()
    2339             : enum PushRuleKind {
    2340             :   @EnhancedEnumValue(name: 'content')
    2341             :   content,
    2342             :   @EnhancedEnumValue(name: 'override')
    2343             :   override,
    2344             :   @EnhancedEnumValue(name: 'room')
    2345             :   room,
    2346             :   @EnhancedEnumValue(name: 'sender')
    2347             :   sender,
    2348             :   @EnhancedEnumValue(name: 'underride')
    2349             :   underride
    2350             : }
    2351             : 
    2352             : ///
    2353             : @_NameSource('generated')
    2354             : class RefreshResponse {
    2355           0 :   RefreshResponse({
    2356             :     required this.accessToken,
    2357             :     this.expiresInMs,
    2358             :     this.refreshToken,
    2359             :   });
    2360             : 
    2361           1 :   RefreshResponse.fromJson(Map<String, Object?> json)
    2362           1 :       : accessToken = json['access_token'] as String,
    2363             :         expiresInMs =
    2364           3 :             ((v) => v != null ? v as int : null)(json['expires_in_ms']),
    2365             :         refreshToken =
    2366           3 :             ((v) => v != null ? v as String : null)(json['refresh_token']);
    2367           0 :   Map<String, Object?> toJson() {
    2368           0 :     final expiresInMs = this.expiresInMs;
    2369           0 :     final refreshToken = this.refreshToken;
    2370           0 :     return {
    2371           0 :       'access_token': accessToken,
    2372           0 :       if (expiresInMs != null) 'expires_in_ms': expiresInMs,
    2373           0 :       if (refreshToken != null) 'refresh_token': refreshToken,
    2374             :     };
    2375             :   }
    2376             : 
    2377             :   /// The new access token to use.
    2378             :   String accessToken;
    2379             : 
    2380             :   /// The lifetime of the access token, in milliseconds. If not
    2381             :   /// given, the client can assume that the access token will not
    2382             :   /// expire.
    2383             :   int? expiresInMs;
    2384             : 
    2385             :   /// The new refresh token to use when the access token needs to
    2386             :   /// be refreshed again. If not given, the old refresh token can
    2387             :   /// be re-used.
    2388             :   String? refreshToken;
    2389             : }
    2390             : 
    2391             : ///
    2392             : @_NameSource('rule override generated')
    2393             : @EnhancedEnum()
    2394             : enum AccountKind {
    2395             :   @EnhancedEnumValue(name: 'guest')
    2396             :   guest,
    2397             :   @EnhancedEnumValue(name: 'user')
    2398             :   user
    2399             : }
    2400             : 
    2401             : ///
    2402             : @_NameSource('generated')
    2403             : class RegisterResponse {
    2404           0 :   RegisterResponse({
    2405             :     this.accessToken,
    2406             :     this.deviceId,
    2407             :     this.expiresInMs,
    2408             :     this.homeServer,
    2409             :     this.refreshToken,
    2410             :     required this.userId,
    2411             :   });
    2412             : 
    2413           0 :   RegisterResponse.fromJson(Map<String, Object?> json)
    2414             :       : accessToken =
    2415           0 :             ((v) => v != null ? v as String : null)(json['access_token']),
    2416           0 :         deviceId = ((v) => v != null ? v as String : null)(json['device_id']),
    2417             :         expiresInMs =
    2418           0 :             ((v) => v != null ? v as int : null)(json['expires_in_ms']),
    2419             :         homeServer =
    2420           0 :             ((v) => v != null ? v as String : null)(json['home_server']),
    2421             :         refreshToken =
    2422           0 :             ((v) => v != null ? v as String : null)(json['refresh_token']),
    2423           0 :         userId = json['user_id'] as String;
    2424           0 :   Map<String, Object?> toJson() {
    2425           0 :     final accessToken = this.accessToken;
    2426           0 :     final deviceId = this.deviceId;
    2427           0 :     final expiresInMs = this.expiresInMs;
    2428           0 :     final homeServer = this.homeServer;
    2429           0 :     final refreshToken = this.refreshToken;
    2430           0 :     return {
    2431           0 :       if (accessToken != null) 'access_token': accessToken,
    2432           0 :       if (deviceId != null) 'device_id': deviceId,
    2433           0 :       if (expiresInMs != null) 'expires_in_ms': expiresInMs,
    2434           0 :       if (homeServer != null) 'home_server': homeServer,
    2435           0 :       if (refreshToken != null) 'refresh_token': refreshToken,
    2436           0 :       'user_id': userId,
    2437             :     };
    2438             :   }
    2439             : 
    2440             :   /// An access token for the account.
    2441             :   /// This access token can then be used to authorize other requests.
    2442             :   /// Required if the `inhibit_login` option is false.
    2443             :   String? accessToken;
    2444             : 
    2445             :   /// ID of the registered device. Will be the same as the
    2446             :   /// corresponding parameter in the request, if one was specified.
    2447             :   /// Required if the `inhibit_login` option is false.
    2448             :   String? deviceId;
    2449             : 
    2450             :   /// The lifetime of the access token, in milliseconds. Once
    2451             :   /// the access token has expired a new access token can be
    2452             :   /// obtained by using the provided refresh token. If no
    2453             :   /// refresh token is provided, the client will need to re-log in
    2454             :   /// to obtain a new access token. If not given, the client can
    2455             :   /// assume that the access token will not expire.
    2456             :   ///
    2457             :   /// Omitted if the `inhibit_login` option is true.
    2458             :   int? expiresInMs;
    2459             : 
    2460             :   /// The server_name of the homeserver on which the account has
    2461             :   /// been registered.
    2462             :   ///
    2463             :   /// **Deprecated**. Clients should extract the server_name from
    2464             :   /// `user_id` (by splitting at the first colon) if they require
    2465             :   /// it. Note also that `homeserver` is not spelt this way.
    2466             :   String? homeServer;
    2467             : 
    2468             :   /// A refresh token for the account. This token can be used to
    2469             :   /// obtain a new access token when it expires by calling the
    2470             :   /// `/refresh` endpoint.
    2471             :   ///
    2472             :   /// Omitted if the `inhibit_login` option is true.
    2473             :   String? refreshToken;
    2474             : 
    2475             :   /// The fully-qualified Matrix user ID (MXID) that has been registered.
    2476             :   ///
    2477             :   /// Any user ID returned by this API must conform to the grammar given in the
    2478             :   /// [Matrix specification](https://spec.matrix.org/unstable/appendices/#user-identifiers).
    2479             :   String userId;
    2480             : }
    2481             : 
    2482             : ///
    2483             : @_NameSource('spec')
    2484             : class RoomKeysUpdateResponse {
    2485           0 :   RoomKeysUpdateResponse({
    2486             :     required this.count,
    2487             :     required this.etag,
    2488             :   });
    2489             : 
    2490           4 :   RoomKeysUpdateResponse.fromJson(Map<String, Object?> json)
    2491           4 :       : count = json['count'] as int,
    2492           4 :         etag = json['etag'] as String;
    2493           0 :   Map<String, Object?> toJson() => {
    2494           0 :         'count': count,
    2495           0 :         'etag': etag,
    2496             :       };
    2497             : 
    2498             :   /// The number of keys stored in the backup
    2499             :   int count;
    2500             : 
    2501             :   /// The new etag value representing stored keys in the backup.
    2502             :   /// See `GET /room_keys/version/{version}` for more details.
    2503             :   String etag;
    2504             : }
    2505             : 
    2506             : /// The key data
    2507             : @_NameSource('spec')
    2508             : class KeyBackupData {
    2509           4 :   KeyBackupData({
    2510             :     required this.firstMessageIndex,
    2511             :     required this.forwardedCount,
    2512             :     required this.isVerified,
    2513             :     required this.sessionData,
    2514             :   });
    2515             : 
    2516           1 :   KeyBackupData.fromJson(Map<String, Object?> json)
    2517           1 :       : firstMessageIndex = json['first_message_index'] as int,
    2518           1 :         forwardedCount = json['forwarded_count'] as int,
    2519           1 :         isVerified = json['is_verified'] as bool,
    2520           1 :         sessionData = json['session_data'] as Map<String, Object?>;
    2521           8 :   Map<String, Object?> toJson() => {
    2522           4 :         'first_message_index': firstMessageIndex,
    2523           4 :         'forwarded_count': forwardedCount,
    2524           4 :         'is_verified': isVerified,
    2525           4 :         'session_data': sessionData,
    2526             :       };
    2527             : 
    2528             :   /// The index of the first message in the session that the key can decrypt.
    2529             :   int firstMessageIndex;
    2530             : 
    2531             :   /// The number of times this key has been forwarded via key-sharing between devices.
    2532             :   int forwardedCount;
    2533             : 
    2534             :   /// Whether the device backing up the key verified the device that the key
    2535             :   /// is from.
    2536             :   bool isVerified;
    2537             : 
    2538             :   /// Algorithm-dependent data.  See the documentation for the backup
    2539             :   /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the
    2540             :   /// expected format of the data.
    2541             :   Map<String, Object?> sessionData;
    2542             : }
    2543             : 
    2544             : /// The backed up keys for a room.
    2545             : @_NameSource('spec')
    2546             : class RoomKeyBackup {
    2547           4 :   RoomKeyBackup({
    2548             :     required this.sessions,
    2549             :   });
    2550             : 
    2551           1 :   RoomKeyBackup.fromJson(Map<String, Object?> json)
    2552           3 :       : sessions = (json['sessions'] as Map<String, Object?>).map((k, v) =>
    2553           2 :             MapEntry(k, KeyBackupData.fromJson(v as Map<String, Object?>)));
    2554           8 :   Map<String, Object?> toJson() => {
    2555          20 :         'sessions': sessions.map((k, v) => MapEntry(k, v.toJson())),
    2556             :       };
    2557             : 
    2558             :   /// A map of session IDs to key data.
    2559             :   Map<String, KeyBackupData> sessions;
    2560             : }
    2561             : 
    2562             : ///
    2563             : @_NameSource('rule override generated')
    2564             : class RoomKeys {
    2565           4 :   RoomKeys({
    2566             :     required this.rooms,
    2567             :   });
    2568             : 
    2569           1 :   RoomKeys.fromJson(Map<String, Object?> json)
    2570           3 :       : rooms = (json['rooms'] as Map<String, Object?>).map((k, v) =>
    2571           2 :             MapEntry(k, RoomKeyBackup.fromJson(v as Map<String, Object?>)));
    2572           8 :   Map<String, Object?> toJson() => {
    2573          20 :         'rooms': rooms.map((k, v) => MapEntry(k, v.toJson())),
    2574             :       };
    2575             : 
    2576             :   /// A map of room IDs to room key backup data.
    2577             :   Map<String, RoomKeyBackup> rooms;
    2578             : }
    2579             : 
    2580             : ///
    2581             : @_NameSource('rule override generated')
    2582             : @EnhancedEnum()
    2583             : enum BackupAlgorithm {
    2584             :   @EnhancedEnumValue(name: 'm.megolm_backup.v1.curve25519-aes-sha2')
    2585             :   mMegolmBackupV1Curve25519AesSha2
    2586             : }
    2587             : 
    2588             : ///
    2589             : @_NameSource('generated')
    2590             : class GetRoomKeysVersionCurrentResponse {
    2591           0 :   GetRoomKeysVersionCurrentResponse({
    2592             :     required this.algorithm,
    2593             :     required this.authData,
    2594             :     required this.count,
    2595             :     required this.etag,
    2596             :     required this.version,
    2597             :   });
    2598             : 
    2599           5 :   GetRoomKeysVersionCurrentResponse.fromJson(Map<String, Object?> json)
    2600             :       : algorithm =
    2601          10 :             BackupAlgorithm.values.fromString(json['algorithm'] as String)!,
    2602           5 :         authData = json['auth_data'] as Map<String, Object?>,
    2603           5 :         count = json['count'] as int,
    2604           5 :         etag = json['etag'] as String,
    2605           5 :         version = json['version'] as String;
    2606           0 :   Map<String, Object?> toJson() => {
    2607           0 :         'algorithm': algorithm.name,
    2608           0 :         'auth_data': authData,
    2609           0 :         'count': count,
    2610           0 :         'etag': etag,
    2611           0 :         'version': version,
    2612             :       };
    2613             : 
    2614             :   /// The algorithm used for storing backups.
    2615             :   BackupAlgorithm algorithm;
    2616             : 
    2617             :   /// Algorithm-dependent data. See the documentation for the backup
    2618             :   /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the
    2619             :   /// expected format of the data.
    2620             :   Map<String, Object?> authData;
    2621             : 
    2622             :   /// The number of keys stored in the backup.
    2623             :   int count;
    2624             : 
    2625             :   /// An opaque string representing stored keys in the backup.
    2626             :   /// Clients can compare it with the `etag` value they received
    2627             :   /// in the request of their last key storage request.  If not
    2628             :   /// equal, another client has modified the backup.
    2629             :   String etag;
    2630             : 
    2631             :   /// The backup version.
    2632             :   String version;
    2633             : }
    2634             : 
    2635             : ///
    2636             : @_NameSource('generated')
    2637             : class GetRoomKeysVersionResponse {
    2638           0 :   GetRoomKeysVersionResponse({
    2639             :     required this.algorithm,
    2640             :     required this.authData,
    2641             :     required this.count,
    2642             :     required this.etag,
    2643             :     required this.version,
    2644             :   });
    2645             : 
    2646           0 :   GetRoomKeysVersionResponse.fromJson(Map<String, Object?> json)
    2647             :       : algorithm =
    2648           0 :             BackupAlgorithm.values.fromString(json['algorithm'] as String)!,
    2649           0 :         authData = json['auth_data'] as Map<String, Object?>,
    2650           0 :         count = json['count'] as int,
    2651           0 :         etag = json['etag'] as String,
    2652           0 :         version = json['version'] as String;
    2653           0 :   Map<String, Object?> toJson() => {
    2654           0 :         'algorithm': algorithm.name,
    2655           0 :         'auth_data': authData,
    2656           0 :         'count': count,
    2657           0 :         'etag': etag,
    2658           0 :         'version': version,
    2659             :       };
    2660             : 
    2661             :   /// The algorithm used for storing backups.
    2662             :   BackupAlgorithm algorithm;
    2663             : 
    2664             :   /// Algorithm-dependent data. See the documentation for the backup
    2665             :   /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the
    2666             :   /// expected format of the data.
    2667             :   Map<String, Object?> authData;
    2668             : 
    2669             :   /// The number of keys stored in the backup.
    2670             :   int count;
    2671             : 
    2672             :   /// An opaque string representing stored keys in the backup.
    2673             :   /// Clients can compare it with the `etag` value they received
    2674             :   /// in the request of their last key storage request.  If not
    2675             :   /// equal, another client has modified the backup.
    2676             :   String etag;
    2677             : 
    2678             :   /// The backup version.
    2679             :   String version;
    2680             : }
    2681             : 
    2682             : /// The events and state surrounding the requested event.
    2683             : @_NameSource('rule override generated')
    2684             : class EventContext {
    2685           0 :   EventContext({
    2686             :     this.end,
    2687             :     this.event,
    2688             :     this.eventsAfter,
    2689             :     this.eventsBefore,
    2690             :     this.start,
    2691             :     this.state,
    2692             :   });
    2693             : 
    2694           0 :   EventContext.fromJson(Map<String, Object?> json)
    2695           0 :       : end = ((v) => v != null ? v as String : null)(json['end']),
    2696           0 :         event = ((v) => v != null
    2697           0 :             ? MatrixEvent.fromJson(v as Map<String, Object?>)
    2698           0 :             : null)(json['event']),
    2699           0 :         eventsAfter = ((v) => v != null
    2700             :             ? (v as List)
    2701           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    2702           0 :                 .toList()
    2703           0 :             : null)(json['events_after']),
    2704           0 :         eventsBefore = ((v) => v != null
    2705             :             ? (v as List)
    2706           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    2707           0 :                 .toList()
    2708           0 :             : null)(json['events_before']),
    2709           0 :         start = ((v) => v != null ? v as String : null)(json['start']),
    2710           0 :         state = ((v) => v != null
    2711             :             ? (v as List)
    2712           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    2713           0 :                 .toList()
    2714           0 :             : null)(json['state']);
    2715           0 :   Map<String, Object?> toJson() {
    2716           0 :     final end = this.end;
    2717           0 :     final event = this.event;
    2718           0 :     final eventsAfter = this.eventsAfter;
    2719           0 :     final eventsBefore = this.eventsBefore;
    2720           0 :     final start = this.start;
    2721           0 :     final state = this.state;
    2722           0 :     return {
    2723           0 :       if (end != null) 'end': end,
    2724           0 :       if (event != null) 'event': event.toJson(),
    2725             :       if (eventsAfter != null)
    2726           0 :         'events_after': eventsAfter.map((v) => v.toJson()).toList(),
    2727             :       if (eventsBefore != null)
    2728           0 :         'events_before': eventsBefore.map((v) => v.toJson()).toList(),
    2729           0 :       if (start != null) 'start': start,
    2730           0 :       if (state != null) 'state': state.map((v) => v.toJson()).toList(),
    2731             :     };
    2732             :   }
    2733             : 
    2734             :   /// A token that can be used to paginate forwards with.
    2735             :   String? end;
    2736             : 
    2737             :   /// Details of the requested event.
    2738             :   MatrixEvent? event;
    2739             : 
    2740             :   /// A list of room events that happened just after the
    2741             :   /// requested event, in chronological order.
    2742             :   List<MatrixEvent>? eventsAfter;
    2743             : 
    2744             :   /// A list of room events that happened just before the
    2745             :   /// requested event, in reverse-chronological order.
    2746             :   List<MatrixEvent>? eventsBefore;
    2747             : 
    2748             :   /// A token that can be used to paginate backwards with.
    2749             :   String? start;
    2750             : 
    2751             :   /// The state of the room at the last event returned.
    2752             :   List<MatrixEvent>? state;
    2753             : }
    2754             : 
    2755             : ///
    2756             : @_NameSource('spec')
    2757             : class RoomMember {
    2758           0 :   RoomMember({
    2759             :     this.avatarUrl,
    2760             :     this.displayName,
    2761             :   });
    2762             : 
    2763           0 :   RoomMember.fromJson(Map<String, Object?> json)
    2764           0 :       : avatarUrl = ((v) =>
    2765           0 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
    2766             :         displayName =
    2767           0 :             ((v) => v != null ? v as String : null)(json['display_name']);
    2768           0 :   Map<String, Object?> toJson() {
    2769           0 :     final avatarUrl = this.avatarUrl;
    2770           0 :     final displayName = this.displayName;
    2771           0 :     return {
    2772           0 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
    2773           0 :       if (displayName != null) 'display_name': displayName,
    2774             :     };
    2775             :   }
    2776             : 
    2777             :   /// The avatar of the user this object is representing, as an [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris).
    2778             :   Uri? avatarUrl;
    2779             : 
    2780             :   /// The display name of the user this object is representing.
    2781             :   String? displayName;
    2782             : }
    2783             : 
    2784             : ///
    2785             : @_NameSource('(generated, rule override generated)')
    2786             : @EnhancedEnum()
    2787             : enum Membership {
    2788             :   @EnhancedEnumValue(name: 'ban')
    2789             :   ban,
    2790             :   @EnhancedEnumValue(name: 'invite')
    2791             :   invite,
    2792             :   @EnhancedEnumValue(name: 'join')
    2793             :   join,
    2794             :   @EnhancedEnumValue(name: 'knock')
    2795             :   knock,
    2796             :   @EnhancedEnumValue(name: 'leave')
    2797             :   leave
    2798             : }
    2799             : 
    2800             : /// A list of messages with a new token to request more.
    2801             : @_NameSource('generated')
    2802             : class GetRoomEventsResponse {
    2803           0 :   GetRoomEventsResponse({
    2804             :     required this.chunk,
    2805             :     this.end,
    2806             :     required this.start,
    2807             :     this.state,
    2808             :   });
    2809             : 
    2810           4 :   GetRoomEventsResponse.fromJson(Map<String, Object?> json)
    2811           4 :       : chunk = (json['chunk'] as List)
    2812          12 :             .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    2813           4 :             .toList(),
    2814          12 :         end = ((v) => v != null ? v as String : null)(json['end']),
    2815           4 :         start = json['start'] as String,
    2816           4 :         state = ((v) => v != null
    2817             :             ? (v as List)
    2818           4 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    2819           4 :                 .toList()
    2820           8 :             : null)(json['state']);
    2821           0 :   Map<String, Object?> toJson() {
    2822           0 :     final end = this.end;
    2823           0 :     final state = this.state;
    2824           0 :     return {
    2825           0 :       'chunk': chunk.map((v) => v.toJson()).toList(),
    2826           0 :       if (end != null) 'end': end,
    2827           0 :       'start': start,
    2828           0 :       if (state != null) 'state': state.map((v) => v.toJson()).toList(),
    2829             :     };
    2830             :   }
    2831             : 
    2832             :   /// A list of room events. The order depends on the `dir` parameter.
    2833             :   /// For `dir=b` events will be in reverse-chronological order,
    2834             :   /// for `dir=f` in chronological order. (The exact definition of `chronological`
    2835             :   /// is dependent on the server implementation.)
    2836             :   ///
    2837             :   /// Note that an empty `chunk` does not *necessarily* imply that no more events
    2838             :   /// are available. Clients should continue to paginate until no `end` property
    2839             :   /// is returned.
    2840             :   List<MatrixEvent> chunk;
    2841             : 
    2842             :   /// A token corresponding to the end of `chunk`. This token can be passed
    2843             :   /// back to this endpoint to request further events.
    2844             :   ///
    2845             :   /// If no further events are available (either because we have
    2846             :   /// reached the start of the timeline, or because the user does
    2847             :   /// not have permission to see any more events), this property
    2848             :   /// is omitted from the response.
    2849             :   String? end;
    2850             : 
    2851             :   /// A token corresponding to the start of `chunk`. This will be the same as
    2852             :   /// the value given in `from`.
    2853             :   String start;
    2854             : 
    2855             :   /// A list of state events relevant to showing the `chunk`. For example, if
    2856             :   /// `lazy_load_members` is enabled in the filter then this may contain
    2857             :   /// the membership events for the senders of events in the `chunk`.
    2858             :   ///
    2859             :   /// Unless `include_redundant_members` is `true`, the server
    2860             :   /// may remove membership events which would have already been
    2861             :   /// sent to the client in prior calls to this endpoint, assuming
    2862             :   /// the membership of those members has not changed.
    2863             :   List<MatrixEvent>? state;
    2864             : }
    2865             : 
    2866             : ///
    2867             : @_NameSource('generated')
    2868             : @EnhancedEnum()
    2869             : enum ReceiptType {
    2870             :   @EnhancedEnumValue(name: 'm.fully_read')
    2871             :   mFullyRead,
    2872             :   @EnhancedEnumValue(name: 'm.read')
    2873             :   mRead,
    2874             :   @EnhancedEnumValue(name: 'm.read.private')
    2875             :   mReadPrivate
    2876             : }
    2877             : 
    2878             : ///
    2879             : @_NameSource('spec')
    2880             : class IncludeEventContext {
    2881           0 :   IncludeEventContext({
    2882             :     this.afterLimit,
    2883             :     this.beforeLimit,
    2884             :     this.includeProfile,
    2885             :   });
    2886             : 
    2887           0 :   IncludeEventContext.fromJson(Map<String, Object?> json)
    2888           0 :       : afterLimit = ((v) => v != null ? v as int : null)(json['after_limit']),
    2889             :         beforeLimit =
    2890           0 :             ((v) => v != null ? v as int : null)(json['before_limit']),
    2891             :         includeProfile =
    2892           0 :             ((v) => v != null ? v as bool : null)(json['include_profile']);
    2893           0 :   Map<String, Object?> toJson() {
    2894           0 :     final afterLimit = this.afterLimit;
    2895           0 :     final beforeLimit = this.beforeLimit;
    2896           0 :     final includeProfile = this.includeProfile;
    2897           0 :     return {
    2898           0 :       if (afterLimit != null) 'after_limit': afterLimit,
    2899           0 :       if (beforeLimit != null) 'before_limit': beforeLimit,
    2900           0 :       if (includeProfile != null) 'include_profile': includeProfile,
    2901             :     };
    2902             :   }
    2903             : 
    2904             :   /// How many events after the result are
    2905             :   /// returned. By default, this is `5`.
    2906             :   int? afterLimit;
    2907             : 
    2908             :   /// How many events before the result are
    2909             :   /// returned. By default, this is `5`.
    2910             :   int? beforeLimit;
    2911             : 
    2912             :   /// Requests that the server returns the
    2913             :   /// historic profile information for the users
    2914             :   /// that sent the events that were returned.
    2915             :   /// By default, this is `false`.
    2916             :   bool? includeProfile;
    2917             : }
    2918             : 
    2919             : ///
    2920             : @_NameSource('spec')
    2921             : class EventFilter {
    2922           0 :   EventFilter({
    2923             :     this.limit,
    2924             :     this.notSenders,
    2925             :     this.notTypes,
    2926             :     this.senders,
    2927             :     this.types,
    2928             :   });
    2929             : 
    2930           0 :   EventFilter.fromJson(Map<String, Object?> json)
    2931           0 :       : limit = ((v) => v != null ? v as int : null)(json['limit']),
    2932           0 :         notSenders = ((v) => v != null
    2933           0 :             ? (v as List).map((v) => v as String).toList()
    2934           0 :             : null)(json['not_senders']),
    2935           0 :         notTypes = ((v) => v != null
    2936           0 :             ? (v as List).map((v) => v as String).toList()
    2937           0 :             : null)(json['not_types']),
    2938           0 :         senders = ((v) => v != null
    2939           0 :             ? (v as List).map((v) => v as String).toList()
    2940           0 :             : null)(json['senders']),
    2941           0 :         types = ((v) => v != null
    2942           0 :             ? (v as List).map((v) => v as String).toList()
    2943           0 :             : null)(json['types']);
    2944           0 :   Map<String, Object?> toJson() {
    2945           0 :     final limit = this.limit;
    2946           0 :     final notSenders = this.notSenders;
    2947           0 :     final notTypes = this.notTypes;
    2948           0 :     final senders = this.senders;
    2949           0 :     final types = this.types;
    2950           0 :     return {
    2951           0 :       if (limit != null) 'limit': limit,
    2952           0 :       if (notSenders != null) 'not_senders': notSenders.map((v) => v).toList(),
    2953           0 :       if (notTypes != null) 'not_types': notTypes.map((v) => v).toList(),
    2954           0 :       if (senders != null) 'senders': senders.map((v) => v).toList(),
    2955           0 :       if (types != null) 'types': types.map((v) => v).toList(),
    2956             :     };
    2957             :   }
    2958             : 
    2959             :   /// The maximum number of events to return, must be an integer greater than 0.
    2960             :   ///
    2961             :   /// Servers should apply a default value, and impose a maximum value to avoid
    2962             :   /// resource exhaustion.
    2963             :   ///
    2964             :   int? limit;
    2965             : 
    2966             :   /// A list of sender IDs to exclude. If this list is absent then no senders are excluded. A matching sender will be excluded even if it is listed in the `'senders'` filter.
    2967             :   List<String>? notSenders;
    2968             : 
    2969             :   /// A list of event types to exclude. If this list is absent then no event types are excluded. A matching type will be excluded even if it is listed in the `'types'` filter. A '*' can be used as a wildcard to match any sequence of characters.
    2970             :   List<String>? notTypes;
    2971             : 
    2972             :   /// A list of senders IDs to include. If this list is absent then all senders are included.
    2973             :   List<String>? senders;
    2974             : 
    2975             :   /// A list of event types to include. If this list is absent then all event types are included. A `'*'` can be used as a wildcard to match any sequence of characters.
    2976             :   List<String>? types;
    2977             : }
    2978             : 
    2979             : ///
    2980             : @_NameSource('spec')
    2981             : class RoomEventFilter {
    2982           0 :   RoomEventFilter({
    2983             :     this.containsUrl,
    2984             :     this.includeRedundantMembers,
    2985             :     this.lazyLoadMembers,
    2986             :     this.notRooms,
    2987             :     this.rooms,
    2988             :     this.unreadThreadNotifications,
    2989             :   });
    2990             : 
    2991           0 :   RoomEventFilter.fromJson(Map<String, Object?> json)
    2992             :       : containsUrl =
    2993           0 :             ((v) => v != null ? v as bool : null)(json['contains_url']),
    2994           0 :         includeRedundantMembers = ((v) =>
    2995           0 :             v != null ? v as bool : null)(json['include_redundant_members']),
    2996             :         lazyLoadMembers =
    2997           0 :             ((v) => v != null ? v as bool : null)(json['lazy_load_members']),
    2998           0 :         notRooms = ((v) => v != null
    2999           0 :             ? (v as List).map((v) => v as String).toList()
    3000           0 :             : null)(json['not_rooms']),
    3001           0 :         rooms = ((v) => v != null
    3002           0 :             ? (v as List).map((v) => v as String).toList()
    3003           0 :             : null)(json['rooms']),
    3004           0 :         unreadThreadNotifications = ((v) =>
    3005           0 :             v != null ? v as bool : null)(json['unread_thread_notifications']);
    3006           0 :   Map<String, Object?> toJson() {
    3007           0 :     final containsUrl = this.containsUrl;
    3008           0 :     final includeRedundantMembers = this.includeRedundantMembers;
    3009           0 :     final lazyLoadMembers = this.lazyLoadMembers;
    3010           0 :     final notRooms = this.notRooms;
    3011           0 :     final rooms = this.rooms;
    3012           0 :     final unreadThreadNotifications = this.unreadThreadNotifications;
    3013           0 :     return {
    3014           0 :       if (containsUrl != null) 'contains_url': containsUrl,
    3015             :       if (includeRedundantMembers != null)
    3016           0 :         'include_redundant_members': includeRedundantMembers,
    3017           0 :       if (lazyLoadMembers != null) 'lazy_load_members': lazyLoadMembers,
    3018           0 :       if (notRooms != null) 'not_rooms': notRooms.map((v) => v).toList(),
    3019           0 :       if (rooms != null) 'rooms': rooms.map((v) => v).toList(),
    3020             :       if (unreadThreadNotifications != null)
    3021           0 :         'unread_thread_notifications': unreadThreadNotifications,
    3022             :     };
    3023             :   }
    3024             : 
    3025             :   /// If `true`, includes only events with a `url` key in their content. If `false`, excludes those events. If omitted, `url` key is not considered for filtering.
    3026             :   bool? containsUrl;
    3027             : 
    3028             :   /// If `true`, sends all membership events for all events, even if they have already
    3029             :   /// been sent to the client. Does not
    3030             :   /// apply unless `lazy_load_members` is `true`. See
    3031             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3032             :   /// for more information. Defaults to `false`.
    3033             :   bool? includeRedundantMembers;
    3034             : 
    3035             :   /// If `true`, enables lazy-loading of membership events. See
    3036             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3037             :   /// for more information. Defaults to `false`.
    3038             :   bool? lazyLoadMembers;
    3039             : 
    3040             :   /// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the `'rooms'` filter.
    3041             :   List<String>? notRooms;
    3042             : 
    3043             :   /// A list of room IDs to include. If this list is absent then all rooms are included.
    3044             :   List<String>? rooms;
    3045             : 
    3046             :   /// If `true`, enables per-[thread](https://spec.matrix.org/unstable/client-server-api/#threading) notification
    3047             :   /// counts. Only applies to the `/sync` endpoint. Defaults to `false`.
    3048             :   bool? unreadThreadNotifications;
    3049             : }
    3050             : 
    3051             : ///
    3052             : @_NameSource('rule override generated')
    3053             : class SearchFilter implements EventFilter, RoomEventFilter {
    3054           0 :   SearchFilter({
    3055             :     this.limit,
    3056             :     this.notSenders,
    3057             :     this.notTypes,
    3058             :     this.senders,
    3059             :     this.types,
    3060             :     this.containsUrl,
    3061             :     this.includeRedundantMembers,
    3062             :     this.lazyLoadMembers,
    3063             :     this.notRooms,
    3064             :     this.rooms,
    3065             :     this.unreadThreadNotifications,
    3066             :   });
    3067             : 
    3068           0 :   SearchFilter.fromJson(Map<String, Object?> json)
    3069           0 :       : limit = ((v) => v != null ? v as int : null)(json['limit']),
    3070           0 :         notSenders = ((v) => v != null
    3071           0 :             ? (v as List).map((v) => v as String).toList()
    3072           0 :             : null)(json['not_senders']),
    3073           0 :         notTypes = ((v) => v != null
    3074           0 :             ? (v as List).map((v) => v as String).toList()
    3075           0 :             : null)(json['not_types']),
    3076           0 :         senders = ((v) => v != null
    3077           0 :             ? (v as List).map((v) => v as String).toList()
    3078           0 :             : null)(json['senders']),
    3079           0 :         types = ((v) => v != null
    3080           0 :             ? (v as List).map((v) => v as String).toList()
    3081           0 :             : null)(json['types']),
    3082             :         containsUrl =
    3083           0 :             ((v) => v != null ? v as bool : null)(json['contains_url']),
    3084           0 :         includeRedundantMembers = ((v) =>
    3085           0 :             v != null ? v as bool : null)(json['include_redundant_members']),
    3086             :         lazyLoadMembers =
    3087           0 :             ((v) => v != null ? v as bool : null)(json['lazy_load_members']),
    3088           0 :         notRooms = ((v) => v != null
    3089           0 :             ? (v as List).map((v) => v as String).toList()
    3090           0 :             : null)(json['not_rooms']),
    3091           0 :         rooms = ((v) => v != null
    3092           0 :             ? (v as List).map((v) => v as String).toList()
    3093           0 :             : null)(json['rooms']),
    3094           0 :         unreadThreadNotifications = ((v) =>
    3095           0 :             v != null ? v as bool : null)(json['unread_thread_notifications']);
    3096           0 :   @override
    3097             :   Map<String, Object?> toJson() {
    3098           0 :     final limit = this.limit;
    3099           0 :     final notSenders = this.notSenders;
    3100           0 :     final notTypes = this.notTypes;
    3101           0 :     final senders = this.senders;
    3102           0 :     final types = this.types;
    3103           0 :     final containsUrl = this.containsUrl;
    3104           0 :     final includeRedundantMembers = this.includeRedundantMembers;
    3105           0 :     final lazyLoadMembers = this.lazyLoadMembers;
    3106           0 :     final notRooms = this.notRooms;
    3107           0 :     final rooms = this.rooms;
    3108           0 :     final unreadThreadNotifications = this.unreadThreadNotifications;
    3109           0 :     return {
    3110           0 :       if (limit != null) 'limit': limit,
    3111           0 :       if (notSenders != null) 'not_senders': notSenders.map((v) => v).toList(),
    3112           0 :       if (notTypes != null) 'not_types': notTypes.map((v) => v).toList(),
    3113           0 :       if (senders != null) 'senders': senders.map((v) => v).toList(),
    3114           0 :       if (types != null) 'types': types.map((v) => v).toList(),
    3115           0 :       if (containsUrl != null) 'contains_url': containsUrl,
    3116             :       if (includeRedundantMembers != null)
    3117           0 :         'include_redundant_members': includeRedundantMembers,
    3118           0 :       if (lazyLoadMembers != null) 'lazy_load_members': lazyLoadMembers,
    3119           0 :       if (notRooms != null) 'not_rooms': notRooms.map((v) => v).toList(),
    3120           0 :       if (rooms != null) 'rooms': rooms.map((v) => v).toList(),
    3121             :       if (unreadThreadNotifications != null)
    3122           0 :         'unread_thread_notifications': unreadThreadNotifications,
    3123             :     };
    3124             :   }
    3125             : 
    3126             :   /// The maximum number of events to return, must be an integer greater than 0.
    3127             :   ///
    3128             :   /// Servers should apply a default value, and impose a maximum value to avoid
    3129             :   /// resource exhaustion.
    3130             :   ///
    3131             :   @override
    3132             :   int? limit;
    3133             : 
    3134             :   /// A list of sender IDs to exclude. If this list is absent then no senders are excluded. A matching sender will be excluded even if it is listed in the `'senders'` filter.
    3135             :   @override
    3136             :   List<String>? notSenders;
    3137             : 
    3138             :   /// A list of event types to exclude. If this list is absent then no event types are excluded. A matching type will be excluded even if it is listed in the `'types'` filter. A '*' can be used as a wildcard to match any sequence of characters.
    3139             :   @override
    3140             :   List<String>? notTypes;
    3141             : 
    3142             :   /// A list of senders IDs to include. If this list is absent then all senders are included.
    3143             :   @override
    3144             :   List<String>? senders;
    3145             : 
    3146             :   /// A list of event types to include. If this list is absent then all event types are included. A `'*'` can be used as a wildcard to match any sequence of characters.
    3147             :   @override
    3148             :   List<String>? types;
    3149             : 
    3150             :   /// If `true`, includes only events with a `url` key in their content. If `false`, excludes those events. If omitted, `url` key is not considered for filtering.
    3151             :   @override
    3152             :   bool? containsUrl;
    3153             : 
    3154             :   /// If `true`, sends all membership events for all events, even if they have already
    3155             :   /// been sent to the client. Does not
    3156             :   /// apply unless `lazy_load_members` is `true`. See
    3157             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3158             :   /// for more information. Defaults to `false`.
    3159             :   @override
    3160             :   bool? includeRedundantMembers;
    3161             : 
    3162             :   /// If `true`, enables lazy-loading of membership events. See
    3163             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3164             :   /// for more information. Defaults to `false`.
    3165             :   @override
    3166             :   bool? lazyLoadMembers;
    3167             : 
    3168             :   /// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the `'rooms'` filter.
    3169             :   @override
    3170             :   List<String>? notRooms;
    3171             : 
    3172             :   /// A list of room IDs to include. If this list is absent then all rooms are included.
    3173             :   @override
    3174             :   List<String>? rooms;
    3175             : 
    3176             :   /// If `true`, enables per-[thread](https://spec.matrix.org/unstable/client-server-api/#threading) notification
    3177             :   /// counts. Only applies to the `/sync` endpoint. Defaults to `false`.
    3178             :   @override
    3179             :   bool? unreadThreadNotifications;
    3180             : }
    3181             : 
    3182             : ///
    3183             : @_NameSource('rule override generated')
    3184             : @EnhancedEnum()
    3185             : enum GroupKey {
    3186             :   @EnhancedEnumValue(name: 'room_id')
    3187             :   roomId,
    3188             :   @EnhancedEnumValue(name: 'sender')
    3189             :   sender
    3190             : }
    3191             : 
    3192             : /// Configuration for group.
    3193             : @_NameSource('spec')
    3194             : class Group {
    3195           0 :   Group({
    3196             :     this.key,
    3197             :   });
    3198             : 
    3199           0 :   Group.fromJson(Map<String, Object?> json)
    3200           0 :       : key = ((v) => v != null
    3201           0 :             ? GroupKey.values.fromString(v as String)!
    3202           0 :             : null)(json['key']);
    3203           0 :   Map<String, Object?> toJson() {
    3204           0 :     final key = this.key;
    3205           0 :     return {
    3206           0 :       if (key != null) 'key': key.name,
    3207             :     };
    3208             :   }
    3209             : 
    3210             :   /// Key that defines the group.
    3211             :   GroupKey? key;
    3212             : }
    3213             : 
    3214             : ///
    3215             : @_NameSource('spec')
    3216             : class Groupings {
    3217           0 :   Groupings({
    3218             :     this.groupBy,
    3219             :   });
    3220             : 
    3221           0 :   Groupings.fromJson(Map<String, Object?> json)
    3222           0 :       : groupBy = ((v) => v != null
    3223             :             ? (v as List)
    3224           0 :                 .map((v) => Group.fromJson(v as Map<String, Object?>))
    3225           0 :                 .toList()
    3226           0 :             : null)(json['group_by']);
    3227           0 :   Map<String, Object?> toJson() {
    3228           0 :     final groupBy = this.groupBy;
    3229           0 :     return {
    3230           0 :       if (groupBy != null) 'group_by': groupBy.map((v) => v.toJson()).toList(),
    3231             :     };
    3232             :   }
    3233             : 
    3234             :   /// List of groups to request.
    3235             :   List<Group>? groupBy;
    3236             : }
    3237             : 
    3238             : ///
    3239             : @_NameSource('rule override generated')
    3240             : @EnhancedEnum()
    3241             : enum KeyKind {
    3242             :   @EnhancedEnumValue(name: 'content.body')
    3243             :   contentBody,
    3244             :   @EnhancedEnumValue(name: 'content.name')
    3245             :   contentName,
    3246             :   @EnhancedEnumValue(name: 'content.topic')
    3247             :   contentTopic
    3248             : }
    3249             : 
    3250             : ///
    3251             : @_NameSource('rule override generated')
    3252             : @EnhancedEnum()
    3253             : enum SearchOrder {
    3254             :   @EnhancedEnumValue(name: 'rank')
    3255             :   rank,
    3256             :   @EnhancedEnumValue(name: 'recent')
    3257             :   recent
    3258             : }
    3259             : 
    3260             : ///
    3261             : @_NameSource('spec')
    3262             : class RoomEventsCriteria {
    3263           0 :   RoomEventsCriteria({
    3264             :     this.eventContext,
    3265             :     this.filter,
    3266             :     this.groupings,
    3267             :     this.includeState,
    3268             :     this.keys,
    3269             :     this.orderBy,
    3270             :     required this.searchTerm,
    3271             :   });
    3272             : 
    3273           0 :   RoomEventsCriteria.fromJson(Map<String, Object?> json)
    3274           0 :       : eventContext = ((v) => v != null
    3275           0 :             ? IncludeEventContext.fromJson(v as Map<String, Object?>)
    3276           0 :             : null)(json['event_context']),
    3277           0 :         filter = ((v) => v != null
    3278           0 :             ? SearchFilter.fromJson(v as Map<String, Object?>)
    3279           0 :             : null)(json['filter']),
    3280           0 :         groupings = ((v) => v != null
    3281           0 :             ? Groupings.fromJson(v as Map<String, Object?>)
    3282           0 :             : null)(json['groupings']),
    3283             :         includeState =
    3284           0 :             ((v) => v != null ? v as bool : null)(json['include_state']),
    3285           0 :         keys = ((v) => v != null
    3286             :             ? (v as List)
    3287           0 :                 .map((v) => KeyKind.values.fromString(v as String)!)
    3288           0 :                 .toList()
    3289           0 :             : null)(json['keys']),
    3290           0 :         orderBy = ((v) => v != null
    3291           0 :             ? SearchOrder.values.fromString(v as String)!
    3292           0 :             : null)(json['order_by']),
    3293           0 :         searchTerm = json['search_term'] as String;
    3294           0 :   Map<String, Object?> toJson() {
    3295           0 :     final eventContext = this.eventContext;
    3296           0 :     final filter = this.filter;
    3297           0 :     final groupings = this.groupings;
    3298           0 :     final includeState = this.includeState;
    3299           0 :     final keys = this.keys;
    3300           0 :     final orderBy = this.orderBy;
    3301           0 :     return {
    3302           0 :       if (eventContext != null) 'event_context': eventContext.toJson(),
    3303           0 :       if (filter != null) 'filter': filter.toJson(),
    3304           0 :       if (groupings != null) 'groupings': groupings.toJson(),
    3305           0 :       if (includeState != null) 'include_state': includeState,
    3306           0 :       if (keys != null) 'keys': keys.map((v) => v.name).toList(),
    3307           0 :       if (orderBy != null) 'order_by': orderBy.name,
    3308           0 :       'search_term': searchTerm,
    3309             :     };
    3310             :   }
    3311             : 
    3312             :   /// Configures whether any context for the events
    3313             :   /// returned are included in the response.
    3314             :   IncludeEventContext? eventContext;
    3315             : 
    3316             :   /// This takes a [filter](https://spec.matrix.org/unstable/client-server-api/#filtering).
    3317             :   SearchFilter? filter;
    3318             : 
    3319             :   /// Requests that the server partitions the result set
    3320             :   /// based on the provided list of keys.
    3321             :   Groupings? groupings;
    3322             : 
    3323             :   /// Requests the server return the current state for
    3324             :   /// each room returned.
    3325             :   bool? includeState;
    3326             : 
    3327             :   /// The keys to search. Defaults to all.
    3328             :   List<KeyKind>? keys;
    3329             : 
    3330             :   /// The order in which to search for results.
    3331             :   /// By default, this is `"rank"`.
    3332             :   SearchOrder? orderBy;
    3333             : 
    3334             :   /// The string to search events for
    3335             :   String searchTerm;
    3336             : }
    3337             : 
    3338             : ///
    3339             : @_NameSource('spec')
    3340             : class Categories {
    3341           0 :   Categories({
    3342             :     this.roomEvents,
    3343             :   });
    3344             : 
    3345           0 :   Categories.fromJson(Map<String, Object?> json)
    3346           0 :       : roomEvents = ((v) => v != null
    3347           0 :             ? RoomEventsCriteria.fromJson(v as Map<String, Object?>)
    3348           0 :             : null)(json['room_events']);
    3349           0 :   Map<String, Object?> toJson() {
    3350           0 :     final roomEvents = this.roomEvents;
    3351           0 :     return {
    3352           0 :       if (roomEvents != null) 'room_events': roomEvents.toJson(),
    3353             :     };
    3354             :   }
    3355             : 
    3356             :   /// Mapping of category name to search criteria.
    3357             :   RoomEventsCriteria? roomEvents;
    3358             : }
    3359             : 
    3360             : /// The results for a particular group value.
    3361             : @_NameSource('spec')
    3362             : class GroupValue {
    3363           0 :   GroupValue({
    3364             :     this.nextBatch,
    3365             :     this.order,
    3366             :     this.results,
    3367             :   });
    3368             : 
    3369           0 :   GroupValue.fromJson(Map<String, Object?> json)
    3370           0 :       : nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
    3371           0 :         order = ((v) => v != null ? v as int : null)(json['order']),
    3372           0 :         results = ((v) => v != null
    3373           0 :             ? (v as List).map((v) => v as String).toList()
    3374           0 :             : null)(json['results']);
    3375           0 :   Map<String, Object?> toJson() {
    3376           0 :     final nextBatch = this.nextBatch;
    3377           0 :     final order = this.order;
    3378           0 :     final results = this.results;
    3379           0 :     return {
    3380           0 :       if (nextBatch != null) 'next_batch': nextBatch,
    3381           0 :       if (order != null) 'order': order,
    3382           0 :       if (results != null) 'results': results.map((v) => v).toList(),
    3383             :     };
    3384             :   }
    3385             : 
    3386             :   /// Token that can be used to get the next batch
    3387             :   /// of results in the group, by passing as the
    3388             :   /// `next_batch` parameter to the next call. If
    3389             :   /// this field is absent, there are no more
    3390             :   /// results in this group.
    3391             :   String? nextBatch;
    3392             : 
    3393             :   /// Key that can be used to order different
    3394             :   /// groups.
    3395             :   int? order;
    3396             : 
    3397             :   /// Which results are in this group.
    3398             :   List<String>? results;
    3399             : }
    3400             : 
    3401             : ///
    3402             : @_NameSource('spec')
    3403             : class UserProfile {
    3404           0 :   UserProfile({
    3405             :     this.avatarUrl,
    3406             :     this.displayname,
    3407             :   });
    3408             : 
    3409           0 :   UserProfile.fromJson(Map<String, Object?> json)
    3410           0 :       : avatarUrl = ((v) =>
    3411           0 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
    3412             :         displayname =
    3413           0 :             ((v) => v != null ? v as String : null)(json['displayname']);
    3414           0 :   Map<String, Object?> toJson() {
    3415           0 :     final avatarUrl = this.avatarUrl;
    3416           0 :     final displayname = this.displayname;
    3417           0 :     return {
    3418           0 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
    3419           0 :       if (displayname != null) 'displayname': displayname,
    3420             :     };
    3421             :   }
    3422             : 
    3423             :   ///
    3424             :   Uri? avatarUrl;
    3425             : 
    3426             :   ///
    3427             :   String? displayname;
    3428             : }
    3429             : 
    3430             : ///
    3431             : @_NameSource('rule override spec')
    3432             : class SearchResultsEventContext {
    3433           0 :   SearchResultsEventContext({
    3434             :     this.end,
    3435             :     this.eventsAfter,
    3436             :     this.eventsBefore,
    3437             :     this.profileInfo,
    3438             :     this.start,
    3439             :   });
    3440             : 
    3441           0 :   SearchResultsEventContext.fromJson(Map<String, Object?> json)
    3442           0 :       : end = ((v) => v != null ? v as String : null)(json['end']),
    3443           0 :         eventsAfter = ((v) => v != null
    3444             :             ? (v as List)
    3445           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    3446           0 :                 .toList()
    3447           0 :             : null)(json['events_after']),
    3448           0 :         eventsBefore = ((v) => v != null
    3449             :             ? (v as List)
    3450           0 :                 .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    3451           0 :                 .toList()
    3452           0 :             : null)(json['events_before']),
    3453           0 :         profileInfo = ((v) => v != null
    3454           0 :             ? (v as Map<String, Object?>).map((k, v) =>
    3455           0 :                 MapEntry(k, UserProfile.fromJson(v as Map<String, Object?>)))
    3456           0 :             : null)(json['profile_info']),
    3457           0 :         start = ((v) => v != null ? v as String : null)(json['start']);
    3458           0 :   Map<String, Object?> toJson() {
    3459           0 :     final end = this.end;
    3460           0 :     final eventsAfter = this.eventsAfter;
    3461           0 :     final eventsBefore = this.eventsBefore;
    3462           0 :     final profileInfo = this.profileInfo;
    3463           0 :     final start = this.start;
    3464           0 :     return {
    3465           0 :       if (end != null) 'end': end,
    3466             :       if (eventsAfter != null)
    3467           0 :         'events_after': eventsAfter.map((v) => v.toJson()).toList(),
    3468             :       if (eventsBefore != null)
    3469           0 :         'events_before': eventsBefore.map((v) => v.toJson()).toList(),
    3470             :       if (profileInfo != null)
    3471           0 :         'profile_info': profileInfo.map((k, v) => MapEntry(k, v.toJson())),
    3472           0 :       if (start != null) 'start': start,
    3473             :     };
    3474             :   }
    3475             : 
    3476             :   /// Pagination token for the end of the chunk
    3477             :   String? end;
    3478             : 
    3479             :   /// Events just after the result.
    3480             :   List<MatrixEvent>? eventsAfter;
    3481             : 
    3482             :   /// Events just before the result.
    3483             :   List<MatrixEvent>? eventsBefore;
    3484             : 
    3485             :   /// The historic profile information of the
    3486             :   /// users that sent the events returned.
    3487             :   ///
    3488             :   /// The key is the user ID for which
    3489             :   /// the profile belongs to.
    3490             :   Map<String, UserProfile>? profileInfo;
    3491             : 
    3492             :   /// Pagination token for the start of the chunk
    3493             :   String? start;
    3494             : }
    3495             : 
    3496             : /// The result object.
    3497             : @_NameSource('spec')
    3498             : class Result {
    3499           0 :   Result({
    3500             :     this.context,
    3501             :     this.rank,
    3502             :     this.result,
    3503             :   });
    3504             : 
    3505           0 :   Result.fromJson(Map<String, Object?> json)
    3506           0 :       : context = ((v) => v != null
    3507           0 :             ? SearchResultsEventContext.fromJson(v as Map<String, Object?>)
    3508           0 :             : null)(json['context']),
    3509           0 :         rank = ((v) => v != null ? (v as num).toDouble() : null)(json['rank']),
    3510           0 :         result = ((v) => v != null
    3511           0 :             ? MatrixEvent.fromJson(v as Map<String, Object?>)
    3512           0 :             : null)(json['result']);
    3513           0 :   Map<String, Object?> toJson() {
    3514           0 :     final context = this.context;
    3515           0 :     final rank = this.rank;
    3516           0 :     final result = this.result;
    3517           0 :     return {
    3518           0 :       if (context != null) 'context': context.toJson(),
    3519           0 :       if (rank != null) 'rank': rank,
    3520           0 :       if (result != null) 'result': result.toJson(),
    3521             :     };
    3522             :   }
    3523             : 
    3524             :   /// Context for result, if requested.
    3525             :   SearchResultsEventContext? context;
    3526             : 
    3527             :   /// A number that describes how closely this result matches the search. Higher is closer.
    3528             :   double? rank;
    3529             : 
    3530             :   /// The event that matched.
    3531             :   MatrixEvent? result;
    3532             : }
    3533             : 
    3534             : ///
    3535             : @_NameSource('spec')
    3536             : class ResultRoomEvents {
    3537           0 :   ResultRoomEvents({
    3538             :     this.count,
    3539             :     this.groups,
    3540             :     this.highlights,
    3541             :     this.nextBatch,
    3542             :     this.results,
    3543             :     this.state,
    3544             :   });
    3545             : 
    3546           0 :   ResultRoomEvents.fromJson(Map<String, Object?> json)
    3547           0 :       : count = ((v) => v != null ? v as int : null)(json['count']),
    3548           0 :         groups = ((v) => v != null
    3549           0 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    3550             :                 k,
    3551           0 :                 (v as Map<String, Object?>).map((k, v) => MapEntry(
    3552           0 :                     k, GroupValue.fromJson(v as Map<String, Object?>)))))
    3553           0 :             : null)(json['groups']),
    3554           0 :         highlights = ((v) => v != null
    3555           0 :             ? (v as List).map((v) => v as String).toList()
    3556           0 :             : null)(json['highlights']),
    3557           0 :         nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']),
    3558           0 :         results = ((v) => v != null
    3559             :             ? (v as List)
    3560           0 :                 .map((v) => Result.fromJson(v as Map<String, Object?>))
    3561           0 :                 .toList()
    3562           0 :             : null)(json['results']),
    3563           0 :         state = ((v) => v != null
    3564           0 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(
    3565             :                 k,
    3566             :                 (v as List)
    3567           0 :                     .map((v) => MatrixEvent.fromJson(v as Map<String, Object?>))
    3568           0 :                     .toList()))
    3569           0 :             : null)(json['state']);
    3570           0 :   Map<String, Object?> toJson() {
    3571           0 :     final count = this.count;
    3572           0 :     final groups = this.groups;
    3573           0 :     final highlights = this.highlights;
    3574           0 :     final nextBatch = this.nextBatch;
    3575           0 :     final results = this.results;
    3576           0 :     final state = this.state;
    3577           0 :     return {
    3578           0 :       if (count != null) 'count': count,
    3579             :       if (groups != null)
    3580           0 :         'groups': groups.map(
    3581           0 :             (k, v) => MapEntry(k, v.map((k, v) => MapEntry(k, v.toJson())))),
    3582           0 :       if (highlights != null) 'highlights': highlights.map((v) => v).toList(),
    3583           0 :       if (nextBatch != null) 'next_batch': nextBatch,
    3584           0 :       if (results != null) 'results': results.map((v) => v.toJson()).toList(),
    3585             :       if (state != null)
    3586           0 :         'state':
    3587           0 :             state.map((k, v) => MapEntry(k, v.map((v) => v.toJson()).toList())),
    3588             :     };
    3589             :   }
    3590             : 
    3591             :   /// An approximate count of the total number of results found.
    3592             :   int? count;
    3593             : 
    3594             :   /// Any groups that were requested.
    3595             :   ///
    3596             :   /// The outer `string` key is the group key requested (eg: `room_id`
    3597             :   /// or `sender`). The inner `string` key is the grouped value (eg:
    3598             :   /// a room's ID or a user's ID).
    3599             :   Map<String, Map<String, GroupValue>>? groups;
    3600             : 
    3601             :   /// List of words which should be highlighted, useful for stemming which may change the query terms.
    3602             :   List<String>? highlights;
    3603             : 
    3604             :   /// Token that can be used to get the next batch of
    3605             :   /// results, by passing as the `next_batch` parameter to
    3606             :   /// the next call. If this field is absent, there are no
    3607             :   /// more results.
    3608             :   String? nextBatch;
    3609             : 
    3610             :   /// List of results in the requested order.
    3611             :   List<Result>? results;
    3612             : 
    3613             :   /// The current state for every room in the results.
    3614             :   /// This is included if the request had the
    3615             :   /// `include_state` key set with a value of `true`.
    3616             :   ///
    3617             :   /// The key is the room ID for which the `State
    3618             :   /// Event` array belongs to.
    3619             :   Map<String, List<MatrixEvent>>? state;
    3620             : }
    3621             : 
    3622             : ///
    3623             : @_NameSource('spec')
    3624             : class ResultCategories {
    3625           0 :   ResultCategories({
    3626             :     this.roomEvents,
    3627             :   });
    3628             : 
    3629           0 :   ResultCategories.fromJson(Map<String, Object?> json)
    3630           0 :       : roomEvents = ((v) => v != null
    3631           0 :             ? ResultRoomEvents.fromJson(v as Map<String, Object?>)
    3632           0 :             : null)(json['room_events']);
    3633           0 :   Map<String, Object?> toJson() {
    3634           0 :     final roomEvents = this.roomEvents;
    3635           0 :     return {
    3636           0 :       if (roomEvents != null) 'room_events': roomEvents.toJson(),
    3637             :     };
    3638             :   }
    3639             : 
    3640             :   /// Mapping of category name to search criteria.
    3641             :   ResultRoomEvents? roomEvents;
    3642             : }
    3643             : 
    3644             : ///
    3645             : @_NameSource('rule override spec')
    3646             : class SearchResults {
    3647           0 :   SearchResults({
    3648             :     required this.searchCategories,
    3649             :   });
    3650             : 
    3651           0 :   SearchResults.fromJson(Map<String, Object?> json)
    3652           0 :       : searchCategories = ResultCategories.fromJson(
    3653           0 :             json['search_categories'] as Map<String, Object?>);
    3654           0 :   Map<String, Object?> toJson() => {
    3655           0 :         'search_categories': searchCategories.toJson(),
    3656             :       };
    3657             : 
    3658             :   /// Describes which categories to search in and their criteria.
    3659             :   ResultCategories searchCategories;
    3660             : }
    3661             : 
    3662             : ///
    3663             : @_NameSource('spec')
    3664             : class Location {
    3665           0 :   Location({
    3666             :     required this.alias,
    3667             :     required this.fields,
    3668             :     required this.protocol,
    3669             :   });
    3670             : 
    3671           0 :   Location.fromJson(Map<String, Object?> json)
    3672           0 :       : alias = json['alias'] as String,
    3673           0 :         fields = json['fields'] as Map<String, Object?>,
    3674           0 :         protocol = json['protocol'] as String;
    3675           0 :   Map<String, Object?> toJson() => {
    3676           0 :         'alias': alias,
    3677           0 :         'fields': fields,
    3678           0 :         'protocol': protocol,
    3679             :       };
    3680             : 
    3681             :   /// An alias for a matrix room.
    3682             :   String alias;
    3683             : 
    3684             :   /// Information used to identify this third-party location.
    3685             :   Map<String, Object?> fields;
    3686             : 
    3687             :   /// The protocol ID that the third-party location is a part of.
    3688             :   String protocol;
    3689             : }
    3690             : 
    3691             : /// Definition of valid values for a field.
    3692             : @_NameSource('spec')
    3693             : class FieldType {
    3694           0 :   FieldType({
    3695             :     required this.placeholder,
    3696             :     required this.regexp,
    3697             :   });
    3698             : 
    3699           0 :   FieldType.fromJson(Map<String, Object?> json)
    3700           0 :       : placeholder = json['placeholder'] as String,
    3701           0 :         regexp = json['regexp'] as String;
    3702           0 :   Map<String, Object?> toJson() => {
    3703           0 :         'placeholder': placeholder,
    3704           0 :         'regexp': regexp,
    3705             :       };
    3706             : 
    3707             :   /// An placeholder serving as a valid example of the field value.
    3708             :   String placeholder;
    3709             : 
    3710             :   /// A regular expression for validation of a field's value. This may be relatively
    3711             :   /// coarse to verify the value as the application service providing this protocol
    3712             :   /// may apply additional validation or filtering.
    3713             :   String regexp;
    3714             : }
    3715             : 
    3716             : ///
    3717             : @_NameSource('spec')
    3718             : class ProtocolInstance {
    3719           0 :   ProtocolInstance({
    3720             :     required this.desc,
    3721             :     required this.fields,
    3722             :     this.icon,
    3723             :     required this.networkId,
    3724             :   });
    3725             : 
    3726           0 :   ProtocolInstance.fromJson(Map<String, Object?> json)
    3727           0 :       : desc = json['desc'] as String,
    3728           0 :         fields = json['fields'] as Map<String, Object?>,
    3729           0 :         icon = ((v) => v != null ? v as String : null)(json['icon']),
    3730           0 :         networkId = json['network_id'] as String;
    3731           0 :   Map<String, Object?> toJson() {
    3732           0 :     final icon = this.icon;
    3733           0 :     return {
    3734           0 :       'desc': desc,
    3735           0 :       'fields': fields,
    3736           0 :       if (icon != null) 'icon': icon,
    3737           0 :       'network_id': networkId,
    3738             :     };
    3739             :   }
    3740             : 
    3741             :   /// A human-readable description for the protocol, such as the name.
    3742             :   String desc;
    3743             : 
    3744             :   /// Preset values for `fields` the client may use to search by.
    3745             :   Map<String, Object?> fields;
    3746             : 
    3747             :   /// An optional content URI representing the protocol. Overrides the one provided
    3748             :   /// at the higher level Protocol object.
    3749             :   String? icon;
    3750             : 
    3751             :   /// A unique identifier across all instances.
    3752             :   String networkId;
    3753             : }
    3754             : 
    3755             : ///
    3756             : @_NameSource('spec')
    3757             : class Protocol {
    3758           0 :   Protocol({
    3759             :     required this.fieldTypes,
    3760             :     required this.icon,
    3761             :     required this.instances,
    3762             :     required this.locationFields,
    3763             :     required this.userFields,
    3764             :   });
    3765             : 
    3766           0 :   Protocol.fromJson(Map<String, Object?> json)
    3767           0 :       : fieldTypes = (json['field_types'] as Map<String, Object?>).map((k, v) =>
    3768           0 :             MapEntry(k, FieldType.fromJson(v as Map<String, Object?>))),
    3769           0 :         icon = json['icon'] as String,
    3770           0 :         instances = (json['instances'] as List)
    3771           0 :             .map((v) => ProtocolInstance.fromJson(v as Map<String, Object?>))
    3772           0 :             .toList(),
    3773             :         locationFields =
    3774           0 :             (json['location_fields'] as List).map((v) => v as String).toList(),
    3775             :         userFields =
    3776           0 :             (json['user_fields'] as List).map((v) => v as String).toList();
    3777           0 :   Map<String, Object?> toJson() => {
    3778           0 :         'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())),
    3779           0 :         'icon': icon,
    3780           0 :         'instances': instances.map((v) => v.toJson()).toList(),
    3781           0 :         'location_fields': locationFields.map((v) => v).toList(),
    3782           0 :         'user_fields': userFields.map((v) => v).toList(),
    3783             :       };
    3784             : 
    3785             :   /// The type definitions for the fields defined in the `user_fields` and
    3786             :   /// `location_fields`. Each entry in those arrays MUST have an entry here. The
    3787             :   /// `string` key for this object is field name itself.
    3788             :   ///
    3789             :   /// May be an empty object if no fields are defined.
    3790             :   Map<String, FieldType> fieldTypes;
    3791             : 
    3792             :   /// A content URI representing an icon for the third-party protocol.
    3793             :   String icon;
    3794             : 
    3795             :   /// A list of objects representing independent instances of configuration.
    3796             :   /// For example, multiple networks on IRC if multiple are provided by the
    3797             :   /// same application service.
    3798             :   List<ProtocolInstance> instances;
    3799             : 
    3800             :   /// Fields which may be used to identify a third-party location. These should be
    3801             :   /// ordered to suggest the way that entities may be grouped, where higher
    3802             :   /// groupings are ordered first. For example, the name of a network should be
    3803             :   /// searched before the name of a channel.
    3804             :   List<String> locationFields;
    3805             : 
    3806             :   /// Fields which may be used to identify a third-party user. These should be
    3807             :   /// ordered to suggest the way that entities may be grouped, where higher
    3808             :   /// groupings are ordered first. For example, the name of a network should be
    3809             :   /// searched before the nickname of a user.
    3810             :   List<String> userFields;
    3811             : }
    3812             : 
    3813             : ///
    3814             : @_NameSource('rule override spec')
    3815             : class ThirdPartyUser {
    3816           0 :   ThirdPartyUser({
    3817             :     required this.fields,
    3818             :     required this.protocol,
    3819             :     required this.userid,
    3820             :   });
    3821             : 
    3822           0 :   ThirdPartyUser.fromJson(Map<String, Object?> json)
    3823           0 :       : fields = json['fields'] as Map<String, Object?>,
    3824           0 :         protocol = json['protocol'] as String,
    3825           0 :         userid = json['userid'] as String;
    3826           0 :   Map<String, Object?> toJson() => {
    3827           0 :         'fields': fields,
    3828           0 :         'protocol': protocol,
    3829           0 :         'userid': userid,
    3830             :       };
    3831             : 
    3832             :   /// Information used to identify this third-party location.
    3833             :   Map<String, Object?> fields;
    3834             : 
    3835             :   /// The protocol ID that the third-party location is a part of.
    3836             :   String protocol;
    3837             : 
    3838             :   /// A Matrix User ID represting a third-party user.
    3839             :   String userid;
    3840             : }
    3841             : 
    3842             : ///
    3843             : @_NameSource('generated')
    3844             : @EnhancedEnum()
    3845             : enum EventFormat {
    3846             :   @EnhancedEnumValue(name: 'client')
    3847             :   client,
    3848             :   @EnhancedEnumValue(name: 'federation')
    3849             :   federation
    3850             : }
    3851             : 
    3852             : ///
    3853             : @_NameSource('rule override generated')
    3854             : class StateFilter implements EventFilter, RoomEventFilter {
    3855          39 :   StateFilter({
    3856             :     this.limit,
    3857             :     this.notSenders,
    3858             :     this.notTypes,
    3859             :     this.senders,
    3860             :     this.types,
    3861             :     this.containsUrl,
    3862             :     this.includeRedundantMembers,
    3863             :     this.lazyLoadMembers,
    3864             :     this.notRooms,
    3865             :     this.rooms,
    3866             :     this.unreadThreadNotifications,
    3867             :   });
    3868             : 
    3869           0 :   StateFilter.fromJson(Map<String, Object?> json)
    3870           0 :       : limit = ((v) => v != null ? v as int : null)(json['limit']),
    3871           0 :         notSenders = ((v) => v != null
    3872           0 :             ? (v as List).map((v) => v as String).toList()
    3873           0 :             : null)(json['not_senders']),
    3874           0 :         notTypes = ((v) => v != null
    3875           0 :             ? (v as List).map((v) => v as String).toList()
    3876           0 :             : null)(json['not_types']),
    3877           0 :         senders = ((v) => v != null
    3878           0 :             ? (v as List).map((v) => v as String).toList()
    3879           0 :             : null)(json['senders']),
    3880           0 :         types = ((v) => v != null
    3881           0 :             ? (v as List).map((v) => v as String).toList()
    3882           0 :             : null)(json['types']),
    3883             :         containsUrl =
    3884           0 :             ((v) => v != null ? v as bool : null)(json['contains_url']),
    3885           0 :         includeRedundantMembers = ((v) =>
    3886           0 :             v != null ? v as bool : null)(json['include_redundant_members']),
    3887             :         lazyLoadMembers =
    3888           0 :             ((v) => v != null ? v as bool : null)(json['lazy_load_members']),
    3889           0 :         notRooms = ((v) => v != null
    3890           0 :             ? (v as List).map((v) => v as String).toList()
    3891           0 :             : null)(json['not_rooms']),
    3892           0 :         rooms = ((v) => v != null
    3893           0 :             ? (v as List).map((v) => v as String).toList()
    3894           0 :             : null)(json['rooms']),
    3895           0 :         unreadThreadNotifications = ((v) =>
    3896           0 :             v != null ? v as bool : null)(json['unread_thread_notifications']);
    3897          32 :   @override
    3898             :   Map<String, Object?> toJson() {
    3899          32 :     final limit = this.limit;
    3900          32 :     final notSenders = this.notSenders;
    3901          32 :     final notTypes = this.notTypes;
    3902          32 :     final senders = this.senders;
    3903          32 :     final types = this.types;
    3904          32 :     final containsUrl = this.containsUrl;
    3905          32 :     final includeRedundantMembers = this.includeRedundantMembers;
    3906          32 :     final lazyLoadMembers = this.lazyLoadMembers;
    3907          32 :     final notRooms = this.notRooms;
    3908          32 :     final rooms = this.rooms;
    3909          32 :     final unreadThreadNotifications = this.unreadThreadNotifications;
    3910          32 :     return {
    3911           3 :       if (limit != null) 'limit': limit,
    3912           0 :       if (notSenders != null) 'not_senders': notSenders.map((v) => v).toList(),
    3913           0 :       if (notTypes != null) 'not_types': notTypes.map((v) => v).toList(),
    3914           0 :       if (senders != null) 'senders': senders.map((v) => v).toList(),
    3915           0 :       if (types != null) 'types': types.map((v) => v).toList(),
    3916           0 :       if (containsUrl != null) 'contains_url': containsUrl,
    3917             :       if (includeRedundantMembers != null)
    3918           0 :         'include_redundant_members': includeRedundantMembers,
    3919          32 :       if (lazyLoadMembers != null) 'lazy_load_members': lazyLoadMembers,
    3920           0 :       if (notRooms != null) 'not_rooms': notRooms.map((v) => v).toList(),
    3921           0 :       if (rooms != null) 'rooms': rooms.map((v) => v).toList(),
    3922             :       if (unreadThreadNotifications != null)
    3923           0 :         'unread_thread_notifications': unreadThreadNotifications,
    3924             :     };
    3925             :   }
    3926             : 
    3927             :   /// The maximum number of events to return, must be an integer greater than 0.
    3928             :   ///
    3929             :   /// Servers should apply a default value, and impose a maximum value to avoid
    3930             :   /// resource exhaustion.
    3931             :   ///
    3932             :   @override
    3933             :   int? limit;
    3934             : 
    3935             :   /// A list of sender IDs to exclude. If this list is absent then no senders are excluded. A matching sender will be excluded even if it is listed in the `'senders'` filter.
    3936             :   @override
    3937             :   List<String>? notSenders;
    3938             : 
    3939             :   /// A list of event types to exclude. If this list is absent then no event types are excluded. A matching type will be excluded even if it is listed in the `'types'` filter. A '*' can be used as a wildcard to match any sequence of characters.
    3940             :   @override
    3941             :   List<String>? notTypes;
    3942             : 
    3943             :   /// A list of senders IDs to include. If this list is absent then all senders are included.
    3944             :   @override
    3945             :   List<String>? senders;
    3946             : 
    3947             :   /// A list of event types to include. If this list is absent then all event types are included. A `'*'` can be used as a wildcard to match any sequence of characters.
    3948             :   @override
    3949             :   List<String>? types;
    3950             : 
    3951             :   /// If `true`, includes only events with a `url` key in their content. If `false`, excludes those events. If omitted, `url` key is not considered for filtering.
    3952             :   @override
    3953             :   bool? containsUrl;
    3954             : 
    3955             :   /// If `true`, sends all membership events for all events, even if they have already
    3956             :   /// been sent to the client. Does not
    3957             :   /// apply unless `lazy_load_members` is `true`. See
    3958             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3959             :   /// for more information. Defaults to `false`.
    3960             :   @override
    3961             :   bool? includeRedundantMembers;
    3962             : 
    3963             :   /// If `true`, enables lazy-loading of membership events. See
    3964             :   /// [Lazy-loading room members](https://spec.matrix.org/unstable/client-server-api/#lazy-loading-room-members)
    3965             :   /// for more information. Defaults to `false`.
    3966             :   @override
    3967             :   bool? lazyLoadMembers;
    3968             : 
    3969             :   /// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the `'rooms'` filter.
    3970             :   @override
    3971             :   List<String>? notRooms;
    3972             : 
    3973             :   /// A list of room IDs to include. If this list is absent then all rooms are included.
    3974             :   @override
    3975             :   List<String>? rooms;
    3976             : 
    3977             :   /// If `true`, enables per-[thread](https://spec.matrix.org/unstable/client-server-api/#threading) notification
    3978             :   /// counts. Only applies to the `/sync` endpoint. Defaults to `false`.
    3979             :   @override
    3980             :   bool? unreadThreadNotifications;
    3981             : }
    3982             : 
    3983             : ///
    3984             : @_NameSource('spec')
    3985             : class RoomFilter {
    3986          39 :   RoomFilter({
    3987             :     this.accountData,
    3988             :     this.ephemeral,
    3989             :     this.includeLeave,
    3990             :     this.notRooms,
    3991             :     this.rooms,
    3992             :     this.state,
    3993             :     this.timeline,
    3994             :   });
    3995             : 
    3996           0 :   RoomFilter.fromJson(Map<String, Object?> json)
    3997           0 :       : accountData = ((v) => v != null
    3998           0 :             ? StateFilter.fromJson(v as Map<String, Object?>)
    3999           0 :             : null)(json['account_data']),
    4000           0 :         ephemeral = ((v) => v != null
    4001           0 :             ? StateFilter.fromJson(v as Map<String, Object?>)
    4002           0 :             : null)(json['ephemeral']),
    4003             :         includeLeave =
    4004           0 :             ((v) => v != null ? v as bool : null)(json['include_leave']),
    4005           0 :         notRooms = ((v) => v != null
    4006           0 :             ? (v as List).map((v) => v as String).toList()
    4007           0 :             : null)(json['not_rooms']),
    4008           0 :         rooms = ((v) => v != null
    4009           0 :             ? (v as List).map((v) => v as String).toList()
    4010           0 :             : null)(json['rooms']),
    4011           0 :         state = ((v) => v != null
    4012           0 :             ? StateFilter.fromJson(v as Map<String, Object?>)
    4013           0 :             : null)(json['state']),
    4014           0 :         timeline = ((v) => v != null
    4015           0 :             ? StateFilter.fromJson(v as Map<String, Object?>)
    4016           0 :             : null)(json['timeline']);
    4017          32 :   Map<String, Object?> toJson() {
    4018          32 :     final accountData = this.accountData;
    4019          32 :     final ephemeral = this.ephemeral;
    4020          32 :     final includeLeave = this.includeLeave;
    4021          32 :     final notRooms = this.notRooms;
    4022          32 :     final rooms = this.rooms;
    4023          32 :     final state = this.state;
    4024          32 :     final timeline = this.timeline;
    4025          32 :     return {
    4026           0 :       if (accountData != null) 'account_data': accountData.toJson(),
    4027           0 :       if (ephemeral != null) 'ephemeral': ephemeral.toJson(),
    4028           3 :       if (includeLeave != null) 'include_leave': includeLeave,
    4029           0 :       if (notRooms != null) 'not_rooms': notRooms.map((v) => v).toList(),
    4030           0 :       if (rooms != null) 'rooms': rooms.map((v) => v).toList(),
    4031          64 :       if (state != null) 'state': state.toJson(),
    4032           6 :       if (timeline != null) 'timeline': timeline.toJson(),
    4033             :     };
    4034             :   }
    4035             : 
    4036             :   /// The per user account data to include for rooms.
    4037             :   StateFilter? accountData;
    4038             : 
    4039             :   /// The ephemeral events to include for rooms. These are the events that appear in the `ephemeral` property in the `/sync` response.
    4040             :   StateFilter? ephemeral;
    4041             : 
    4042             :   /// Include rooms that the user has left in the sync, default false
    4043             :   bool? includeLeave;
    4044             : 
    4045             :   /// A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching room will be excluded even if it is listed in the `'rooms'` filter. This filter is applied before the filters in `ephemeral`, `state`, `timeline` or `account_data`
    4046             :   List<String>? notRooms;
    4047             : 
    4048             :   /// A list of room IDs to include. If this list is absent then all rooms are included. This filter is applied before the filters in `ephemeral`, `state`, `timeline` or `account_data`
    4049             :   List<String>? rooms;
    4050             : 
    4051             :   /// The state events to include for rooms.
    4052             :   StateFilter? state;
    4053             : 
    4054             :   /// The message and state update events to include for rooms.
    4055             :   StateFilter? timeline;
    4056             : }
    4057             : 
    4058             : ///
    4059             : @_NameSource('spec')
    4060             : class Filter {
    4061          39 :   Filter({
    4062             :     this.accountData,
    4063             :     this.eventFields,
    4064             :     this.eventFormat,
    4065             :     this.presence,
    4066             :     this.room,
    4067             :   });
    4068             : 
    4069           0 :   Filter.fromJson(Map<String, Object?> json)
    4070           0 :       : accountData = ((v) => v != null
    4071           0 :             ? EventFilter.fromJson(v as Map<String, Object?>)
    4072           0 :             : null)(json['account_data']),
    4073           0 :         eventFields = ((v) => v != null
    4074           0 :             ? (v as List).map((v) => v as String).toList()
    4075           0 :             : null)(json['event_fields']),
    4076           0 :         eventFormat = ((v) => v != null
    4077           0 :             ? EventFormat.values.fromString(v as String)!
    4078           0 :             : null)(json['event_format']),
    4079           0 :         presence = ((v) => v != null
    4080           0 :             ? EventFilter.fromJson(v as Map<String, Object?>)
    4081           0 :             : null)(json['presence']),
    4082           0 :         room = ((v) => v != null
    4083           0 :             ? RoomFilter.fromJson(v as Map<String, Object?>)
    4084           0 :             : null)(json['room']);
    4085          32 :   Map<String, Object?> toJson() {
    4086          32 :     final accountData = this.accountData;
    4087          32 :     final eventFields = this.eventFields;
    4088          32 :     final eventFormat = this.eventFormat;
    4089          32 :     final presence = this.presence;
    4090          32 :     final room = this.room;
    4091          32 :     return {
    4092           0 :       if (accountData != null) 'account_data': accountData.toJson(),
    4093             :       if (eventFields != null)
    4094           0 :         'event_fields': eventFields.map((v) => v).toList(),
    4095           0 :       if (eventFormat != null) 'event_format': eventFormat.name,
    4096           0 :       if (presence != null) 'presence': presence.toJson(),
    4097          64 :       if (room != null) 'room': room.toJson(),
    4098             :     };
    4099             :   }
    4100             : 
    4101             :   /// The user account data that isn't associated with rooms to include.
    4102             :   EventFilter? accountData;
    4103             : 
    4104             :   /// List of event fields to include. If this list is absent then all fields are included. The entries are [dot-separated paths for each property](https://spec.matrix.org/unstable/appendices#dot-separated-property-paths) to include. So ['content.body'] will include the 'body' field of the 'content' object. A server may include more fields than were requested.
    4105             :   List<String>? eventFields;
    4106             : 
    4107             :   /// The format to use for events. 'client' will return the events in a format suitable for clients. 'federation' will return the raw event as received over federation. The default is 'client'.
    4108             :   EventFormat? eventFormat;
    4109             : 
    4110             :   /// The presence updates to include.
    4111             :   EventFilter? presence;
    4112             : 
    4113             :   /// Filters to be applied to room data.
    4114             :   RoomFilter? room;
    4115             : }
    4116             : 
    4117             : ///
    4118             : @_NameSource('spec')
    4119             : class OpenIdCredentials {
    4120           0 :   OpenIdCredentials({
    4121             :     required this.accessToken,
    4122             :     required this.expiresIn,
    4123             :     required this.matrixServerName,
    4124             :     required this.tokenType,
    4125             :   });
    4126             : 
    4127           0 :   OpenIdCredentials.fromJson(Map<String, Object?> json)
    4128           0 :       : accessToken = json['access_token'] as String,
    4129           0 :         expiresIn = json['expires_in'] as int,
    4130           0 :         matrixServerName = json['matrix_server_name'] as String,
    4131           0 :         tokenType = json['token_type'] as String;
    4132           0 :   Map<String, Object?> toJson() => {
    4133           0 :         'access_token': accessToken,
    4134           0 :         'expires_in': expiresIn,
    4135           0 :         'matrix_server_name': matrixServerName,
    4136           0 :         'token_type': tokenType,
    4137             :       };
    4138             : 
    4139             :   /// An access token the consumer may use to verify the identity of
    4140             :   /// the person who generated the token. This is given to the federation
    4141             :   /// API `GET /openid/userinfo` to verify the user's identity.
    4142             :   String accessToken;
    4143             : 
    4144             :   /// The number of seconds before this token expires and a new one must
    4145             :   /// be generated.
    4146             :   int expiresIn;
    4147             : 
    4148             :   /// The homeserver domain the consumer should use when attempting to
    4149             :   /// verify the user's identity.
    4150             :   String matrixServerName;
    4151             : 
    4152             :   /// The string `Bearer`.
    4153             :   String tokenType;
    4154             : }
    4155             : 
    4156             : ///
    4157             : @_NameSource('spec')
    4158             : class Tag {
    4159          32 :   Tag({
    4160             :     this.order,
    4161             :     this.additionalProperties = const {},
    4162             :   });
    4163             : 
    4164           0 :   Tag.fromJson(Map<String, Object?> json)
    4165             :       : order =
    4166           0 :             ((v) => v != null ? (v as num).toDouble() : null)(json['order']),
    4167           0 :         additionalProperties = Map.fromEntries(json.entries
    4168           0 :             .where((e) => !['order'].contains(e.key))
    4169           0 :             .map((e) => MapEntry(e.key, e.value)));
    4170           2 :   Map<String, Object?> toJson() {
    4171           2 :     final order = this.order;
    4172           2 :     return {
    4173           2 :       ...additionalProperties,
    4174           2 :       if (order != null) 'order': order,
    4175             :     };
    4176             :   }
    4177             : 
    4178             :   /// A number in a range `[0,1]` describing a relative
    4179             :   /// position of the room under the given tag.
    4180             :   double? order;
    4181             : 
    4182             :   Map<String, Object?> additionalProperties;
    4183             : }
    4184             : 
    4185             : ///
    4186             : @_NameSource('rule override spec')
    4187             : class Profile {
    4188           1 :   Profile({
    4189             :     this.avatarUrl,
    4190             :     this.displayName,
    4191             :     required this.userId,
    4192             :   });
    4193             : 
    4194           0 :   Profile.fromJson(Map<String, Object?> json)
    4195           0 :       : avatarUrl = ((v) =>
    4196           0 :             v != null ? Uri.parse(v as String) : null)(json['avatar_url']),
    4197             :         displayName =
    4198           0 :             ((v) => v != null ? v as String : null)(json['display_name']),
    4199           0 :         userId = json['user_id'] as String;
    4200           0 :   Map<String, Object?> toJson() {
    4201           0 :     final avatarUrl = this.avatarUrl;
    4202           0 :     final displayName = this.displayName;
    4203           0 :     return {
    4204           0 :       if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
    4205           0 :       if (displayName != null) 'display_name': displayName,
    4206           0 :       'user_id': userId,
    4207             :     };
    4208             :   }
    4209             : 
    4210             :   /// The avatar url, as an [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris), if one exists.
    4211             :   Uri? avatarUrl;
    4212             : 
    4213             :   /// The display name of the user, if one exists.
    4214             :   String? displayName;
    4215             : 
    4216             :   /// The user's matrix user ID.
    4217             :   String userId;
    4218             : }
    4219             : 
    4220             : ///
    4221             : @_NameSource('generated')
    4222             : class SearchUserDirectoryResponse {
    4223           0 :   SearchUserDirectoryResponse({
    4224             :     required this.limited,
    4225             :     required this.results,
    4226             :   });
    4227             : 
    4228           0 :   SearchUserDirectoryResponse.fromJson(Map<String, Object?> json)
    4229           0 :       : limited = json['limited'] as bool,
    4230           0 :         results = (json['results'] as List)
    4231           0 :             .map((v) => Profile.fromJson(v as Map<String, Object?>))
    4232           0 :             .toList();
    4233           0 :   Map<String, Object?> toJson() => {
    4234           0 :         'limited': limited,
    4235           0 :         'results': results.map((v) => v.toJson()).toList(),
    4236             :       };
    4237             : 
    4238             :   /// Indicates if the result list has been truncated by the limit.
    4239             :   bool limited;
    4240             : 
    4241             :   /// Ordered by rank and then whether or not profile info is available.
    4242             :   List<Profile> results;
    4243             : }
    4244             : 
    4245             : ///
    4246             : @_NameSource('rule override generated')
    4247             : class TurnServerCredentials {
    4248           0 :   TurnServerCredentials({
    4249             :     required this.password,
    4250             :     required this.ttl,
    4251             :     required this.uris,
    4252             :     required this.username,
    4253             :   });
    4254             : 
    4255           2 :   TurnServerCredentials.fromJson(Map<String, Object?> json)
    4256           2 :       : password = json['password'] as String,
    4257           2 :         ttl = json['ttl'] as int,
    4258           8 :         uris = (json['uris'] as List).map((v) => v as String).toList(),
    4259           2 :         username = json['username'] as String;
    4260           0 :   Map<String, Object?> toJson() => {
    4261           0 :         'password': password,
    4262           0 :         'ttl': ttl,
    4263           0 :         'uris': uris.map((v) => v).toList(),
    4264           0 :         'username': username,
    4265             :       };
    4266             : 
    4267             :   /// The password to use.
    4268             :   String password;
    4269             : 
    4270             :   /// The time-to-live in seconds
    4271             :   int ttl;
    4272             : 
    4273             :   /// A list of TURN URIs
    4274             :   List<String> uris;
    4275             : 
    4276             :   /// The username to use.
    4277             :   String username;
    4278             : }
    4279             : 
    4280             : ///
    4281             : @_NameSource('generated')
    4282             : class GetVersionsResponse {
    4283           0 :   GetVersionsResponse({
    4284             :     this.unstableFeatures,
    4285             :     required this.versions,
    4286             :   });
    4287             : 
    4288          34 :   GetVersionsResponse.fromJson(Map<String, Object?> json)
    4289          34 :       : unstableFeatures = ((v) => v != null
    4290         102 :             ? (v as Map<String, Object?>).map((k, v) => MapEntry(k, v as bool))
    4291          68 :             : null)(json['unstable_features']),
    4292         136 :         versions = (json['versions'] as List).map((v) => v as String).toList();
    4293           0 :   Map<String, Object?> toJson() {
    4294           0 :     final unstableFeatures = this.unstableFeatures;
    4295           0 :     return {
    4296             :       if (unstableFeatures != null)
    4297           0 :         'unstable_features': unstableFeatures.map((k, v) => MapEntry(k, v)),
    4298           0 :       'versions': versions.map((v) => v).toList(),
    4299             :     };
    4300             :   }
    4301             : 
    4302             :   /// Experimental features the server supports. Features not listed here,
    4303             :   /// or the lack of this property all together, indicate that a feature is
    4304             :   /// not supported.
    4305             :   Map<String, bool>? unstableFeatures;
    4306             : 
    4307             :   /// The supported versions.
    4308             :   List<String> versions;
    4309             : }
    4310             : 
    4311             : ///
    4312             : @_NameSource('generated')
    4313             : class CreateContentResponse {
    4314           0 :   CreateContentResponse({
    4315             :     required this.contentUri,
    4316             :     this.unusedExpiresAt,
    4317             :   });
    4318             : 
    4319           0 :   CreateContentResponse.fromJson(Map<String, Object?> json)
    4320           0 :       : contentUri = ((json['content_uri'] as String).startsWith('mxc://')
    4321           0 :             ? Uri.parse(json['content_uri'] as String)
    4322           0 :             : throw Exception('Uri not an mxc URI')),
    4323             :         unusedExpiresAt =
    4324           0 :             ((v) => v != null ? v as int : null)(json['unused_expires_at']);
    4325           0 :   Map<String, Object?> toJson() {
    4326           0 :     final unusedExpiresAt = this.unusedExpiresAt;
    4327           0 :     return {
    4328           0 :       'content_uri': contentUri.toString(),
    4329           0 :       if (unusedExpiresAt != null) 'unused_expires_at': unusedExpiresAt,
    4330             :     };
    4331             :   }
    4332             : 
    4333             :   /// The [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris) at
    4334             :   /// which the content will be available, once it is uploaded.
    4335             :   Uri contentUri;
    4336             : 
    4337             :   /// The timestamp (in milliseconds since the unix epoch) when the
    4338             :   /// generated media id will expire, if media is not uploaded.
    4339             :   int? unusedExpiresAt;
    4340             : }

Generated by: LCOV version 1.14