diff --git a/lib/src/generated/api.dart b/lib/src/generated/api.dart index 89164749..77390b0f 100644 --- a/lib/src/generated/api.dart +++ b/lib/src/generated/api.dart @@ -40,7 +40,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return DiscoveryInformation.fromJson(json); + return DiscoveryInformation.fromJson(json as Map); } /// Queries the server to determine if a given registration token is still @@ -116,7 +116,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetSpaceHierarchyResponse.fromJson(json); + return GetSpaceHierarchyResponse.fromJson(json as Map); } /// Retrieve all of the child events for a given parent event. @@ -174,7 +174,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRelatingEventsResponse.fromJson(json); + return GetRelatingEventsResponse.fromJson(json as Map); } /// Retrieve all of the child events for a given parent event which relate to the parent @@ -235,7 +235,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRelatingEventsWithRelTypeResponse.fromJson(json); + return GetRelatingEventsWithRelTypeResponse.fromJson( + json as Map); } /// Retrieve all of the child events for a given parent event which relate to the parent @@ -302,7 +303,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRelatingEventsWithRelTypeAndEventTypeResponse.fromJson(json); + return GetRelatingEventsWithRelTypeAndEventTypeResponse.fromJson( + json as Map); } /// Paginates over the thread roots in a room, ordered by the `latest_event` of each thread root @@ -338,7 +340,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetThreadRootsResponse.fromJson(json); + return GetThreadRootsResponse.fromJson(json as Map); } /// Get the ID of the event closest to the given timestamp, in the @@ -387,7 +389,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetEventByTimestampResponse.fromJson(json); + return GetEventByTimestampResponse.fromJson(json as Map); } /// Gets a list of the third party identifiers that the homeserver has @@ -399,7 +401,8 @@ class Api { /// Identifiers in this list may be used by the homeserver as, for example, /// identifiers that it will accept to reset the user's account password. /// - /// returns `threepids` + /// returns `threepids`: + /// Future?> getAccount3PIDs() async { final requestUri = Uri(path: '_matrix/client/v3/account/3pid'); final request = Request('GET', baseUri!.resolveUri(requestUri)); @@ -410,7 +413,10 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as List).map((v) => ThirdPartyIdentifier.fromJson(v)).toList() + ? (v as List) + .map( + (v) => ThirdPartyIdentifier.fromJson(v as Map)) + .toList() : null)(json['threepids']); } @@ -454,7 +460,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ((v) => v != null ? Uri.parse(v) : null)(json['submit_url']); + return ((v) => + v != null ? Uri.parse(v as String) : null)(json['submit_url']); } /// This API endpoint uses the [User-Interactive Authentication API](https://spec.matrix.org/unstable/client-server-api/#user-interactive-authentication-api). @@ -566,7 +573,7 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return IdServerUnbindResult.values - .fromString(json['id_server_unbind_result'])!; + .fromString(json['id_server_unbind_result'] as String)!; } /// The homeserver must check that the given email address is **not** @@ -631,7 +638,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// The homeserver must check that the given phone number is **not** @@ -699,7 +706,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// Removes a user's third party identifier from the provided identity server @@ -742,7 +749,7 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return IdServerUnbindResult.values - .fromString(json['id_server_unbind_result'])!; + .fromString(json['id_server_unbind_result'] as String)!; } /// Deactivate the user's account, removing all ability for the user to @@ -794,7 +801,7 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return IdServerUnbindResult.values - .fromString(json['id_server_unbind_result'])!; + .fromString(json['id_server_unbind_result'] as String)!; } /// Changes the password for an account on this homeserver. @@ -908,7 +915,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// The homeserver must check that the given phone number **is @@ -983,7 +990,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// Gets information about the owner of a given access token. @@ -1003,7 +1010,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return TokenOwnerInfo.fromJson(json); + return TokenOwnerInfo.fromJson(json as Map); } /// Gets information about a particular user. @@ -1023,7 +1030,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return WhoIsInfo.fromJson(json); + return WhoIsInfo.fromJson(json as Map); } /// Gets information about the server's supported feature set @@ -1041,7 +1048,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return Capabilities.fromJson(json['capabilities']); + return Capabilities.fromJson(json['capabilities'] as Map); } /// Create a new room with various configuration options. @@ -1157,13 +1164,13 @@ class Api { /// returns `room_id`: /// The created room's ID. Future createRoom( - {Map? creationContent, + {Map? creationContent, List? initialState, List? invite, List? invite3pid, bool? isDirect, String? name, - Map? powerLevelContentOverride, + Map? powerLevelContentOverride, CreateRoomPreset? preset, String? roomAliasName, String? roomVersion, @@ -1238,7 +1245,9 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as List).map((v) => Device.fromJson(v)).toList() + ? (v as List) + .map((v) => Device.fromJson(v as Map)) + .toList() : null)(json['devices']); } @@ -1280,7 +1289,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return Device.fromJson(json); + return Device.fromJson(json as Map); } /// Updates the metadata on the given device. @@ -1324,7 +1333,7 @@ class Api { /// /// [visibility] Whether the room should be visible (public) in the directory /// or not (private). - Future> updateAppserviceRoomDirectoryVisibility( + Future> updateAppserviceRoomDirectoryVisibility( String networkId, String roomId, Visibility visibility) async { final requestUri = Uri( path: @@ -1340,7 +1349,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return json as Map; + return json as Map; } /// Gets the visibility of a given room on the server's public room directory. @@ -1359,8 +1368,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ((v) => v != null ? Visibility.values.fromString(v)! : null)( - json['visibility']); + return ((v) => v != null + ? Visibility.values.fromString(v as String)! + : null)(json['visibility']); } /// Sets the visibility of a given room in the server's public room @@ -1441,10 +1451,10 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRoomIdByAliasResponse.fromJson(json); + return GetRoomIdByAliasResponse.fromJson(json as Map); } - /// setRoomAlias + /// /// /// [roomAlias] The room alias to set. Its format is defined /// [in the appendices](https://spec.matrix.org/unstable/appendices/#room-aliases). @@ -1494,7 +1504,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetEventsResponse.fromJson(json); + return GetEventsResponse.fromJson(json as Map); } /// This will listen for new events related to a particular room and return @@ -1528,7 +1538,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return PeekEventsResponse.fromJson(json); + return PeekEventsResponse.fromJson(json as Map); } /// Get a single event based on `event_id`. You must have permission to @@ -1551,7 +1561,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return MatrixEvent.fromJson(json); + return MatrixEvent.fromJson(json as Map); } /// *Note that this API takes either a room ID or alias, unlike* `/rooms/{roomId}/join`. @@ -1654,7 +1664,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetKeysChangesResponse.fromJson(json); + return GetKeysChangesResponse.fromJson(json as Map); } /// Claims one-time keys for use in pre-key messages. @@ -1681,7 +1691,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ClaimKeysResponse.fromJson(json); + return ClaimKeysResponse.fromJson(json as Map); } /// Publishes cross-signing keys for the user. @@ -1756,7 +1766,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return QueryKeysResponse.fromJson(json); + return QueryKeysResponse.fromJson(json as Map); } /// Publishes cross-signing signatures for the user. The request body is a @@ -1768,9 +1778,9 @@ class Api { /// A map from user ID to key ID to an error for any signatures /// that failed. If a signature was invalid, the `errcode` will /// be set to `M_INVALID_SIGNATURE`. - Future>>?> + Future>>?> uploadCrossSigningSignatures( - Map>> signatures) async { + Map>> signatures) async { final requestUri = Uri(path: '_matrix/client/v3/keys/signatures/upload'); final request = Request('POST', baseUri!.resolveUri(requestUri)); request.headers['authorization'] = 'Bearer ${bearerToken!}'; @@ -1783,10 +1793,10 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as Map).map((k, v) => MapEntry( + ? (v as Map).map((k, v) => MapEntry( k, - (v as Map) - .map((k, v) => MapEntry(k, v as Map)))) + (v as Map) + .map((k, v) => MapEntry(k, v as Map)))) : null)(json['failures']); } @@ -1852,7 +1862,9 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as List).map((v) => LoginFlow.fromJson(v)).toList() + ? (v as List) + .map((v) => LoginFlow.fromJson(v as Map)) + .toList() : null)(json['flows']); } @@ -1924,7 +1936,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return LoginResponse.fromJson(json); + return LoginResponse.fromJson(json as Map); } /// Invalidates an existing access token, so that it can no longer be used for @@ -1991,7 +2003,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetNotificationsResponse.fromJson(json); + return GetNotificationsResponse.fromJson(json as Map); } /// Get the given user's presence state. @@ -2008,7 +2020,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetPresenceResponse.fromJson(json); + return GetPresenceResponse.fromJson(json as Map); } /// This API sets the given user's presence state. When setting the status, @@ -2056,7 +2068,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ProfileInformation.fromJson(json); + return ProfileInformation.fromJson(json as Map); } /// Get the user's avatar URL. This API may be used to fetch the user's @@ -2077,7 +2089,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']); + return ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']); } /// This API sets the given user's avatar URL. You must have permission to @@ -2177,7 +2190,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetPublicRoomsResponse.fromJson(json); + return GetPublicRoomsResponse.fromJson(json as Map); } /// Lists the public rooms on the server, with optional filter. @@ -2230,7 +2243,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return QueryPublicRoomsResponse.fromJson(json); + return QueryPublicRoomsResponse.fromJson(json as Map); } /// Gets all currently active pushers for the authenticated user. @@ -2247,7 +2260,9 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as List).map((v) => Pusher.fromJson(v)).toList() + ? (v as List) + .map((v) => Pusher.fromJson(v as Map)) + .toList() : null)(json['pushers']); } @@ -2267,7 +2282,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return PushRuleSet.fromJson(json['global']); + return PushRuleSet.fromJson(json['global'] as Map); } /// This endpoint removes the push rule defined in the path. @@ -2315,7 +2330,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return PushRule.fromJson(json); + return PushRule.fromJson(json as Map); } /// This endpoint allows the creation and modification of user defined push @@ -2361,7 +2376,7 @@ class Api { /// /// [pattern] Only applicable to `content` rules. The glob-style pattern to match against. Future setPushRule( - String scope, PushRuleKind kind, String ruleId, List actions, + String scope, PushRuleKind kind, String ruleId, List actions, {String? before, String? after, List? conditions, @@ -2403,7 +2418,7 @@ class Api { /// /// returns `actions`: /// The action(s) to perform for this rule. - Future> getPushRuleActions( + Future> getPushRuleActions( String scope, PushRuleKind kind, String ruleId) async { final requestUri = Uri( path: @@ -2415,7 +2430,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json['actions'] as List).map((v) => v as dynamic).toList(); + return (json['actions'] as List).map((v) => v as Object?).toList(); } /// This endpoint allows clients to change the actions of a push rule. @@ -2431,7 +2446,7 @@ class Api { /// /// [actions] The action(s) to perform for this rule. Future setPushRuleActions(String scope, PushRuleKind kind, - String ruleId, List actions) async { + String ruleId, List actions) async { final requestUri = Uri( path: '_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions'); @@ -2538,7 +2553,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RefreshResponse.fromJson(json); + return RefreshResponse.fromJson(json as Map); } /// This API endpoint uses the [User-Interactive Authentication API](https://spec.matrix.org/unstable/client-server-api/#user-interactive-authentication-api), except in @@ -2636,7 +2651,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RegisterResponse.fromJson(json); + return RegisterResponse.fromJson(json as Map); } /// Checks to see if a username is available, and valid, for the server. @@ -2729,7 +2744,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// The homeserver must check that the given phone number is **not** @@ -2793,7 +2808,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RequestTokenResponse.fromJson(json); + return RequestTokenResponse.fromJson(json as Map); } /// Delete the keys from the backup. @@ -2811,7 +2826,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Retrieve the keys from the backup. @@ -2829,7 +2844,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeys.fromJson(json); + return RoomKeys.fromJson(json as Map); } /// Store several keys in the backup. @@ -2852,7 +2867,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Delete the keys from the backup for a given room. @@ -2874,7 +2889,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Retrieve the keys from the backup for a given room. @@ -2896,7 +2911,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeyBackup.fromJson(json); + return RoomKeyBackup.fromJson(json as Map); } /// Store several keys in the backup for a given room. @@ -2922,7 +2937,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Delete a key from the backup. @@ -2947,7 +2962,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Retrieve a key from the backup. @@ -2972,7 +2987,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return KeyBackupData.fromJson(json); + return KeyBackupData.fromJson(json as Map); } /// Store a key in the backup. @@ -3001,7 +3016,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return RoomKeysUpdateResponse.fromJson(json); + return RoomKeysUpdateResponse.fromJson(json as Map); } /// Get information about the latest backup version. @@ -3014,7 +3029,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRoomKeysVersionCurrentResponse.fromJson(json); + return GetRoomKeysVersionCurrentResponse.fromJson( + json as Map); } /// Creates a new backup. @@ -3028,7 +3044,7 @@ class Api { /// returns `version`: /// The backup version. This is an opaque string. Future postRoomKeysVersion( - BackupAlgorithm algorithm, Map authData) async { + BackupAlgorithm algorithm, Map authData) async { final requestUri = Uri(path: '_matrix/client/v3/room_keys/version'); final request = Request('POST', baseUri!.resolveUri(requestUri)); request.headers['authorization'] = 'Bearer ${bearerToken!}'; @@ -3083,7 +3099,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRoomKeysVersionResponse.fromJson(json); + return GetRoomKeysVersionResponse.fromJson(json as Map); } /// Update information about an existing backup. Only `auth_data` can be modified. @@ -3099,8 +3115,8 @@ class Api { /// [authData] Algorithm-dependent data. See the documentation for the backup /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the /// expected format of the data. - Future> putRoomKeysVersion(String version, - BackupAlgorithm algorithm, Map authData) async { + Future> putRoomKeysVersion(String version, + BackupAlgorithm algorithm, Map authData) async { final requestUri = Uri( path: '_matrix/client/v3/room_keys/version/${Uri.encodeComponent(version)}'); @@ -3116,7 +3132,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return json as Map; + return json as Map; } /// Get a list of aliases maintained by the local server for the @@ -3221,7 +3237,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return EventContext.fromJson(json); + return EventContext.fromJson(json as Map); } /// Get a single event based on `roomId/eventId`. You must have permission to @@ -3241,7 +3257,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return MatrixEvent.fromJson(json); + return MatrixEvent.fromJson(json as Map); } /// This API stops a user remembering about a particular room. @@ -3443,8 +3459,8 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, RoomMember.fromJson(v))) + ? (v as Map).map((k, v) => + MapEntry(k, RoomMember.fromJson(v as Map))) : null)(json['joined']); } @@ -3530,7 +3546,8 @@ class Api { /// [notMembership] The kind of membership to exclude from the results. Defaults to no /// filtering if unspecified. /// - /// returns `chunk` + /// returns `chunk`: + /// Future?> getMembersByRoom(String roomId, {String? at, Membership? membership, Membership? notMembership}) async { final requestUri = Uri( @@ -3548,7 +3565,9 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['chunk']); } @@ -3602,7 +3621,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetRoomEventsResponse.fromJson(json); + return GetRoomEventsResponse.fromJson(json as Map); } /// Sets the position of the read marker for a given room, and optionally @@ -3768,10 +3787,12 @@ class Api { /// ID unique across requests with the same access token; it will be /// used by the server to ensure idempotency of requests. /// + /// [body] + /// /// returns `event_id`: /// A unique identifier for the event. Future sendMessage(String roomId, String eventType, String txnId, - Map body) async { + Map body) async { final requestUri = Uri( path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/send/${Uri.encodeComponent(eventType)}/${Uri.encodeComponent(txnId)}'); @@ -3800,7 +3821,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as List).map((v) => MatrixEvent.fromJson(v)).toList(); + return (json as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList(); } /// Looks up the contents of a state event in a room. If the user is @@ -3814,7 +3837,7 @@ class Api { /// /// [stateKey] The key of the state to look up. Defaults to an empty string. When /// an empty string, the trailing slash on this endpoint is optional. - Future> getRoomStateWithKey( + Future> getRoomStateWithKey( String roomId, String eventType, String stateKey) async { final requestUri = Uri( path: @@ -3826,7 +3849,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return json as Map; + return json as Map; } /// State events can be sent using this endpoint. These events will be @@ -3855,10 +3878,12 @@ class Api { /// [stateKey] The state_key for the state to send. Defaults to the empty string. When /// an empty string, the trailing slash on this endpoint is optional. /// + /// [body] + /// /// returns `event_id`: /// A unique identifier for the event. Future setRoomStateWithKey(String roomId, String eventType, - String stateKey, Map body) async { + String stateKey, Map body) async { final requestUri = Uri( path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/state/${Uri.encodeComponent(eventType)}/${Uri.encodeComponent(stateKey)}'); @@ -3983,7 +4008,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return SearchResults.fromJson(json); + return SearchResults.fromJson(json as Map); } /// This endpoint is used to send send-to-device events to a set of @@ -3999,7 +4024,7 @@ class Api { /// device ID to message body. The device ID may also be `*`, /// meaning all known devices for the user. Future sendToDevice(String eventType, String txnId, - Map>> messages) async { + Map>> messages) async { final requestUri = Uri( path: '_matrix/client/v3/sendToDevice/${Uri.encodeComponent(eventType)}/${Uri.encodeComponent(txnId)}'); @@ -4100,7 +4125,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return SyncUpdate.fromJson(json); + return SyncUpdate.fromJson(json as Map); } /// Retrieve an array of third party network locations from a Matrix room @@ -4119,7 +4144,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as List).map((v) => Location.fromJson(v)).toList(); + return (json as List) + .map((v) => Location.fromJson(v as Map)) + .toList(); } /// Requesting this endpoint with a valid protocol name results in a list @@ -4150,7 +4177,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as List).map((v) => Location.fromJson(v)).toList(); + return (json as List) + .map((v) => Location.fromJson(v as Map)) + .toList(); } /// Fetches the metadata from the homeserver about a particular third party protocol. @@ -4167,7 +4196,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return Protocol.fromJson(json); + return Protocol.fromJson(json as Map); } /// Fetches the overall metadata about protocols supported by the @@ -4182,8 +4211,8 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as Map) - .map((k, v) => MapEntry(k, Protocol.fromJson(v))); + return (json as Map).map( + (k, v) => MapEntry(k, Protocol.fromJson(v as Map))); } /// Retrieve an array of third party users from a Matrix User ID. @@ -4201,7 +4230,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as List).map((v) => ThirdPartyUser.fromJson(v)).toList(); + return (json as List) + .map((v) => ThirdPartyUser.fromJson(v as Map)) + .toList(); } /// Retrieve a Matrix User ID linked to a user on the third party service, given @@ -4225,7 +4256,9 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return (json as List).map((v) => ThirdPartyUser.fromJson(v)).toList(); + return (json as List) + .map((v) => ThirdPartyUser.fromJson(v as Map)) + .toList(); } /// Get some account data for the client. This config is only visible to the user @@ -4236,7 +4269,7 @@ class Api { /// /// [type] The event type of the account data to get. Custom types should be /// namespaced to avoid clashes. - Future> getAccountData( + Future> getAccountData( String userId, String type) async { final requestUri = Uri( path: @@ -4248,7 +4281,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return json as Map; + return json as Map; } /// Set some account data for the client. This config is only visible to the user @@ -4264,7 +4297,7 @@ class Api { /// /// [content] The content of the account data. Future setAccountData( - String userId, String type, Map content) async { + String userId, String type, Map content) async { final requestUri = Uri( path: '_matrix/client/v3/user/${Uri.encodeComponent(userId)}/account_data/${Uri.encodeComponent(type)}'); @@ -4308,7 +4341,7 @@ class Api { return json['filter_id'] as String; } - /// getFilter + /// /// /// [userId] The user ID to download a filter for. /// @@ -4324,7 +4357,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return Filter.fromJson(json); + return Filter.fromJson(json as Map); } /// Gets an OpenID token object that the requester may supply to another @@ -4341,7 +4374,7 @@ class Api { /// /// [body] An empty object. Reserved for future expansion. Future requestOpenIdToken( - String userId, Map body) async { + String userId, Map body) async { final requestUri = Uri( path: '_matrix/client/v3/user/${Uri.encodeComponent(userId)}/openid/request_token'); @@ -4354,7 +4387,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return OpenIdCredentials.fromJson(json); + return OpenIdCredentials.fromJson(json as Map); } /// Get some account data for the client on a given room. This config is only @@ -4367,7 +4400,7 @@ class Api { /// /// [type] The event type of the account data to get. Custom types should be /// namespaced to avoid clashes. - Future> getAccountDataPerRoom( + Future> getAccountDataPerRoom( String userId, String roomId, String type) async { final requestUri = Uri( path: @@ -4379,7 +4412,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return json as Map; + return json as Map; } /// Set some account data for the client on a given room. This config is only @@ -4396,7 +4429,7 @@ class Api { /// /// [content] The content of the account data. Future setAccountDataPerRoom(String userId, String roomId, String type, - Map content) async { + Map content) async { final requestUri = Uri( path: '_matrix/client/v3/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/account_data/${Uri.encodeComponent(type)}'); @@ -4419,7 +4452,8 @@ class Api { /// /// [roomId] The ID of the room to get tags for. /// - /// returns `tags` + /// returns `tags`: + /// Future?> getRoomTags(String userId, String roomId) async { final requestUri = Uri( path: @@ -4432,8 +4466,8 @@ class Api { final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); return ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, Tag.fromJson(v))) + ? (v as Map) + .map((k, v) => MapEntry(k, Tag.fromJson(v as Map))) : null)(json['tags']); } @@ -4472,7 +4506,7 @@ class Api { /// position of the room under the given tag. Future setRoomTag(String userId, String roomId, String tag, {double? order, - Map additionalProperties = const {}}) async { + Map additionalProperties = const {}}) async { final requestUri = Uri( path: '_matrix/client/v3/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/tags/${Uri.encodeComponent(tag)}'); @@ -4520,7 +4554,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return SearchUserDirectoryResponse.fromJson(json); + return SearchUserDirectoryResponse.fromJson(json as Map); } /// This API provides credentials for the client to use when initiating @@ -4534,7 +4568,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return TurnServerCredentials.fromJson(json); + return TurnServerCredentials.fromJson(json as Map); } /// Gets the versions of the specification supported by the server. @@ -4563,7 +4597,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetVersionsResponse.fromJson(json); + return GetVersionsResponse.fromJson(json as Map); } /// This endpoint allows clients to retrieve the configuration of the content @@ -4585,10 +4619,10 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ServerConfig.fromJson(json); + return ServerConfig.fromJson(json as Map); } - /// getContent + /// /// /// [serverName] The server name from the `mxc://` URI (the authoritory component) /// @@ -4678,7 +4712,7 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return GetUrlPreviewResponse.fromJson(json); + return GetUrlPreviewResponse.fromJson(json as Map); } /// Download a thumbnail of content from the content repository. @@ -4723,7 +4757,7 @@ class Api { contentType: response.headers['content-type'], data: responseBody); } - /// uploadContent + /// /// /// [filename] The name of the file being uploaded /// @@ -4747,6 +4781,6 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return Uri.parse(json['content_uri']); + return Uri.parse(json['content_uri'] as String); } } diff --git a/lib/src/generated/model.dart b/lib/src/generated/model.dart index a4341e68..3ab82f75 100644 --- a/lib/src/generated/model.dart +++ b/lib/src/generated/model.dart @@ -16,15 +16,16 @@ class _NameSource { const _NameSource(this.source); } +/// @_NameSource('spec') class HomeserverInformation { HomeserverInformation({ required this.baseUrl, }); - HomeserverInformation.fromJson(Map json) - : baseUrl = Uri.parse(json['base_url']); - Map toJson() => { + HomeserverInformation.fromJson(Map json) + : baseUrl = Uri.parse(json['base_url'] as String); + Map toJson() => { 'base_url': baseUrl.toString(), }; @@ -32,15 +33,16 @@ class HomeserverInformation { Uri baseUrl; } +/// @_NameSource('spec') class IdentityServerInformation { IdentityServerInformation({ required this.baseUrl, }); - IdentityServerInformation.fromJson(Map json) - : baseUrl = Uri.parse(json['base_url']); - Map toJson() => { + IdentityServerInformation.fromJson(Map json) + : baseUrl = Uri.parse(json['base_url'] as String); + Map toJson() => { 'base_url': baseUrl.toString(), }; @@ -58,16 +60,17 @@ class DiscoveryInformation { this.additionalProperties = const {}, }); - DiscoveryInformation.fromJson(Map json) - : mHomeserver = HomeserverInformation.fromJson(json['m.homeserver']), + DiscoveryInformation.fromJson(Map json) + : mHomeserver = HomeserverInformation.fromJson( + json['m.homeserver'] as Map), mIdentityServer = ((v) => v != null - ? IdentityServerInformation.fromJson(v) + ? IdentityServerInformation.fromJson(v as Map) : null)(json['m.identity_server']), additionalProperties = Map.fromEntries(json.entries .where( (e) => !['m.homeserver', 'm.identity_server'].contains(e.key)) - .map((e) => MapEntry(e.key, e.value as Map))); - Map toJson() { + .map((e) => MapEntry(e.key, e.value as Map))); + Map toJson() { final mIdentityServer = this.mIdentityServer; return { ...additionalProperties, @@ -83,9 +86,10 @@ class DiscoveryInformation { /// Used by clients to discover identity server information. IdentityServerInformation? mIdentityServer; - Map> additionalProperties; + Map> additionalProperties; } +/// @_NameSource('spec') class PublicRoomsChunk { PublicRoomsChunk({ @@ -101,9 +105,9 @@ class PublicRoomsChunk { required this.worldReadable, }); - PublicRoomsChunk.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + PublicRoomsChunk.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), canonicalAlias = ((v) => v != null ? v as String : null)(json['canonical_alias']), guestCanJoin = json['guest_can_join'] as bool, @@ -114,7 +118,7 @@ class PublicRoomsChunk { roomType = ((v) => v != null ? v as String : null)(json['room_type']), topic = ((v) => v != null ? v as String : null)(json['topic']), worldReadable = json['world_readable'] as bool; - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final canonicalAlias = this.canonicalAlias; final joinRule = this.joinRule; @@ -169,6 +173,7 @@ class PublicRoomsChunk { bool worldReadable; } +/// @_NameSource('spec') class ChildRoomsChunk { ChildRoomsChunk({ @@ -176,12 +181,12 @@ class ChildRoomsChunk { this.roomType, }); - ChildRoomsChunk.fromJson(Map json) + ChildRoomsChunk.fromJson(Map json) : childrenState = (json['children_state'] as List) - .map((v) => ChildrenState.fromJson(v)) + .map((v) => ChildrenState.fromJson(v as Map)) .toList(), roomType = ((v) => v != null ? v as String : null)(json['room_type']); - Map toJson() { + Map toJson() { final roomType = this.roomType; return { 'children_state': childrenState.map((v) => v.toJson()).toList(), @@ -199,6 +204,7 @@ class ChildRoomsChunk { String? roomType; } +/// @_NameSource('rule override generated') class SpaceRoomsChunk implements PublicRoomsChunk, ChildRoomsChunk { SpaceRoomsChunk({ @@ -215,9 +221,9 @@ class SpaceRoomsChunk implements PublicRoomsChunk, ChildRoomsChunk { required this.childrenState, }); - SpaceRoomsChunk.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + SpaceRoomsChunk.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), canonicalAlias = ((v) => v != null ? v as String : null)(json['canonical_alias']), guestCanJoin = json['guest_can_join'] as bool, @@ -229,9 +235,9 @@ class SpaceRoomsChunk implements PublicRoomsChunk, ChildRoomsChunk { topic = ((v) => v != null ? v as String : null)(json['topic']), worldReadable = json['world_readable'] as bool, childrenState = (json['children_state'] as List) - .map((v) => ChildrenState.fromJson(v)) + .map((v) => ChildrenState.fromJson(v as Map)) .toList(); - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final canonicalAlias = this.canonicalAlias; final joinRule = this.joinRule; @@ -293,6 +299,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, ChildRoomsChunk { List childrenState; } +/// @_NameSource('generated') class GetSpaceHierarchyResponse { GetSpaceHierarchyResponse({ @@ -300,12 +307,12 @@ class GetSpaceHierarchyResponse { required this.rooms, }); - GetSpaceHierarchyResponse.fromJson(Map json) + GetSpaceHierarchyResponse.fromJson(Map json) : nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), rooms = (json['rooms'] as List) - .map((v) => SpaceRoomsChunk.fromJson(v)) + .map((v) => SpaceRoomsChunk.fromJson(v as Map)) .toList(); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; return { if (nextBatch != null) 'next_batch': nextBatch, @@ -321,6 +328,7 @@ class GetSpaceHierarchyResponse { List rooms; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum Direction { @@ -330,6 +338,7 @@ enum Direction { f } +/// @_NameSource('generated') class GetRelatingEventsResponse { GetRelatingEventsResponse({ @@ -338,13 +347,13 @@ class GetRelatingEventsResponse { this.prevBatch, }); - GetRelatingEventsResponse.fromJson(Map json) + GetRelatingEventsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => MatrixEvent.fromJson(v)) + .map((v) => MatrixEvent.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final prevBatch = this.prevBatch; return { @@ -366,6 +375,7 @@ class GetRelatingEventsResponse { String? prevBatch; } +/// @_NameSource('generated') class GetRelatingEventsWithRelTypeResponse { GetRelatingEventsWithRelTypeResponse({ @@ -374,13 +384,13 @@ class GetRelatingEventsWithRelTypeResponse { this.prevBatch, }); - GetRelatingEventsWithRelTypeResponse.fromJson(Map json) + GetRelatingEventsWithRelTypeResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => MatrixEvent.fromJson(v)) + .map((v) => MatrixEvent.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final prevBatch = this.prevBatch; return { @@ -404,6 +414,7 @@ class GetRelatingEventsWithRelTypeResponse { String? prevBatch; } +/// @_NameSource('generated') class GetRelatingEventsWithRelTypeAndEventTypeResponse { GetRelatingEventsWithRelTypeAndEventTypeResponse({ @@ -413,13 +424,13 @@ class GetRelatingEventsWithRelTypeAndEventTypeResponse { }); GetRelatingEventsWithRelTypeAndEventTypeResponse.fromJson( - Map json) + Map json) : chunk = (json['chunk'] as List) - .map((v) => MatrixEvent.fromJson(v)) + .map((v) => MatrixEvent.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final prevBatch = this.prevBatch; return { @@ -443,6 +454,7 @@ class GetRelatingEventsWithRelTypeAndEventTypeResponse { String? prevBatch; } +/// @_NameSource('generated') @EnhancedEnum() enum Include { @@ -452,6 +464,7 @@ enum Include { participated } +/// @_NameSource('generated') class GetThreadRootsResponse { GetThreadRootsResponse({ @@ -459,12 +472,12 @@ class GetThreadRootsResponse { this.nextBatch, }); - GetThreadRootsResponse.fromJson(Map json) + GetThreadRootsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => MatrixEvent.fromJson(v)) + .map((v) => MatrixEvent.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; return { 'chunk': chunk.map((v) => v.toJson()).toList(), @@ -485,6 +498,7 @@ class GetThreadRootsResponse { String? nextBatch; } +/// @_NameSource('generated') class GetEventByTimestampResponse { GetEventByTimestampResponse({ @@ -492,10 +506,10 @@ class GetEventByTimestampResponse { required this.originServerTs, }); - GetEventByTimestampResponse.fromJson(Map json) + GetEventByTimestampResponse.fromJson(Map json) : eventId = json['event_id'] as String, originServerTs = json['origin_server_ts'] as int; - Map toJson() => { + Map toJson() => { 'event_id': eventId, 'origin_server_ts': originServerTs, }; @@ -510,6 +524,7 @@ class GetEventByTimestampResponse { int originServerTs; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum ThirdPartyIdentifierMedium { @@ -519,6 +534,7 @@ enum ThirdPartyIdentifierMedium { msisdn } +/// @_NameSource('spec') class ThirdPartyIdentifier { ThirdPartyIdentifier({ @@ -528,12 +544,13 @@ class ThirdPartyIdentifier { required this.validatedAt, }); - ThirdPartyIdentifier.fromJson(Map json) + ThirdPartyIdentifier.fromJson(Map json) : addedAt = json['added_at'] as int, address = json['address'] as String, - medium = ThirdPartyIdentifierMedium.values.fromString(json['medium'])!, + medium = ThirdPartyIdentifierMedium.values + .fromString(json['medium'] as String)!, validatedAt = json['validated_at'] as int; - Map toJson() => { + Map toJson() => { 'added_at': addedAt, 'address': address, 'medium': medium.name, @@ -554,6 +571,7 @@ class ThirdPartyIdentifier { int validatedAt; } +/// @_NameSource('spec') class ThreePidCredentials { ThreePidCredentials({ @@ -563,12 +581,12 @@ class ThreePidCredentials { required this.sid, }); - ThreePidCredentials.fromJson(Map json) + ThreePidCredentials.fromJson(Map json) : clientSecret = json['client_secret'] as String, idAccessToken = json['id_access_token'] as String, idServer = json['id_server'] as String, sid = json['sid'] as String; - Map toJson() => { + Map toJson() => { 'client_secret': clientSecret, 'id_access_token': idAccessToken, 'id_server': idServer, @@ -590,6 +608,7 @@ class ThreePidCredentials { String sid; } +/// @_NameSource('generated') @EnhancedEnum() enum IdServerUnbindResult { @@ -599,6 +618,7 @@ enum IdServerUnbindResult { success } +/// @_NameSource('spec') class RequestTokenResponse { RequestTokenResponse({ @@ -606,11 +626,11 @@ class RequestTokenResponse { this.submitUrl, }); - RequestTokenResponse.fromJson(Map json) + RequestTokenResponse.fromJson(Map json) : sid = json['sid'] as String, - submitUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['submit_url']); - Map toJson() { + submitUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['submit_url']); + Map toJson() { final submitUrl = this.submitUrl; return { 'sid': sid, @@ -636,6 +656,7 @@ class RequestTokenResponse { Uri? submitUrl; } +/// @_NameSource('rule override generated') class TokenOwnerInfo { TokenOwnerInfo({ @@ -644,11 +665,11 @@ class TokenOwnerInfo { required this.userId, }); - TokenOwnerInfo.fromJson(Map json) + TokenOwnerInfo.fromJson(Map json) : deviceId = ((v) => v != null ? v as String : null)(json['device_id']), isGuest = ((v) => v != null ? v as bool : null)(json['is_guest']), userId = json['user_id'] as String; - Map toJson() { + Map toJson() { final deviceId = this.deviceId; final isGuest = this.isGuest; return { @@ -673,6 +694,7 @@ class TokenOwnerInfo { String userId; } +/// @_NameSource('spec') class ConnectionInfo { ConnectionInfo({ @@ -681,11 +703,11 @@ class ConnectionInfo { this.userAgent, }); - ConnectionInfo.fromJson(Map json) + ConnectionInfo.fromJson(Map json) : ip = ((v) => v != null ? v as String : null)(json['ip']), lastSeen = ((v) => v != null ? v as int : null)(json['last_seen']), userAgent = ((v) => v != null ? v as String : null)(json['user_agent']); - Map toJson() { + Map toJson() { final ip = this.ip; final lastSeen = this.lastSeen; final userAgent = this.userAgent; @@ -706,17 +728,20 @@ class ConnectionInfo { String? userAgent; } +/// @_NameSource('spec') class SessionInfo { SessionInfo({ this.connections, }); - SessionInfo.fromJson(Map json) + SessionInfo.fromJson(Map json) : connections = ((v) => v != null - ? (v as List).map((v) => ConnectionInfo.fromJson(v)).toList() + ? (v as List) + .map((v) => ConnectionInfo.fromJson(v as Map)) + .toList() : null)(json['connections']); - Map toJson() { + Map toJson() { final connections = this.connections; return { if (connections != null) @@ -728,17 +753,20 @@ class SessionInfo { List? connections; } +/// @_NameSource('spec') class DeviceInfo { DeviceInfo({ this.sessions, }); - DeviceInfo.fromJson(Map json) + DeviceInfo.fromJson(Map json) : sessions = ((v) => v != null - ? (v as List).map((v) => SessionInfo.fromJson(v)).toList() + ? (v as List) + .map((v) => SessionInfo.fromJson(v as Map)) + .toList() : null)(json['sessions']); - Map toJson() { + Map toJson() { final sessions = this.sessions; return { if (sessions != null) @@ -750,6 +778,7 @@ class DeviceInfo { List? sessions; } +/// @_NameSource('rule override generated') class WhoIsInfo { WhoIsInfo({ @@ -757,13 +786,13 @@ class WhoIsInfo { this.userId, }); - WhoIsInfo.fromJson(Map json) + WhoIsInfo.fromJson(Map json) : devices = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, DeviceInfo.fromJson(v))) + ? (v as Map).map((k, v) => + MapEntry(k, DeviceInfo.fromJson(v as Map))) : null)(json['devices']), userId = ((v) => v != null ? v as String : null)(json['user_id']); - Map toJson() { + Map toJson() { final devices = this.devices; final userId = this.userId; return { @@ -780,15 +809,16 @@ class WhoIsInfo { String? userId; } +/// @_NameSource('spec') class ChangePasswordCapability { ChangePasswordCapability({ required this.enabled, }); - ChangePasswordCapability.fromJson(Map json) + ChangePasswordCapability.fromJson(Map json) : enabled = json['enabled'] as bool; - Map toJson() => { + Map toJson() => { 'enabled': enabled, }; @@ -806,6 +836,7 @@ enum RoomVersionAvailable { unstable } +/// @_NameSource('spec') class RoomVersionsCapability { RoomVersionsCapability({ @@ -813,11 +844,11 @@ class RoomVersionsCapability { required this.default$, }); - RoomVersionsCapability.fromJson(Map json) - : available = (json['available'] as Map).map( - (k, v) => MapEntry(k, RoomVersionAvailable.values.fromString(v)!)), + RoomVersionsCapability.fromJson(Map json) + : available = (json['available'] as Map).map((k, v) => + MapEntry(k, RoomVersionAvailable.values.fromString(v as String)!)), default$ = json['default'] as String; - Map toJson() => { + Map toJson() => { 'available': available.map((k, v) => MapEntry(k, v.name)), 'default': default$, }; @@ -829,6 +860,7 @@ class RoomVersionsCapability { String default$; } +/// @_NameSource('spec') class Capabilities { Capabilities({ @@ -837,18 +869,18 @@ class Capabilities { this.additionalProperties = const {}, }); - Capabilities.fromJson(Map json) + Capabilities.fromJson(Map json) : mChangePassword = ((v) => v != null - ? ChangePasswordCapability.fromJson(v) + ? ChangePasswordCapability.fromJson(v as Map) : null)(json['m.change_password']), mRoomVersions = ((v) => v != null - ? RoomVersionsCapability.fromJson(v) + ? RoomVersionsCapability.fromJson(v as Map) : null)(json['m.room_versions']), additionalProperties = Map.fromEntries(json.entries .where((e) => !['m.change_password', 'm.room_versions'].contains(e.key)) - .map((e) => MapEntry(e.key, e.value as Map))); - Map toJson() { + .map((e) => MapEntry(e.key, e.value as Map))); + Map toJson() { final mChangePassword = this.mChangePassword; final mRoomVersions = this.mRoomVersions; return { @@ -865,9 +897,10 @@ class Capabilities { /// The room versions the server supports. RoomVersionsCapability? mRoomVersions; - Map> additionalProperties; + Map> additionalProperties; } +/// @_NameSource('spec') class StateEvent { StateEvent({ @@ -876,11 +909,11 @@ class StateEvent { required this.type, }); - StateEvent.fromJson(Map json) - : content = json['content'] as Map, + StateEvent.fromJson(Map json) + : content = json['content'] as Map, stateKey = ((v) => v != null ? v as String : null)(json['state_key']), type = json['type'] as String; - Map toJson() { + Map toJson() { final stateKey = this.stateKey; return { 'content': content, @@ -890,7 +923,7 @@ class StateEvent { } /// The content of the event. - Map content; + Map content; /// The state_key of the state event. Defaults to an empty string. String? stateKey; @@ -899,6 +932,7 @@ class StateEvent { String type; } +/// @_NameSource('spec') class Invite3pid { Invite3pid({ @@ -908,12 +942,12 @@ class Invite3pid { required this.medium, }); - Invite3pid.fromJson(Map json) + Invite3pid.fromJson(Map json) : address = json['address'] as String, idAccessToken = json['id_access_token'] as String, idServer = json['id_server'] as String, medium = json['medium'] as String; - Map toJson() => { + Map toJson() => { 'address': address, 'id_access_token': idAccessToken, 'id_server': idServer, @@ -936,6 +970,7 @@ class Invite3pid { String medium; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum CreateRoomPreset { @@ -947,6 +982,7 @@ enum CreateRoomPreset { trustedPrivateChat } +/// @_NameSource('generated') @EnhancedEnum() enum Visibility { @@ -966,14 +1002,14 @@ class Device { this.lastSeenTs, }); - Device.fromJson(Map json) + Device.fromJson(Map json) : deviceId = json['device_id'] as String, displayName = ((v) => v != null ? v as String : null)(json['display_name']), lastSeenIp = ((v) => v != null ? v as String : null)(json['last_seen_ip']), lastSeenTs = ((v) => v != null ? v as int : null)(json['last_seen_ts']); - Map toJson() { + Map toJson() { final displayName = this.displayName; final lastSeenIp = this.lastSeenIp; final lastSeenTs = this.lastSeenTs; @@ -1002,6 +1038,7 @@ class Device { int? lastSeenTs; } +/// @_NameSource('generated') class GetRoomIdByAliasResponse { GetRoomIdByAliasResponse({ @@ -1009,12 +1046,12 @@ class GetRoomIdByAliasResponse { this.servers, }); - GetRoomIdByAliasResponse.fromJson(Map json) + GetRoomIdByAliasResponse.fromJson(Map json) : roomId = ((v) => v != null ? v as String : null)(json['room_id']), servers = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['servers']); - Map toJson() { + Map toJson() { final roomId = this.roomId; final servers = this.servers; return { @@ -1030,6 +1067,7 @@ class GetRoomIdByAliasResponse { List? servers; } +/// @_NameSource('generated') class GetEventsResponse { GetEventsResponse({ @@ -1038,13 +1076,15 @@ class GetEventsResponse { this.start, }); - GetEventsResponse.fromJson(Map json) + GetEventsResponse.fromJson(Map json) : chunk = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['chunk']), end = ((v) => v != null ? v as String : null)(json['end']), start = ((v) => v != null ? v as String : null)(json['start']); - Map toJson() { + Map toJson() { final chunk = this.chunk; final end = this.end; final start = this.start; @@ -1067,6 +1107,7 @@ class GetEventsResponse { String? start; } +/// @_NameSource('generated') class PeekEventsResponse { PeekEventsResponse({ @@ -1075,13 +1116,15 @@ class PeekEventsResponse { this.start, }); - PeekEventsResponse.fromJson(Map json) + PeekEventsResponse.fromJson(Map json) : chunk = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['chunk']), end = ((v) => v != null ? v as String : null)(json['end']), start = ((v) => v != null ? v as String : null)(json['start']); - Map toJson() { + Map toJson() { final chunk = this.chunk; final end = this.end; final start = this.start; @@ -1115,16 +1158,16 @@ class ThirdPartySigned { required this.token, }); - ThirdPartySigned.fromJson(Map json) + ThirdPartySigned.fromJson(Map json) : mxid = json['mxid'] as String, sender = json['sender'] as String, - signatures = (json['signatures'] as Map).map((k, v) => + signatures = (json['signatures'] as Map).map((k, v) => MapEntry( k, - (v as Map) + (v as Map) .map((k, v) => MapEntry(k, v as String)))), token = json['token'] as String; - Map toJson() => { + Map toJson() => { 'mxid': mxid, 'sender': sender, 'signatures': signatures @@ -1145,6 +1188,7 @@ class ThirdPartySigned { String token; } +/// @_NameSource('generated') class GetKeysChangesResponse { GetKeysChangesResponse({ @@ -1152,14 +1196,14 @@ class GetKeysChangesResponse { this.left, }); - GetKeysChangesResponse.fromJson(Map json) + GetKeysChangesResponse.fromJson(Map json) : changed = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['changed']), left = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['left']); - Map toJson() { + Map toJson() { final changed = this.changed; final left = this.left; return { @@ -1178,6 +1222,7 @@ class GetKeysChangesResponse { List? left; } +/// @_NameSource('generated') class ClaimKeysResponse { ClaimKeysResponse({ @@ -1185,17 +1230,17 @@ class ClaimKeysResponse { required this.oneTimeKeys, }); - ClaimKeysResponse.fromJson(Map json) + ClaimKeysResponse.fromJson(Map json) : failures = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, v as Map)) + ? (v as Map) + .map((k, v) => MapEntry(k, v as Map)) : null)(json['failures']), - oneTimeKeys = (json['one_time_keys'] as Map).map( + oneTimeKeys = (json['one_time_keys'] as Map).map( (k, v) => MapEntry( k, - (v as Map) - .map((k, v) => MapEntry(k, v as Map)))); - Map toJson() { + (v as Map) + .map((k, v) => MapEntry(k, v as Map)))); + Map toJson() { final failures = this.failures; return { if (failures != null) 'failures': failures.map((k, v) => MapEntry(k, v)), @@ -1211,7 +1256,7 @@ class ClaimKeysResponse { /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the `one_time_keys` result. - Map>? failures; + Map>? failures; /// One-time keys for the queried devices. A map from user ID, to a /// map from devices to a map from `:` to the key object. @@ -1221,9 +1266,10 @@ class ClaimKeysResponse { /// /// If necessary, the claimed key might be a fallback key. Fallback /// keys are re-used by the server until replaced by the device. - Map>> oneTimeKeys; + Map>> oneTimeKeys; } +/// @_NameSource('generated') class QueryKeysResponse { QueryKeysResponse({ @@ -1234,30 +1280,30 @@ class QueryKeysResponse { this.userSigningKeys, }); - QueryKeysResponse.fromJson(Map json) + QueryKeysResponse.fromJson(Map json) : deviceKeys = ((v) => v != null - ? (v as Map).map((k, v) => MapEntry( + ? (v as Map).map((k, v) => MapEntry( k, - (v as Map) - .map((k, v) => MapEntry(k, MatrixDeviceKeys.fromJson(v))))) + (v as Map).map((k, v) => MapEntry( + k, MatrixDeviceKeys.fromJson(v as Map))))) : null)(json['device_keys']), failures = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, v as Map)) + ? (v as Map) + .map((k, v) => MapEntry(k, v as Map)) : null)(json['failures']), masterKeys = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, MatrixCrossSigningKey.fromJson(v))) + ? (v as Map).map((k, v) => MapEntry( + k, MatrixCrossSigningKey.fromJson(v as Map))) : null)(json['master_keys']), selfSigningKeys = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, MatrixCrossSigningKey.fromJson(v))) + ? (v as Map).map((k, v) => MapEntry( + k, MatrixCrossSigningKey.fromJson(v as Map))) : null)(json['self_signing_keys']), userSigningKeys = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, MatrixCrossSigningKey.fromJson(v))) + ? (v as Map).map((k, v) => MapEntry( + k, MatrixCrossSigningKey.fromJson(v as Map))) : null)(json['user_signing_keys']); - Map toJson() { + Map toJson() { final deviceKeys = this.deviceKeys; final failures = this.failures; final masterKeys = this.masterKeys; @@ -1293,7 +1339,7 @@ class QueryKeysResponse { /// If the homeserver could be reached, but the user or device /// was unknown, no failure is recorded. Instead, the corresponding /// user or device is missing from the `device_keys` result. - Map>? failures; + Map>? failures; /// Information on the master cross-signing keys of the queried users. /// A map from user ID, to master key information. For each key, the @@ -1317,15 +1363,16 @@ class QueryKeysResponse { Map? userSigningKeys; } +/// @_NameSource('spec') class LoginFlow { LoginFlow({ this.type, }); - LoginFlow.fromJson(Map json) + LoginFlow.fromJson(Map json) : type = ((v) => v != null ? v as String : null)(json['type']); - Map toJson() { + Map toJson() { final type = this.type; return { if (type != null) 'type': type, @@ -1337,6 +1384,7 @@ class LoginFlow { String? type; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum LoginType { @@ -1346,6 +1394,7 @@ enum LoginType { mLoginToken } +/// @_NameSource('generated') class LoginResponse { LoginResponse({ @@ -1358,7 +1407,7 @@ class LoginResponse { this.wellKnown, }); - LoginResponse.fromJson(Map json) + LoginResponse.fromJson(Map json) : accessToken = json['access_token'] as String, deviceId = json['device_id'] as String, expiresInMs = @@ -1369,9 +1418,9 @@ class LoginResponse { ((v) => v != null ? v as String : null)(json['refresh_token']), userId = json['user_id'] as String, wellKnown = ((v) => v != null - ? DiscoveryInformation.fromJson(v) + ? DiscoveryInformation.fromJson(v as Map) : null)(json['well_known']); - Map toJson() { + Map toJson() { final expiresInMs = this.expiresInMs; final homeServer = this.homeServer; final refreshToken = this.refreshToken; @@ -1426,6 +1475,7 @@ class LoginResponse { DiscoveryInformation? wellKnown; } +/// @_NameSource('spec') class Notification { Notification({ @@ -1437,15 +1487,15 @@ class Notification { required this.ts, }); - Notification.fromJson(Map json) - : actions = (json['actions'] as List).map((v) => v as dynamic).toList(), - event = MatrixEvent.fromJson(json['event']), + Notification.fromJson(Map json) + : actions = (json['actions'] as List).map((v) => v as Object?).toList(), + event = MatrixEvent.fromJson(json['event'] as Map), profileTag = ((v) => v != null ? v as String : null)(json['profile_tag']), read = json['read'] as bool, roomId = json['room_id'] as String, ts = json['ts'] as int; - Map toJson() { + Map toJson() { final profileTag = this.profileTag; return { 'actions': actions.map((v) => v).toList(), @@ -1459,7 +1509,7 @@ class Notification { /// The action(s) to perform when the conditions for this rule are met. /// See [Push Rules: API](https://spec.matrix.org/unstable/client-server-api/#push-rules-api). - List actions; + List actions; /// The Event object for the event that triggered the notification. MatrixEvent event; @@ -1479,6 +1529,7 @@ class Notification { int ts; } +/// @_NameSource('generated') class GetNotificationsResponse { GetNotificationsResponse({ @@ -1486,12 +1537,12 @@ class GetNotificationsResponse { required this.notifications, }); - GetNotificationsResponse.fromJson(Map json) + GetNotificationsResponse.fromJson(Map json) : nextToken = ((v) => v != null ? v as String : null)(json['next_token']), notifications = (json['notifications'] as List) - .map((v) => Notification.fromJson(v)) + .map((v) => Notification.fromJson(v as Map)) .toList(); - Map toJson() { + Map toJson() { final nextToken = this.nextToken; return { if (nextToken != null) 'next_token': nextToken, @@ -1508,6 +1559,7 @@ class GetNotificationsResponse { List notifications; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum PresenceType { @@ -1519,6 +1571,7 @@ enum PresenceType { unavailable } +/// @_NameSource('generated') class GetPresenceResponse { GetPresenceResponse({ @@ -1528,14 +1581,14 @@ class GetPresenceResponse { this.statusMsg, }); - GetPresenceResponse.fromJson(Map json) + GetPresenceResponse.fromJson(Map json) : currentlyActive = ((v) => v != null ? v as bool : null)(json['currently_active']), lastActiveAgo = ((v) => v != null ? v as int : null)(json['last_active_ago']), - presence = PresenceType.values.fromString(json['presence'])!, + presence = PresenceType.values.fromString(json['presence'] as String)!, statusMsg = ((v) => v != null ? v as String : null)(json['status_msg']); - Map toJson() { + Map toJson() { final currentlyActive = this.currentlyActive; final lastActiveAgo = this.lastActiveAgo; final statusMsg = this.statusMsg; @@ -1561,6 +1614,7 @@ class GetPresenceResponse { String? statusMsg; } +/// @_NameSource('rule override generated') class ProfileInformation { ProfileInformation({ @@ -1568,12 +1622,12 @@ class ProfileInformation { this.displayname, }); - ProfileInformation.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + ProfileInformation.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), displayname = ((v) => v != null ? v as String : null)(json['displayname']); - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final displayname = this.displayname; return { @@ -1599,15 +1653,15 @@ class GetPublicRoomsResponse { this.totalRoomCountEstimate, }); - GetPublicRoomsResponse.fromJson(Map json) + GetPublicRoomsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => PublicRoomsChunk.fromJson(v)) + .map((v) => PublicRoomsChunk.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']), totalRoomCountEstimate = ((v) => v != null ? v as int : null)(json['total_room_count_estimate']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final prevBatch = this.prevBatch; final totalRoomCountEstimate = this.totalRoomCountEstimate; @@ -1638,6 +1692,7 @@ class GetPublicRoomsResponse { int? totalRoomCountEstimate; } +/// @_NameSource('rule override spec') class PublicRoomQueryFilter { PublicRoomQueryFilter({ @@ -1645,13 +1700,13 @@ class PublicRoomQueryFilter { this.roomTypes, }); - PublicRoomQueryFilter.fromJson(Map json) + PublicRoomQueryFilter.fromJson(Map json) : genericSearchTerm = ((v) => v != null ? v as String : null)(json['generic_search_term']), roomTypes = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['room_types']); - Map toJson() { + Map toJson() { final genericSearchTerm = this.genericSearchTerm; final roomTypes = this.roomTypes; return { @@ -1681,15 +1736,15 @@ class QueryPublicRoomsResponse { this.totalRoomCountEstimate, }); - QueryPublicRoomsResponse.fromJson(Map json) + QueryPublicRoomsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => PublicRoomsChunk.fromJson(v)) + .map((v) => PublicRoomsChunk.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']), totalRoomCountEstimate = ((v) => v != null ? v as int : null)(json['total_room_count_estimate']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final prevBatch = this.prevBatch; final totalRoomCountEstimate = this.totalRoomCountEstimate; @@ -1720,6 +1775,7 @@ class QueryPublicRoomsResponse { int? totalRoomCountEstimate; } +/// @_NameSource('spec') class PusherData { PusherData({ @@ -1728,13 +1784,13 @@ class PusherData { this.additionalProperties = const {}, }); - PusherData.fromJson(Map json) + PusherData.fromJson(Map json) : format = ((v) => v != null ? v as String : null)(json['format']), - url = ((v) => v != null ? Uri.parse(v) : null)(json['url']), + url = ((v) => v != null ? Uri.parse(v as String) : null)(json['url']), additionalProperties = Map.fromEntries(json.entries .where((e) => !['format', 'url'].contains(e.key)) - .map((e) => MapEntry(e.key, e.value as dynamic))); - Map toJson() { + .map((e) => MapEntry(e.key, e.value as Object?))); + Map toJson() { final format = this.format; final url = this.url; return { @@ -1752,9 +1808,10 @@ class PusherData { /// notifications to. Uri? url; - Map additionalProperties; + Map additionalProperties; } +/// @_NameSource('spec') class PusherId { PusherId({ @@ -1762,10 +1819,10 @@ class PusherId { required this.pushkey, }); - PusherId.fromJson(Map json) + PusherId.fromJson(Map json) : appId = json['app_id'] as String, pushkey = json['pushkey'] as String; - Map toJson() => { + Map toJson() => { 'app_id': appId, 'pushkey': pushkey, }; @@ -1780,6 +1837,7 @@ class PusherId { String pushkey; } +/// @_NameSource('spec') class Pusher implements PusherId { Pusher({ @@ -1793,17 +1851,17 @@ class Pusher implements PusherId { this.profileTag, }); - Pusher.fromJson(Map json) + Pusher.fromJson(Map json) : appId = json['app_id'] as String, pushkey = json['pushkey'] as String, appDisplayName = json['app_display_name'] as String, - data = PusherData.fromJson(json['data']), + data = PusherData.fromJson(json['data'] as Map), deviceDisplayName = json['device_display_name'] as String, kind = json['kind'] as String, lang = json['lang'] as String, profileTag = ((v) => v != null ? v as String : null)(json['profile_tag']); - Map toJson() { + Map toJson() { final profileTag = this.profileTag; return { 'app_id': appId, @@ -1851,6 +1909,7 @@ class Pusher implements PusherId { String? profileTag; } +/// @_NameSource('spec') class PushCondition { PushCondition({ @@ -1860,12 +1919,12 @@ class PushCondition { this.pattern, }); - PushCondition.fromJson(Map json) + PushCondition.fromJson(Map json) : is$ = ((v) => v != null ? v as String : null)(json['is']), key = ((v) => v != null ? v as String : null)(json['key']), kind = json['kind'] as String, pattern = ((v) => v != null ? v as String : null)(json['pattern']); - Map toJson() { + Map toJson() { final is$ = this.is$; final key = this.key; final pattern = this.pattern; @@ -1901,6 +1960,7 @@ class PushCondition { String? pattern; } +/// @_NameSource('spec') class PushRule { PushRule({ @@ -1912,16 +1972,18 @@ class PushRule { required this.ruleId, }); - PushRule.fromJson(Map json) - : actions = (json['actions'] as List).map((v) => v as dynamic).toList(), + PushRule.fromJson(Map json) + : actions = (json['actions'] as List).map((v) => v as Object?).toList(), conditions = ((v) => v != null - ? (v as List).map((v) => PushCondition.fromJson(v)).toList() + ? (v as List) + .map((v) => PushCondition.fromJson(v as Map)) + .toList() : null)(json['conditions']), default$ = json['default'] as bool, enabled = json['enabled'] as bool, pattern = ((v) => v != null ? v as String : null)(json['pattern']), ruleId = json['rule_id'] as String; - Map toJson() { + Map toJson() { final conditions = this.conditions; final pattern = this.pattern; return { @@ -1936,7 +1998,7 @@ class PushRule { } /// The actions to perform when this rule is matched. - List actions; + List actions; /// The conditions that must hold true for an event in order for a rule to be /// applied to an event. A rule with no conditions always matches. Only @@ -1957,6 +2019,7 @@ class PushRule { String ruleId; } +/// @_NameSource('rule override generated') class PushRuleSet { PushRuleSet({ @@ -1967,23 +2030,33 @@ class PushRuleSet { this.underride, }); - PushRuleSet.fromJson(Map json) + PushRuleSet.fromJson(Map json) : content = ((v) => v != null - ? (v as List).map((v) => PushRule.fromJson(v)).toList() + ? (v as List) + .map((v) => PushRule.fromJson(v as Map)) + .toList() : null)(json['content']), override = ((v) => v != null - ? (v as List).map((v) => PushRule.fromJson(v)).toList() + ? (v as List) + .map((v) => PushRule.fromJson(v as Map)) + .toList() : null)(json['override']), room = ((v) => v != null - ? (v as List).map((v) => PushRule.fromJson(v)).toList() + ? (v as List) + .map((v) => PushRule.fromJson(v as Map)) + .toList() : null)(json['room']), sender = ((v) => v != null - ? (v as List).map((v) => PushRule.fromJson(v)).toList() + ? (v as List) + .map((v) => PushRule.fromJson(v as Map)) + .toList() : null)(json['sender']), underride = ((v) => v != null - ? (v as List).map((v) => PushRule.fromJson(v)).toList() + ? (v as List) + .map((v) => PushRule.fromJson(v as Map)) + .toList() : null)(json['underride']); - Map toJson() { + Map toJson() { final content = this.content; final override = this.override; final room = this.room; @@ -2000,17 +2073,23 @@ class PushRuleSet { }; } + /// List? content; + /// List? override; + /// List? room; + /// List? sender; + /// List? underride; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum PushRuleKind { @@ -2026,6 +2105,7 @@ enum PushRuleKind { underride } +/// @_NameSource('generated') class RefreshResponse { RefreshResponse({ @@ -2034,13 +2114,13 @@ class RefreshResponse { this.refreshToken, }); - RefreshResponse.fromJson(Map json) + RefreshResponse.fromJson(Map json) : accessToken = json['access_token'] as String, expiresInMs = ((v) => v != null ? v as int : null)(json['expires_in_ms']), refreshToken = ((v) => v != null ? v as String : null)(json['refresh_token']); - Map toJson() { + Map toJson() { final expiresInMs = this.expiresInMs; final refreshToken = this.refreshToken; return { @@ -2064,6 +2144,7 @@ class RefreshResponse { String? refreshToken; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum AccountKind { @@ -2073,6 +2154,7 @@ enum AccountKind { user } +/// @_NameSource('generated') class RegisterResponse { RegisterResponse({ @@ -2084,7 +2166,7 @@ class RegisterResponse { required this.userId, }); - RegisterResponse.fromJson(Map json) + RegisterResponse.fromJson(Map json) : accessToken = ((v) => v != null ? v as String : null)(json['access_token']), deviceId = ((v) => v != null ? v as String : null)(json['device_id']), @@ -2095,7 +2177,7 @@ class RegisterResponse { refreshToken = ((v) => v != null ? v as String : null)(json['refresh_token']), userId = json['user_id'] as String; - Map toJson() { + Map toJson() { final accessToken = this.accessToken; final deviceId = this.deviceId; final expiresInMs = this.expiresInMs; @@ -2153,6 +2235,7 @@ class RegisterResponse { String userId; } +/// @_NameSource('spec') class RoomKeysUpdateResponse { RoomKeysUpdateResponse({ @@ -2160,10 +2243,10 @@ class RoomKeysUpdateResponse { required this.etag, }); - RoomKeysUpdateResponse.fromJson(Map json) + RoomKeysUpdateResponse.fromJson(Map json) : count = json['count'] as int, etag = json['etag'] as String; - Map toJson() => { + Map toJson() => { 'count': count, 'etag': etag, }; @@ -2186,12 +2269,12 @@ class KeyBackupData { required this.sessionData, }); - KeyBackupData.fromJson(Map json) + KeyBackupData.fromJson(Map json) : firstMessageIndex = json['first_message_index'] as int, forwardedCount = json['forwarded_count'] as int, isVerified = json['is_verified'] as bool, - sessionData = json['session_data'] as Map; - Map toJson() => { + sessionData = json['session_data'] as Map; + Map toJson() => { 'first_message_index': firstMessageIndex, 'forwarded_count': forwardedCount, 'is_verified': isVerified, @@ -2211,7 +2294,7 @@ class KeyBackupData { /// Algorithm-dependent data. See the documentation for the backup /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the /// expected format of the data. - Map sessionData; + Map sessionData; } /// The backed up keys for a room. @@ -2221,10 +2304,10 @@ class RoomKeyBackup { required this.sessions, }); - RoomKeyBackup.fromJson(Map json) - : sessions = (json['sessions'] as Map) - .map((k, v) => MapEntry(k, KeyBackupData.fromJson(v))); - Map toJson() => { + RoomKeyBackup.fromJson(Map json) + : sessions = (json['sessions'] as Map).map((k, v) => + MapEntry(k, KeyBackupData.fromJson(v as Map))); + Map toJson() => { 'sessions': sessions.map((k, v) => MapEntry(k, v.toJson())), }; @@ -2232,16 +2315,17 @@ class RoomKeyBackup { Map sessions; } +/// @_NameSource('rule override generated') class RoomKeys { RoomKeys({ required this.rooms, }); - RoomKeys.fromJson(Map json) - : rooms = (json['rooms'] as Map) - .map((k, v) => MapEntry(k, RoomKeyBackup.fromJson(v))); - Map toJson() => { + RoomKeys.fromJson(Map json) + : rooms = (json['rooms'] as Map).map((k, v) => + MapEntry(k, RoomKeyBackup.fromJson(v as Map))); + Map toJson() => { 'rooms': rooms.map((k, v) => MapEntry(k, v.toJson())), }; @@ -2249,6 +2333,7 @@ class RoomKeys { Map rooms; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum BackupAlgorithm { @@ -2256,6 +2341,7 @@ enum BackupAlgorithm { mMegolmBackupV1Curve25519AesSha2 } +/// @_NameSource('generated') class GetRoomKeysVersionCurrentResponse { GetRoomKeysVersionCurrentResponse({ @@ -2266,13 +2352,14 @@ class GetRoomKeysVersionCurrentResponse { required this.version, }); - GetRoomKeysVersionCurrentResponse.fromJson(Map json) - : algorithm = BackupAlgorithm.values.fromString(json['algorithm'])!, - authData = json['auth_data'] as Map, + GetRoomKeysVersionCurrentResponse.fromJson(Map json) + : algorithm = + BackupAlgorithm.values.fromString(json['algorithm'] as String)!, + authData = json['auth_data'] as Map, count = json['count'] as int, etag = json['etag'] as String, version = json['version'] as String; - Map toJson() => { + Map toJson() => { 'algorithm': algorithm.name, 'auth_data': authData, 'count': count, @@ -2286,7 +2373,7 @@ class GetRoomKeysVersionCurrentResponse { /// Algorithm-dependent data. See the documentation for the backup /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the /// expected format of the data. - Map authData; + Map authData; /// The number of keys stored in the backup. int count; @@ -2301,6 +2388,7 @@ class GetRoomKeysVersionCurrentResponse { String version; } +/// @_NameSource('generated') class GetRoomKeysVersionResponse { GetRoomKeysVersionResponse({ @@ -2311,13 +2399,14 @@ class GetRoomKeysVersionResponse { required this.version, }); - GetRoomKeysVersionResponse.fromJson(Map json) - : algorithm = BackupAlgorithm.values.fromString(json['algorithm'])!, - authData = json['auth_data'] as Map, + GetRoomKeysVersionResponse.fromJson(Map json) + : algorithm = + BackupAlgorithm.values.fromString(json['algorithm'] as String)!, + authData = json['auth_data'] as Map, count = json['count'] as int, etag = json['etag'] as String, version = json['version'] as String; - Map toJson() => { + Map toJson() => { 'algorithm': algorithm.name, 'auth_data': authData, 'count': count, @@ -2331,7 +2420,7 @@ class GetRoomKeysVersionResponse { /// Algorithm-dependent data. See the documentation for the backup /// algorithms in [Server-side key backups](https://spec.matrix.org/unstable/client-server-api/#server-side-key-backups) for more information on the /// expected format of the data. - Map authData; + Map authData; /// The number of keys stored in the backup. int count; @@ -2358,21 +2447,28 @@ class EventContext { this.state, }); - EventContext.fromJson(Map json) + EventContext.fromJson(Map json) : end = ((v) => v != null ? v as String : null)(json['end']), - event = - ((v) => v != null ? MatrixEvent.fromJson(v) : null)(json['event']), + event = ((v) => v != null + ? MatrixEvent.fromJson(v as Map) + : null)(json['event']), eventsAfter = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['events_after']), eventsBefore = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['events_before']), start = ((v) => v != null ? v as String : null)(json['start']), state = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['state']); - Map toJson() { + Map toJson() { final end = this.end; final event = this.event; final eventsAfter = this.eventsAfter; @@ -2412,6 +2508,7 @@ class EventContext { List? state; } +/// @_NameSource('spec') class RoomMember { RoomMember({ @@ -2419,12 +2516,12 @@ class RoomMember { this.displayName, }); - RoomMember.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + RoomMember.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), displayName = ((v) => v != null ? v as String : null)(json['display_name']); - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final displayName = this.displayName; return { @@ -2440,6 +2537,7 @@ class RoomMember { String? displayName; } +/// @_NameSource('(generated, rule override generated)') @EnhancedEnum() enum Membership { @@ -2465,16 +2563,18 @@ class GetRoomEventsResponse { this.state, }); - GetRoomEventsResponse.fromJson(Map json) + GetRoomEventsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => MatrixEvent.fromJson(v)) + .map((v) => MatrixEvent.fromJson(v as Map)) .toList(), end = ((v) => v != null ? v as String : null)(json['end']), start = json['start'] as String, state = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['state']); - Map toJson() { + Map toJson() { final end = this.end; final state = this.state; return { @@ -2519,6 +2619,7 @@ class GetRoomEventsResponse { List? state; } +/// @_NameSource('generated') @EnhancedEnum() enum ReceiptType { @@ -2530,6 +2631,7 @@ enum ReceiptType { mReadPrivate } +/// @_NameSource('spec') class IncludeEventContext { IncludeEventContext({ @@ -2538,13 +2640,13 @@ class IncludeEventContext { this.includeProfile, }); - IncludeEventContext.fromJson(Map json) + IncludeEventContext.fromJson(Map json) : afterLimit = ((v) => v != null ? v as int : null)(json['after_limit']), beforeLimit = ((v) => v != null ? v as int : null)(json['before_limit']), includeProfile = ((v) => v != null ? v as bool : null)(json['include_profile']); - Map toJson() { + Map toJson() { final afterLimit = this.afterLimit; final beforeLimit = this.beforeLimit; final includeProfile = this.includeProfile; @@ -2570,6 +2672,7 @@ class IncludeEventContext { bool? includeProfile; } +/// @_NameSource('spec') class EventFilter { EventFilter({ @@ -2580,7 +2683,7 @@ class EventFilter { this.types, }); - EventFilter.fromJson(Map json) + EventFilter.fromJson(Map json) : limit = ((v) => v != null ? v as int : null)(json['limit']), notSenders = ((v) => v != null ? (v as List).map((v) => v as String).toList() @@ -2594,7 +2697,7 @@ class EventFilter { types = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['types']); - Map toJson() { + Map toJson() { final limit = this.limit; final notSenders = this.notSenders; final notTypes = this.notTypes; @@ -2625,6 +2728,7 @@ class EventFilter { List? types; } +/// @_NameSource('spec') class RoomEventFilter { RoomEventFilter({ @@ -2636,7 +2740,7 @@ class RoomEventFilter { this.unreadThreadNotifications, }); - RoomEventFilter.fromJson(Map json) + RoomEventFilter.fromJson(Map json) : containsUrl = ((v) => v != null ? v as bool : null)(json['contains_url']), includeRedundantMembers = ((v) => @@ -2651,7 +2755,7 @@ class RoomEventFilter { : null)(json['rooms']), unreadThreadNotifications = ((v) => v != null ? v as bool : null)(json['unread_thread_notifications']); - Map toJson() { + Map toJson() { final containsUrl = this.containsUrl; final includeRedundantMembers = this.includeRedundantMembers; final lazyLoadMembers = this.lazyLoadMembers; @@ -2696,6 +2800,7 @@ class RoomEventFilter { bool? unreadThreadNotifications; } +/// @_NameSource('rule override generated') class SearchFilter implements EventFilter, RoomEventFilter { SearchFilter({ @@ -2712,7 +2817,7 @@ class SearchFilter implements EventFilter, RoomEventFilter { this.unreadThreadNotifications, }); - SearchFilter.fromJson(Map json) + SearchFilter.fromJson(Map json) : limit = ((v) => v != null ? v as int : null)(json['limit']), notSenders = ((v) => v != null ? (v as List).map((v) => v as String).toList() @@ -2740,7 +2845,7 @@ class SearchFilter implements EventFilter, RoomEventFilter { : null)(json['rooms']), unreadThreadNotifications = ((v) => v != null ? v as bool : null)(json['unread_thread_notifications']); - Map toJson() { + Map toJson() { final limit = this.limit; final notSenders = this.notSenders; final notTypes = this.notTypes; @@ -2810,6 +2915,7 @@ class SearchFilter implements EventFilter, RoomEventFilter { bool? unreadThreadNotifications; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum GroupKey { @@ -2826,10 +2932,11 @@ class Group { this.key, }); - Group.fromJson(Map json) - : key = ((v) => - v != null ? GroupKey.values.fromString(v)! : null)(json['key']); - Map toJson() { + Group.fromJson(Map json) + : key = ((v) => v != null + ? GroupKey.values.fromString(v as String)! + : null)(json['key']); + Map toJson() { final key = this.key; return { if (key != null) 'key': key.name, @@ -2840,17 +2947,20 @@ class Group { GroupKey? key; } +/// @_NameSource('spec') class Groupings { Groupings({ this.groupBy, }); - Groupings.fromJson(Map json) + Groupings.fromJson(Map json) : groupBy = ((v) => v != null - ? (v as List).map((v) => Group.fromJson(v)).toList() + ? (v as List) + .map((v) => Group.fromJson(v as Map)) + .toList() : null)(json['group_by']); - Map toJson() { + Map toJson() { final groupBy = this.groupBy; return { if (groupBy != null) 'group_by': groupBy.map((v) => v.toJson()).toList(), @@ -2861,6 +2971,7 @@ class Groupings { List? groupBy; } +/// @_NameSource('rule override generated') @EnhancedEnum() enum KeyKind { @@ -2872,6 +2983,7 @@ enum KeyKind { contentTopic } +/// @_NameSource('rule override generated') @EnhancedEnum() enum SearchOrder { @@ -2881,6 +2993,7 @@ enum SearchOrder { recent } +/// @_NameSource('spec') class RoomEventsCriteria { RoomEventsCriteria({ @@ -2893,23 +3006,28 @@ class RoomEventsCriteria { required this.searchTerm, }); - RoomEventsCriteria.fromJson(Map json) + RoomEventsCriteria.fromJson(Map json) : eventContext = ((v) => v != null - ? IncludeEventContext.fromJson(v) + ? IncludeEventContext.fromJson(v as Map) : null)(json['event_context']), - filter = ((v) => - v != null ? SearchFilter.fromJson(v) : null)(json['filter']), - groupings = ((v) => - v != null ? Groupings.fromJson(v) : null)(json['groupings']), + filter = ((v) => v != null + ? SearchFilter.fromJson(v as Map) + : null)(json['filter']), + groupings = ((v) => v != null + ? Groupings.fromJson(v as Map) + : null)(json['groupings']), includeState = ((v) => v != null ? v as bool : null)(json['include_state']), keys = ((v) => v != null - ? (v as List).map((v) => KeyKind.values.fromString(v)!).toList() + ? (v as List) + .map((v) => KeyKind.values.fromString(v as String)!) + .toList() : null)(json['keys']), - orderBy = ((v) => v != null ? SearchOrder.values.fromString(v)! : null)( - json['order_by']), + orderBy = ((v) => v != null + ? SearchOrder.values.fromString(v as String)! + : null)(json['order_by']), searchTerm = json['search_term'] as String; - Map toJson() { + Map toJson() { final eventContext = this.eventContext; final filter = this.filter; final groupings = this.groupings; @@ -2953,16 +3071,18 @@ class RoomEventsCriteria { String searchTerm; } +/// @_NameSource('spec') class Categories { Categories({ this.roomEvents, }); - Categories.fromJson(Map json) - : roomEvents = ((v) => v != null ? RoomEventsCriteria.fromJson(v) : null)( - json['room_events']); - Map toJson() { + Categories.fromJson(Map json) + : roomEvents = ((v) => v != null + ? RoomEventsCriteria.fromJson(v as Map) + : null)(json['room_events']); + Map toJson() { final roomEvents = this.roomEvents; return { if (roomEvents != null) 'room_events': roomEvents.toJson(), @@ -2982,13 +3102,13 @@ class GroupValue { this.results, }); - GroupValue.fromJson(Map json) + GroupValue.fromJson(Map json) : nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), order = ((v) => v != null ? v as int : null)(json['order']), results = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['results']); - Map toJson() { + Map toJson() { final nextBatch = this.nextBatch; final order = this.order; final results = this.results; @@ -3014,6 +3134,7 @@ class GroupValue { List? results; } +/// @_NameSource('spec') class UserProfile { UserProfile({ @@ -3021,12 +3142,12 @@ class UserProfile { this.displayname, }); - UserProfile.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + UserProfile.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), displayname = ((v) => v != null ? v as String : null)(json['displayname']); - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final displayname = this.displayname; return { @@ -3035,11 +3156,14 @@ class UserProfile { }; } + /// Uri? avatarUrl; + /// String? displayname; } +/// @_NameSource('rule override spec') class SearchResultsEventContext { SearchResultsEventContext({ @@ -3050,20 +3174,24 @@ class SearchResultsEventContext { this.start, }); - SearchResultsEventContext.fromJson(Map json) + SearchResultsEventContext.fromJson(Map json) : end = ((v) => v != null ? v as String : null)(json['end']), eventsAfter = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['events_after']), eventsBefore = ((v) => v != null - ? (v as List).map((v) => MatrixEvent.fromJson(v)).toList() + ? (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList() : null)(json['events_before']), profileInfo = ((v) => v != null - ? (v as Map) - .map((k, v) => MapEntry(k, UserProfile.fromJson(v))) + ? (v as Map).map((k, v) => + MapEntry(k, UserProfile.fromJson(v as Map))) : null)(json['profile_info']), start = ((v) => v != null ? v as String : null)(json['start']); - Map toJson() { + Map toJson() { final end = this.end; final eventsAfter = this.eventsAfter; final eventsBefore = this.eventsBefore; @@ -3110,14 +3238,15 @@ class Result { this.result, }); - Result.fromJson(Map json) + Result.fromJson(Map json) : context = ((v) => v != null - ? SearchResultsEventContext.fromJson(v) + ? SearchResultsEventContext.fromJson(v as Map) : null)(json['context']), rank = ((v) => v != null ? (v as num).toDouble() : null)(json['rank']), - result = - ((v) => v != null ? MatrixEvent.fromJson(v) : null)(json['result']); - Map toJson() { + result = ((v) => v != null + ? MatrixEvent.fromJson(v as Map) + : null)(json['result']); + Map toJson() { final context = this.context; final rank = this.rank; final result = this.result; @@ -3138,6 +3267,7 @@ class Result { MatrixEvent? result; } +/// @_NameSource('spec') class ResultRoomEvents { ResultRoomEvents({ @@ -3149,26 +3279,31 @@ class ResultRoomEvents { this.state, }); - ResultRoomEvents.fromJson(Map json) + ResultRoomEvents.fromJson(Map json) : count = ((v) => v != null ? v as int : null)(json['count']), groups = ((v) => v != null - ? (v as Map).map((k, v) => MapEntry( + ? (v as Map).map((k, v) => MapEntry( k, - (v as Map) - .map((k, v) => MapEntry(k, GroupValue.fromJson(v))))) + (v as Map).map((k, v) => MapEntry( + k, GroupValue.fromJson(v as Map))))) : null)(json['groups']), highlights = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['highlights']), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), results = ((v) => v != null - ? (v as List).map((v) => Result.fromJson(v)).toList() + ? (v as List) + .map((v) => Result.fromJson(v as Map)) + .toList() : null)(json['results']), state = ((v) => v != null - ? (v as Map).map((k, v) => MapEntry( - k, (v as List).map((v) => MatrixEvent.fromJson(v)).toList())) + ? (v as Map).map((k, v) => MapEntry( + k, + (v as List) + .map((v) => MatrixEvent.fromJson(v as Map)) + .toList())) : null)(json['state']); - Map toJson() { + Map toJson() { final count = this.count; final groups = this.groups; final highlights = this.highlights; @@ -3220,16 +3355,18 @@ class ResultRoomEvents { Map>? state; } +/// @_NameSource('spec') class ResultCategories { ResultCategories({ this.roomEvents, }); - ResultCategories.fromJson(Map json) - : roomEvents = ((v) => v != null ? ResultRoomEvents.fromJson(v) : null)( - json['room_events']); - Map toJson() { + ResultCategories.fromJson(Map json) + : roomEvents = ((v) => v != null + ? ResultRoomEvents.fromJson(v as Map) + : null)(json['room_events']); + Map toJson() { final roomEvents = this.roomEvents; return { if (roomEvents != null) 'room_events': roomEvents.toJson(), @@ -3240,15 +3377,17 @@ class ResultCategories { ResultRoomEvents? roomEvents; } +/// @_NameSource('rule override spec') class SearchResults { SearchResults({ required this.searchCategories, }); - SearchResults.fromJson(Map json) - : searchCategories = ResultCategories.fromJson(json['search_categories']); - Map toJson() => { + SearchResults.fromJson(Map json) + : searchCategories = ResultCategories.fromJson( + json['search_categories'] as Map); + Map toJson() => { 'search_categories': searchCategories.toJson(), }; @@ -3256,6 +3395,7 @@ class SearchResults { ResultCategories searchCategories; } +/// @_NameSource('spec') class Location { Location({ @@ -3264,11 +3404,11 @@ class Location { required this.protocol, }); - Location.fromJson(Map json) + Location.fromJson(Map json) : alias = json['alias'] as String, - fields = json['fields'] as Map, + fields = json['fields'] as Map, protocol = json['protocol'] as String; - Map toJson() => { + Map toJson() => { 'alias': alias, 'fields': fields, 'protocol': protocol, @@ -3278,7 +3418,7 @@ class Location { String alias; /// Information used to identify this third party location. - Map fields; + Map fields; /// The protocol ID that the third party location is a part of. String protocol; @@ -3292,10 +3432,10 @@ class FieldType { required this.regexp, }); - FieldType.fromJson(Map json) + FieldType.fromJson(Map json) : placeholder = json['placeholder'] as String, regexp = json['regexp'] as String; - Map toJson() => { + Map toJson() => { 'placeholder': placeholder, 'regexp': regexp, }; @@ -3309,6 +3449,7 @@ class FieldType { String regexp; } +/// @_NameSource('spec') class ProtocolInstance { ProtocolInstance({ @@ -3318,12 +3459,12 @@ class ProtocolInstance { required this.networkId, }); - ProtocolInstance.fromJson(Map json) + ProtocolInstance.fromJson(Map json) : desc = json['desc'] as String, - fields = json['fields'] as Map, + fields = json['fields'] as Map, icon = ((v) => v != null ? v as String : null)(json['icon']), networkId = json['network_id'] as String; - Map toJson() { + Map toJson() { final icon = this.icon; return { 'desc': desc, @@ -3337,7 +3478,7 @@ class ProtocolInstance { String desc; /// Preset values for `fields` the client may use to search by. - Map fields; + Map fields; /// An optional content URI representing the protocol. Overrides the one provided /// at the higher level Protocol object. @@ -3347,6 +3488,7 @@ class ProtocolInstance { String networkId; } +/// @_NameSource('spec') class Protocol { Protocol({ @@ -3357,18 +3499,18 @@ class Protocol { required this.userFields, }); - Protocol.fromJson(Map json) - : fieldTypes = (json['field_types'] as Map) - .map((k, v) => MapEntry(k, FieldType.fromJson(v))), + Protocol.fromJson(Map json) + : fieldTypes = (json['field_types'] as Map).map((k, v) => + MapEntry(k, FieldType.fromJson(v as Map))), icon = json['icon'] as String, instances = (json['instances'] as List) - .map((v) => ProtocolInstance.fromJson(v)) + .map((v) => ProtocolInstance.fromJson(v as Map)) .toList(), locationFields = (json['location_fields'] as List).map((v) => v as String).toList(), userFields = (json['user_fields'] as List).map((v) => v as String).toList(); - Map toJson() => { + Map toJson() => { 'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())), 'icon': icon, 'instances': instances.map((v) => v.toJson()).toList(), @@ -3404,6 +3546,7 @@ class Protocol { List userFields; } +/// @_NameSource('rule override spec') class ThirdPartyUser { ThirdPartyUser({ @@ -3412,18 +3555,18 @@ class ThirdPartyUser { required this.userid, }); - ThirdPartyUser.fromJson(Map json) - : fields = json['fields'] as Map, + ThirdPartyUser.fromJson(Map json) + : fields = json['fields'] as Map, protocol = json['protocol'] as String, userid = json['userid'] as String; - Map toJson() => { + Map toJson() => { 'fields': fields, 'protocol': protocol, 'userid': userid, }; /// Information used to identify this third party location. - Map fields; + Map fields; /// The protocol ID that the third party location is a part of. String protocol; @@ -3432,6 +3575,7 @@ class ThirdPartyUser { String userid; } +/// @_NameSource('generated') @EnhancedEnum() enum EventFormat { @@ -3441,6 +3585,7 @@ enum EventFormat { federation } +/// @_NameSource('rule override generated') class StateFilter implements EventFilter, RoomEventFilter { StateFilter({ @@ -3457,7 +3602,7 @@ class StateFilter implements EventFilter, RoomEventFilter { this.unreadThreadNotifications, }); - StateFilter.fromJson(Map json) + StateFilter.fromJson(Map json) : limit = ((v) => v != null ? v as int : null)(json['limit']), notSenders = ((v) => v != null ? (v as List).map((v) => v as String).toList() @@ -3485,7 +3630,7 @@ class StateFilter implements EventFilter, RoomEventFilter { : null)(json['rooms']), unreadThreadNotifications = ((v) => v != null ? v as bool : null)(json['unread_thread_notifications']); - Map toJson() { + Map toJson() { final limit = this.limit; final notSenders = this.notSenders; final notTypes = this.notTypes; @@ -3555,6 +3700,7 @@ class StateFilter implements EventFilter, RoomEventFilter { bool? unreadThreadNotifications; } +/// @_NameSource('spec') class RoomFilter { RoomFilter({ @@ -3567,11 +3713,13 @@ class RoomFilter { this.timeline, }); - RoomFilter.fromJson(Map json) - : accountData = ((v) => - v != null ? StateFilter.fromJson(v) : null)(json['account_data']), - ephemeral = ((v) => - v != null ? StateFilter.fromJson(v) : null)(json['ephemeral']), + RoomFilter.fromJson(Map json) + : accountData = ((v) => v != null + ? StateFilter.fromJson(v as Map) + : null)(json['account_data']), + ephemeral = ((v) => v != null + ? StateFilter.fromJson(v as Map) + : null)(json['ephemeral']), includeLeave = ((v) => v != null ? v as bool : null)(json['include_leave']), notRooms = ((v) => v != null @@ -3580,11 +3728,13 @@ class RoomFilter { rooms = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['rooms']), - state = - ((v) => v != null ? StateFilter.fromJson(v) : null)(json['state']), - timeline = ((v) => - v != null ? StateFilter.fromJson(v) : null)(json['timeline']); - Map toJson() { + state = ((v) => v != null + ? StateFilter.fromJson(v as Map) + : null)(json['state']), + timeline = ((v) => v != null + ? StateFilter.fromJson(v as Map) + : null)(json['timeline']); + Map toJson() { final accountData = this.accountData; final ephemeral = this.ephemeral; final includeLeave = this.includeLeave; @@ -3625,6 +3775,7 @@ class RoomFilter { StateFilter? timeline; } +/// @_NameSource('spec') class Filter { Filter({ @@ -3635,19 +3786,23 @@ class Filter { this.room, }); - Filter.fromJson(Map json) - : accountData = ((v) => - v != null ? EventFilter.fromJson(v) : null)(json['account_data']), + Filter.fromJson(Map json) + : accountData = ((v) => v != null + ? EventFilter.fromJson(v as Map) + : null)(json['account_data']), eventFields = ((v) => v != null ? (v as List).map((v) => v as String).toList() : null)(json['event_fields']), eventFormat = ((v) => v != null - ? EventFormat.values.fromString(v)! + ? EventFormat.values.fromString(v as String)! : null)(json['event_format']), - presence = ((v) => - v != null ? EventFilter.fromJson(v) : null)(json['presence']), - room = ((v) => v != null ? RoomFilter.fromJson(v) : null)(json['room']); - Map toJson() { + presence = ((v) => v != null + ? EventFilter.fromJson(v as Map) + : null)(json['presence']), + room = ((v) => v != null + ? RoomFilter.fromJson(v as Map) + : null)(json['room']); + Map toJson() { final accountData = this.accountData; final eventFields = this.eventFields; final eventFormat = this.eventFormat; @@ -3679,6 +3834,7 @@ class Filter { RoomFilter? room; } +/// @_NameSource('spec') class OpenIdCredentials { OpenIdCredentials({ @@ -3688,12 +3844,12 @@ class OpenIdCredentials { required this.tokenType, }); - OpenIdCredentials.fromJson(Map json) + OpenIdCredentials.fromJson(Map json) : accessToken = json['access_token'] as String, expiresIn = json['expires_in'] as int, matrixServerName = json['matrix_server_name'] as String, tokenType = json['token_type'] as String; - Map toJson() => { + Map toJson() => { 'access_token': accessToken, 'expires_in': expiresIn, 'matrix_server_name': matrixServerName, @@ -3717,6 +3873,7 @@ class OpenIdCredentials { String tokenType; } +/// @_NameSource('spec') class Tag { Tag({ @@ -3724,13 +3881,13 @@ class Tag { this.additionalProperties = const {}, }); - Tag.fromJson(Map json) + Tag.fromJson(Map json) : order = ((v) => v != null ? (v as num).toDouble() : null)(json['order']), additionalProperties = Map.fromEntries(json.entries .where((e) => !['order'].contains(e.key)) - .map((e) => MapEntry(e.key, e.value as dynamic))); - Map toJson() { + .map((e) => MapEntry(e.key, e.value as Object?))); + Map toJson() { final order = this.order; return { ...additionalProperties, @@ -3742,9 +3899,10 @@ class Tag { /// position of the room under the given tag. double? order; - Map additionalProperties; + Map additionalProperties; } +/// @_NameSource('rule override spec') class Profile { Profile({ @@ -3753,13 +3911,13 @@ class Profile { required this.userId, }); - Profile.fromJson(Map json) - : avatarUrl = - ((v) => v != null ? Uri.parse(v) : null)(json['avatar_url']), + Profile.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), displayName = ((v) => v != null ? v as String : null)(json['display_name']), userId = json['user_id'] as String; - Map toJson() { + Map toJson() { final avatarUrl = this.avatarUrl; final displayName = this.displayName; return { @@ -3779,6 +3937,7 @@ class Profile { String userId; } +/// @_NameSource('generated') class SearchUserDirectoryResponse { SearchUserDirectoryResponse({ @@ -3786,11 +3945,12 @@ class SearchUserDirectoryResponse { required this.results, }); - SearchUserDirectoryResponse.fromJson(Map json) + SearchUserDirectoryResponse.fromJson(Map json) : limited = json['limited'] as bool, - results = - (json['results'] as List).map((v) => Profile.fromJson(v)).toList(); - Map toJson() => { + results = (json['results'] as List) + .map((v) => Profile.fromJson(v as Map)) + .toList(); + Map toJson() => { 'limited': limited, 'results': results.map((v) => v.toJson()).toList(), }; @@ -3802,6 +3962,7 @@ class SearchUserDirectoryResponse { List results; } +/// @_NameSource('rule override generated') class TurnServerCredentials { TurnServerCredentials({ @@ -3811,12 +3972,12 @@ class TurnServerCredentials { required this.username, }); - TurnServerCredentials.fromJson(Map json) + TurnServerCredentials.fromJson(Map json) : password = json['password'] as String, ttl = json['ttl'] as int, uris = (json['uris'] as List).map((v) => v as String).toList(), username = json['username'] as String; - Map toJson() => { + Map toJson() => { 'password': password, 'ttl': ttl, 'uris': uris.map((v) => v).toList(), @@ -3836,6 +3997,7 @@ class TurnServerCredentials { String username; } +/// @_NameSource('generated') class GetVersionsResponse { GetVersionsResponse({ @@ -3843,12 +4005,12 @@ class GetVersionsResponse { required this.versions, }); - GetVersionsResponse.fromJson(Map json) + GetVersionsResponse.fromJson(Map json) : unstableFeatures = ((v) => v != null - ? (v as Map).map((k, v) => MapEntry(k, v as bool)) + ? (v as Map).map((k, v) => MapEntry(k, v as bool)) : null)(json['unstable_features']), versions = (json['versions'] as List).map((v) => v as String).toList(); - Map toJson() { + Map toJson() { final unstableFeatures = this.unstableFeatures; return { if (unstableFeatures != null) @@ -3866,16 +4028,17 @@ class GetVersionsResponse { List versions; } +/// @_NameSource('rule override generated') class ServerConfig { ServerConfig({ this.mUploadSize, }); - ServerConfig.fromJson(Map json) + ServerConfig.fromJson(Map json) : mUploadSize = ((v) => v != null ? v as int : null)(json['m.upload.size']); - Map toJson() { + Map toJson() { final mUploadSize = this.mUploadSize; return { if (mUploadSize != null) 'm.upload.size': mUploadSize, @@ -3888,6 +4051,7 @@ class ServerConfig { int? mUploadSize; } +/// @_NameSource('generated') class GetUrlPreviewResponse { GetUrlPreviewResponse({ @@ -3895,11 +4059,12 @@ class GetUrlPreviewResponse { this.ogImage, }); - GetUrlPreviewResponse.fromJson(Map json) + GetUrlPreviewResponse.fromJson(Map json) : matrixImageSize = ((v) => v != null ? v as int : null)(json['matrix:image:size']), - ogImage = ((v) => v != null ? Uri.parse(v) : null)(json['og:image']); - Map toJson() { + ogImage = ((v) => + v != null ? Uri.parse(v as String) : null)(json['og:image']); + Map toJson() { final matrixImageSize = this.matrixImageSize; final ogImage = this.ogImage; return { @@ -3915,6 +4080,7 @@ class GetUrlPreviewResponse { Uri? ogImage; } +/// @_NameSource('generated') @EnhancedEnum() enum Method {