diff --git a/lib/src/generated/api.dart b/lib/src/generated/api.dart index 72d386f9..059101ab 100644 --- a/lib/src/generated/api.dart +++ b/lib/src/generated/api.dart @@ -98,10 +98,7 @@ class Api { /// [from] A pagination token from a previous result. If specified, `max_depth` and `suggested_only` cannot /// be changed from the first request. Future getSpaceHierarchy(String roomId, - {bool? suggestedOnly, - double? limit, - double? maxDepth, - String? from}) async { + {bool? suggestedOnly, int? limit, int? maxDepth, String? from}) async { final requestUri = Uri( path: '_matrix/client/v1/rooms/${Uri.encodeComponent(roomId)}/hierarchy', @@ -3234,6 +3231,10 @@ class Api { /// by a previous request to this endpoint, though servers are not /// required to support this. Clients should not rely on the behaviour. /// + /// If it is not provided, the homeserver shall return a list of messages + /// from the first or last (per the value of the `dir` parameter) visible + /// event in the room history for the requesting user. + /// /// [to] The token to stop returning events at. This token can be obtained from /// a `prev_batch` or `next_batch` token returned by the `/sync` endpoint, /// or from an `end` token returned by a previous request to this endpoint. @@ -3246,13 +3247,12 @@ class Api { /// [limit] The maximum number of events to return. Default: 10. /// /// [filter] A JSON RoomEventFilter to filter returned events with. - Future getRoomEvents( - String roomId, String from, Direction dir, - {String? to, int? limit, String? filter}) async { + Future getRoomEvents(String roomId, Direction dir, + {String? from, String? to, int? limit, String? filter}) async { final requestUri = Uri( path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/messages', queryParameters: { - 'from': from, + if (from != null) 'from': from, if (to != null) 'to': to, 'dir': dir.name, if (limit != null) 'limit': limit.toString(), diff --git a/lib/src/generated/model.dart b/lib/src/generated/model.dart index db8cb054..1ccbebd9 100644 --- a/lib/src/generated/model.dart +++ b/lib/src/generated/model.dart @@ -164,18 +164,21 @@ class PublicRoomsChunk { class SpaceRoomsChunkBase { SpaceRoomsChunkBase({ required this.childrenState, - required this.roomType, + this.roomType, }); SpaceRoomsChunkBase.fromJson(Map json) : childrenState = (json['children_state'] as List) .map((v) => MatrixEvent.fromJson(v)) .toList(), - roomType = json['room_type'] as String; - Map toJson() => { - 'children_state': childrenState.map((v) => v.toJson()).toList(), - 'room_type': roomType, - }; + roomType = ((v) => v != null ? v as String : null)(json['room_type']); + Map toJson() { + final roomType = this.roomType; + return { + 'children_state': childrenState.map((v) => v.toJson()).toList(), + if (roomType != null) 'room_type': roomType, + }; + } /// The [`m.space.child`](#mspacechild) events of the space-room, represented /// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key. @@ -184,7 +187,7 @@ class SpaceRoomsChunkBase { List childrenState; /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. - String roomType; + String? roomType; } @_NameSource('rule override generated') @@ -200,7 +203,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase { this.topic, required this.worldReadable, required this.childrenState, - required this.roomType, + this.roomType, }); SpaceRoomsChunk.fromJson(Map json) @@ -218,13 +221,14 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase { childrenState = (json['children_state'] as List) .map((v) => MatrixEvent.fromJson(v)) .toList(), - roomType = json['room_type'] as String; + roomType = ((v) => v != null ? v as String : null)(json['room_type']); Map toJson() { final avatarUrl = this.avatarUrl; final canonicalAlias = this.canonicalAlias; final joinRule = this.joinRule; final name = this.name; final topic = this.topic; + final roomType = this.roomType; return { if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), if (canonicalAlias != null) 'canonical_alias': canonicalAlias, @@ -236,7 +240,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase { if (topic != null) 'topic': topic, 'world_readable': worldReadable, 'children_state': childrenState.map((v) => v.toJson()).toList(), - 'room_type': roomType, + if (roomType != null) 'room_type': roomType, }; } @@ -277,7 +281,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase { List childrenState; /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. - String roomType; + String? roomType; } @_NameSource('generated') diff --git a/test/matrix_api_test.dart b/test/matrix_api_test.dart index 0090ddcf..15a4999a 100644 --- a/test/matrix_api_test.dart +++ b/test/matrix_api_test.dart @@ -566,8 +566,8 @@ void main() { final timelineHistoryResponse = await matrixApi.getRoomEvents( '!localpart:server.abc', - '1234', Direction.b, + from: '1234', limit: 10, filter: '{"lazy_load_members":true}', to: '1234',