feat!: operation names from OpenAPI spec

This commit is contained in:
Lukas Lihotzki 2021-05-07 13:43:06 +02:00
parent d667f63675
commit 3eaf4ef99a
2 changed files with 157 additions and 159 deletions

View File

@ -219,7 +219,7 @@ class MatrixApi {
/// Gets the versions of the specification supported by the server. /// Gets the versions of the specification supported by the server.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-versions /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-versions
Future<SupportedVersions> requestSupportedVersions() async { Future<SupportedVersions> getVersions() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/versions', '/client/versions',
@ -229,14 +229,14 @@ class MatrixApi {
/// Gets discovery information about the domain. The file may include additional keys. /// Gets discovery information about the domain. The file may include additional keys.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-well-known-matrix-client /// https://matrix.org/docs/spec/client_server/r0.6.0#get-well-known-matrix-client
Future<WellKnownInformation> requestWellKnownInformation() async { Future<WellKnownInformation> getWellknown() async {
final response = final response =
await httpClient.get(homeserver.resolve('.well-known/matrix/client')); await httpClient.get(homeserver.resolve('.well-known/matrix/client'));
final rawJson = json.decode(response.body); final rawJson = json.decode(response.body);
return WellKnownInformation.fromJson(rawJson); return WellKnownInformation.fromJson(rawJson);
} }
Future<LoginTypes> requestLoginTypes() async { Future<LoginTypes> getLoginFlows() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/login', '/client/r0/login',
@ -473,7 +473,7 @@ class MatrixApi {
); );
} }
Future<bool> usernameAvailable(String username) async { Future<bool> checkUsernameAvailability(String username) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/register/available', '/client/r0/register/available',
@ -487,7 +487,7 @@ class MatrixApi {
/// Gets a list of the third party identifiers that the homeserver has /// Gets a list of the third party identifiers that the homeserver has
/// associated with the user's account. /// associated with the user's account.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-register-available /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-register-available
Future<List<ThirdPartyIdentifier>> requestThirdPartyIdentifiers() async { Future<List<ThirdPartyIdentifier>> getAccount3PIDs() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/account/3pid', '/client/r0/account/3pid',
@ -501,7 +501,7 @@ class MatrixApi {
/// should use 3PIDs added through this endpoint for password resets /// should use 3PIDs added through this endpoint for password resets
/// instead of relying on the identity server. /// instead of relying on the identity server.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-add /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-add
Future<void> addThirdPartyIdentifier( Future<void> add3PID(
String clientSecret, String clientSecret,
String sid, { String sid, {
AuthenticationData auth, AuthenticationData auth,
@ -516,7 +516,7 @@ class MatrixApi {
/// Binds a 3PID to the user's account through the specified identity server. /// Binds a 3PID to the user's account through the specified identity server.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-bind /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-bind
Future<void> bindThirdPartyIdentifier( Future<void> bind3PID(
String clientSecret, String clientSecret,
String sid, String sid,
String idServer, String idServer,
@ -533,7 +533,7 @@ class MatrixApi {
/// Removes a third party identifier from the user's account. This might not cause an unbind of the identifier from the identity server. /// Removes a third party identifier from the user's account. This might not cause an unbind of the identifier from the identity server.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-delete /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-delete
Future<IdServerUnbindResult> deleteThirdPartyIdentifier( Future<IdServerUnbindResult> delete3pidFromAccount(
String address, String address,
ThirdPartyIdentifierMedium medium, { ThirdPartyIdentifierMedium medium, {
String idServer, String idServer,
@ -552,7 +552,7 @@ class MatrixApi {
/// Removes a user's third party identifier from the provided identity server without removing it from the homeserver. /// Removes a user's third party identifier from the provided identity server without removing it from the homeserver.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-unbind /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-unbind
Future<IdServerUnbindResult> unbindThirdPartyIdentifier( Future<IdServerUnbindResult> unbind3pidFromAccount(
String address, String address,
ThirdPartyIdentifierMedium medium, ThirdPartyIdentifierMedium medium,
String idServer, String idServer,
@ -619,7 +619,7 @@ class MatrixApi {
/// Gets information about the owner of a given access token. /// Gets information about the owner of a given access token.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-account-whoami /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-account-whoami
Future<String> whoAmI() async { Future<String> getTokenOwner() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/account/whoami', '/client/r0/account/whoami',
@ -629,7 +629,7 @@ class MatrixApi {
/// Gets information about the server's supported feature set and other relevant capabilities. /// Gets information about the server's supported feature set and other relevant capabilities.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-capabilities /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-capabilities
Future<ServerCapabilities> requestServerCapabilities() async { Future<ServerCapabilities> getCapabilities() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/capabilities', '/client/r0/capabilities',
@ -640,7 +640,7 @@ class MatrixApi {
/// Uploads a new filter definition to the homeserver. Returns a filter ID that may be used /// Uploads a new filter definition to the homeserver. Returns a filter ID that may be used
/// in future requests to restrict which events are returned to the client. /// in future requests to restrict which events are returned to the client.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter
Future<String> uploadFilter( Future<String> defineFilter(
String userId, String userId,
Filter filter, Filter filter,
) async { ) async {
@ -654,7 +654,7 @@ class MatrixApi {
/// Download a filter /// Download a filter
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter
Future<Filter> downloadFilter(String userId, String filterId) async { Future<Filter> getFilter(String userId, String filterId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/user/${Uri.encodeComponent(userId)}/filter/${Uri.encodeComponent(filterId)}', '/client/r0/user/${Uri.encodeComponent(userId)}/filter/${Uri.encodeComponent(filterId)}',
@ -690,7 +690,7 @@ class MatrixApi {
/// Get a single event based on roomId/eventId. You must have permission to /// Get a single event based on roomId/eventId. You must have permission to
/// retrieve this event e.g. by being a member in the room for this event. /// retrieve this event e.g. by being a member in the room for this event.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-event-eventid /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-event-eventid
Future<MatrixEvent> requestEvent(String roomId, String eventId) async { Future<MatrixEvent> getOneRoomEvent(String roomId, String eventId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/event/${Uri.encodeComponent(eventId)}', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/event/${Uri.encodeComponent(eventId)}',
@ -719,7 +719,7 @@ class MatrixApi {
/// Get the state events for the current state of a room. /// Get the state events for the current state of a room.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state
Future<List<MatrixEvent>> requestStates(String roomId) async { Future<List<MatrixEvent>> getRoomState(String roomId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/state', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/state',
@ -731,7 +731,7 @@ class MatrixApi {
/// Get the list of members for this room. /// Get the list of members for this room.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members
Future<List<MatrixEvent>> requestMembers( Future<List<MatrixEvent>> getMembersByRoom(
String roomId, { String roomId, {
String at, String at,
Membership membership, Membership membership,
@ -754,7 +754,7 @@ class MatrixApi {
/// This API returns a map of MXIDs to member info objects for members of the room. /// This API returns a map of MXIDs to member info objects for members of the room.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-joined-members /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-joined-members
Future<Map<String, Profile>> requestJoinedMembers(String roomId) async { Future<Map<String, Profile>> getJoinedMembersByRoom(String roomId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/joined_members', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/joined_members',
@ -767,7 +767,7 @@ class MatrixApi {
/// This API returns a list of message and state events for a room. It uses pagination query /// This API returns a list of message and state events for a room. It uses pagination query
/// parameters to paginate history in the room. /// parameters to paginate history in the room.
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages /// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages
Future<TimelineHistoryResponse> requestMessages( Future<TimelineHistoryResponse> getRoomEvents(
String roomId, String roomId,
String from, String from,
Direction dir, { Direction dir, {
@ -789,7 +789,7 @@ class MatrixApi {
/// State events can be sent using this endpoint. /// State events can be sent using this endpoint.
/// https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey /// https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey
Future<String> sendState( Future<String> setRoomStateWithKey(
String roomId, String roomId,
String eventType, String eventType,
Map<String, dynamic> content, [ Map<String, dynamic> content, [
@ -820,7 +820,7 @@ class MatrixApi {
/// Strips all information out of an event which isn't critical to the integrity of /// Strips all information out of an event which isn't critical to the integrity of
/// the server-side representation of the room. /// the server-side representation of the room.
/// https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid /// https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
Future<String> redact( Future<String> redactEvent(
String roomId, String roomId,
String eventId, String eventId,
String txnId, { String txnId, {
@ -869,7 +869,7 @@ class MatrixApi {
/// Create a new mapping from room alias to room ID. /// Create a new mapping from room alias to room ID.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-directory-room-roomalias /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-directory-room-roomalias
Future<void> createRoomAlias(String alias, String roomId) async { Future<void> setRoomAlias(String alias, String roomId) async {
await request( await request(
RequestType.PUT, RequestType.PUT,
'/client/r0/directory/room/${Uri.encodeComponent(alias)}', '/client/r0/directory/room/${Uri.encodeComponent(alias)}',
@ -880,7 +880,7 @@ class MatrixApi {
/// Requests that the server resolve a room alias to a room ID. /// Requests that the server resolve a room alias to a room ID.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-room-roomalias /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-room-roomalias
Future<RoomAliasInformation> requestRoomAliasInformation(String alias) async { Future<RoomAliasInformation> getRoomIdByAlias(String alias) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/directory/room/${Uri.encodeComponent(alias)}', '/client/r0/directory/room/${Uri.encodeComponent(alias)}',
@ -890,7 +890,7 @@ class MatrixApi {
/// Remove a mapping of room alias to room ID. /// Remove a mapping of room alias to room ID.
/// https://matrix.org/docs/spec/client_server/r0.6.1#delete-matrix-client-r0-directory-room-roomalias /// https://matrix.org/docs/spec/client_server/r0.6.1#delete-matrix-client-r0-directory-room-roomalias
Future<void> removeRoomAlias(String alias) async { Future<void> deleteRoomAlias(String alias) async {
await request( await request(
RequestType.DELETE, RequestType.DELETE,
'/client/r0/directory/room/${Uri.encodeComponent(alias)}', '/client/r0/directory/room/${Uri.encodeComponent(alias)}',
@ -900,7 +900,7 @@ class MatrixApi {
/// Get a list of aliases maintained by the local server for the given room. /// Get a list of aliases maintained by the local server for the given room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
Future<List<String>> requestRoomAliases(String roomId) async { Future<List<String>> getLocalAliases(String roomId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/aliases', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/aliases',
@ -910,7 +910,7 @@ class MatrixApi {
/// This API returns a list of the user's current rooms. /// This API returns a list of the user's current rooms.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-joined-rooms /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-joined-rooms
Future<List<String>> requestJoinedRooms() async { Future<List<String>> getJoinedRooms() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/joined_rooms', '/client/r0/joined_rooms',
@ -933,7 +933,7 @@ class MatrixApi {
/// This API starts a user participating in a particular room, if that user is allowed to participate in that room. /// This API starts a user participating in a particular room, if that user is allowed to participate in that room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-invite /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-invite
Future<String> joinRoom( Future<String> joinRoomById(
String roomId, { String roomId, {
String thirdPidSignedSender, String thirdPidSignedSender,
String thirdPidSignedmxid, String thirdPidSignedmxid,
@ -958,7 +958,7 @@ class MatrixApi {
/// This API starts a user participating in a particular room, if that user is allowed to participate in that room. /// This API starts a user participating in a particular room, if that user is allowed to participate in that room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-join-roomidoralias /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-join-roomidoralias
Future<String> joinRoomOrAlias( Future<String> joinRoom(
String roomIdOrAlias, { String roomIdOrAlias, {
List<String> servers, List<String> servers,
String thirdPidSignedSender, String thirdPidSignedSender,
@ -1006,8 +1006,7 @@ class MatrixApi {
/// Kick a user from the room. /// Kick a user from the room.
/// The caller must have the required power level in order to perform this operation. /// The caller must have the required power level in order to perform this operation.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-kick /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-kick
Future<void> kickFromRoom(String roomId, String userId, Future<void> kick(String roomId, String userId, {String reason}) async {
{String reason}) async {
await request(RequestType.POST, await request(RequestType.POST,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/kick', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/kick',
data: { data: {
@ -1019,8 +1018,7 @@ class MatrixApi {
/// Ban a user in the room. If the user is currently in the room, also kick them. /// Ban a user in the room. If the user is currently in the room, also kick them.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-ban /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-ban
Future<void> banFromRoom(String roomId, String userId, Future<void> ban(String roomId, String userId, {String reason}) async {
{String reason}) async {
await request( await request(
RequestType.POST, '/client/r0/rooms/${Uri.encodeComponent(roomId)}/ban', RequestType.POST, '/client/r0/rooms/${Uri.encodeComponent(roomId)}/ban',
data: { data: {
@ -1033,7 +1031,7 @@ class MatrixApi {
/// Unban a user from the room. This allows them to be invited to the room, and join if they /// Unban a user from the room. This allows them to be invited to the room, and join if they
/// would otherwise be allowed to join according to its join rules. /// would otherwise be allowed to join according to its join rules.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-unban /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-unban
Future<void> unbanInRoom(String roomId, String userId) async { Future<void> unban(String roomId, String userId) async {
await request(RequestType.POST, await request(RequestType.POST,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/unban', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/unban',
data: { data: {
@ -1044,7 +1042,7 @@ class MatrixApi {
/// Gets the visibility of a given room on the server's public room directory. /// Gets the visibility of a given room on the server's public room directory.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-list-room-roomid /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-directory-list-room-roomid
Future<Visibility> requestRoomVisibility(String roomId) async { Future<Visibility> getRoomVisibilityOnDirectory(String roomId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/directory/list/room/${Uri.encodeComponent(roomId)}', '/client/r0/directory/list/room/${Uri.encodeComponent(roomId)}',
@ -1055,7 +1053,8 @@ class MatrixApi {
/// Sets the visibility of a given room in the server's public room directory. /// Sets the visibility of a given room in the server's public room directory.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-directory-list-room-roomid /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-directory-list-room-roomid
Future<void> setRoomVisibility(String roomId, Visibility visibility) async { Future<void> setRoomVisibilityOnDirectory(
String roomId, Visibility visibility) async {
await request( await request(
RequestType.PUT, RequestType.PUT,
'/client/r0/directory/list/room/${Uri.encodeComponent(roomId)}', '/client/r0/directory/list/room/${Uri.encodeComponent(roomId)}',
@ -1068,7 +1067,7 @@ class MatrixApi {
/// Lists the public rooms on the server. /// Lists the public rooms on the server.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-publicrooms /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-publicrooms
Future<PublicRoomsResponse> requestPublicRooms({ Future<PublicRoomsResponse> getPublicRooms({
int limit, int limit,
String since, String since,
String server, String server,
@ -1087,7 +1086,7 @@ class MatrixApi {
/// Lists the public rooms on the server, with optional filter. /// Lists the public rooms on the server, with optional filter.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-publicrooms /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-publicrooms
Future<PublicRoomsResponse> searchPublicRooms({ Future<PublicRoomsResponse> queryPublicRooms({
String genericSearchTerm, String genericSearchTerm,
int limit, int limit,
String since, String since,
@ -1122,7 +1121,7 @@ class MatrixApi {
/// room with and those who reside in public rooms (known to the homeserver). The search MUST /// room with and those who reside in public rooms (known to the homeserver). The search MUST
/// consider local users to the homeserver, and SHOULD query remote users as part of the search. /// consider local users to the homeserver, and SHOULD query remote users as part of the search.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-user-directory-search /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-user-directory-search
Future<UserSearchResult> searchUser( Future<UserSearchResult> searchUserDirectory(
String searchTerm, { String searchTerm, {
int limit, int limit,
}) async { }) async {
@ -1140,7 +1139,7 @@ class MatrixApi {
/// This API sets the given user's display name. You must have permission to /// This API sets the given user's display name. You must have permission to
/// set this user's display name, e.g. you need to have their access_token. /// set this user's display name, e.g. you need to have their access_token.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-profile-userid-displayname /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-profile-userid-displayname
Future<void> setDisplayname(String userId, String displayname) async { Future<void> setDisplayName(String userId, String displayname) async {
await request( await request(
RequestType.PUT, RequestType.PUT,
'/client/r0/profile/${Uri.encodeComponent(userId)}/displayname', '/client/r0/profile/${Uri.encodeComponent(userId)}/displayname',
@ -1154,7 +1153,7 @@ class MatrixApi {
/// Get the user's display name. This API may be used to fetch the user's own /// Get the user's display name. This API may be used to fetch the user's own
/// displayname or to query the name of other users; either locally or on remote homeservers. /// displayname or to query the name of other users; either locally or on remote homeservers.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-displayname /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-displayname
Future<String> requestDisplayname(String userId) async { Future<String> getDisplayName(String userId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/profile/${Uri.encodeComponent(userId)}/displayname', '/client/r0/profile/${Uri.encodeComponent(userId)}/displayname',
@ -1179,7 +1178,7 @@ class MatrixApi {
/// Get the user's avatar URL. This API may be used to fetch the user's own avatar URL or to /// Get the user's avatar URL. This API may be used to fetch the user's own avatar URL or to
/// query the URL of other users; either locally or on remote homeservers. /// query the URL of other users; either locally or on remote homeservers.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-avatar-url /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-avatar-url
Future<Uri> requestAvatarUrl(String userId) async { Future<Uri> getAvatarUrl(String userId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/profile/${Uri.encodeComponent(userId)}/avatar_url', '/client/r0/profile/${Uri.encodeComponent(userId)}/avatar_url',
@ -1190,7 +1189,7 @@ class MatrixApi {
/// Get the combined profile information for this user. This API may be used to fetch the user's /// Get the combined profile information for this user. This API may be used to fetch the user's
/// own profile information or other users; either locally or on remote homeservers. /// own profile information or other users; either locally or on remote homeservers.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-avatar-url /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-profile-userid-avatar-url
Future<Profile> requestProfile(String userId) async { Future<Profile> getUserProfile(String userId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/profile/${Uri.encodeComponent(userId)}', '/client/r0/profile/${Uri.encodeComponent(userId)}',
@ -1200,7 +1199,7 @@ class MatrixApi {
/// This API provides credentials for the client to use when initiating calls. /// This API provides credentials for the client to use when initiating calls.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-voip-turnserver /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-voip-turnserver
Future<TurnServerCredentials> requestTurnServerCredentials() async { Future<TurnServerCredentials> getTurnServer() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/voip/turnServer', '/client/r0/voip/turnServer',
@ -1212,7 +1211,7 @@ class MatrixApi {
/// where N is the value specified in the timeout key. Alternatively, if typing is false, /// where N is the value specified in the timeout key. Alternatively, if typing is false,
/// it tells the server that the user has stopped typing. /// it tells the server that the user has stopped typing.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-typing-userid /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-typing-userid
Future<void> sendTypingNotification( Future<void> setTyping(
String userId, String userId,
String roomId, String roomId,
bool typing, { bool typing, {
@ -1230,7 +1229,7 @@ class MatrixApi {
/// This API updates the marker for the given receipt type to the event ID specified. /// This API updates the marker for the given receipt type to the event ID specified.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid
/// ///
Future<void> sendReceiptMarker(String roomId, String eventId) async { Future<void> postReceipt(String roomId, String eventId) async {
await request( await request(
RequestType.POST, RequestType.POST,
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/receipt/m.read/${Uri.encodeComponent(eventId)}', '/client/r0/rooms/${Uri.encodeComponent(roomId)}/receipt/m.read/${Uri.encodeComponent(eventId)}',
@ -1240,7 +1239,7 @@ class MatrixApi {
/// Sets the position of the read marker for a given room, and optionally the read receipt's location. /// Sets the position of the read marker for a given room, and optionally the read receipt's location.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-read-markers /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-read-markers
Future<void> sendReadMarker(String roomId, String eventId, Future<void> setReadMarker(String roomId, String eventId,
{String readReceiptLocationEventId}) async { {String readReceiptLocationEventId}) async {
await request( await request(
RequestType.POST, RequestType.POST,
@ -1258,7 +1257,7 @@ class MatrixApi {
/// the activity time is updated to reflect that activity; the client does not need /// the activity time is updated to reflect that activity; the client does not need
/// to specify the last_active_ago field. You cannot set the presence state of another user. /// to specify the last_active_ago field. You cannot set the presence state of another user.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-presence-userid-status /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-presence-userid-status
Future<void> sendPresence( Future<void> setPresence(
String userId, String userId,
PresenceType presenceType, { PresenceType presenceType, {
String statusMsg, String statusMsg,
@ -1276,7 +1275,7 @@ class MatrixApi {
/// Get the given user's presence state. /// Get the given user's presence state.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-presence-userid-status /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-presence-userid-status
Future<PresenceContent> requestPresence(String userId) async { Future<PresenceContent> getPresence(String userId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/presence/${Uri.encodeComponent(userId)}/status', '/client/r0/presence/${Uri.encodeComponent(userId)}/status',
@ -1287,7 +1286,7 @@ class MatrixApi {
/// Uploads a file with the name [fileName] as base64 encoded to the server /// Uploads a file with the name [fileName] as base64 encoded to the server
/// and returns the mxc url as a string. /// and returns the mxc url as a string.
/// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload /// https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload
Future<String> upload(Uint8List file, String fileName, Future<String> uploadContent(Uint8List file, String fileName,
{String contentType}) async { {String contentType}) async {
fileName = fileName.split('/').last; fileName = fileName.split('/').last;
final length = file.length; final length = file.length;
@ -1324,7 +1323,7 @@ class MatrixApi {
/// Get information about a URL for the client. Typically this is called when a client sees a /// Get information about a URL for the client. Typically this is called when a client sees a
/// URL in a message and wants to render a preview for the user. /// URL in a message and wants to render a preview for the user.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-preview-url /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-preview-url
Future<OpenGraphData> requestOpenGraphDataForUrl(Uri url, {int ts}) async { Future<OpenGraphData> getUrlPreview(Uri url, {int ts}) async {
final action = homeserver final action = homeserver
.resolveUri(Uri(path: '_matrix/media/r0/preview_url', queryParameters: { .resolveUri(Uri(path: '_matrix/media/r0/preview_url', queryParameters: {
'url': url.toString(), 'url': url.toString(),
@ -1337,7 +1336,7 @@ class MatrixApi {
/// This endpoint allows clients to retrieve the configuration of the content repository, such as upload limitations. /// This endpoint allows clients to retrieve the configuration of the content repository, such as upload limitations.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
Future<int> requestMaxUploadSize() async { Future<int> getConfig() async {
final action = homeserver.resolve('_matrix/media/r0/config'); final action = homeserver.resolve('_matrix/media/r0/config');
final response = await httpClient.get(action); final response = await httpClient.get(action);
final rawJson = json.decode(response.body.isEmpty ? '{}' : response.body); final rawJson = json.decode(response.body.isEmpty ? '{}' : response.body);
@ -1363,7 +1362,7 @@ class MatrixApi {
/// Gets information about all devices for the current user. /// Gets information about all devices for the current user.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices
Future<List<Device>> requestDevices() async { Future<List<Device>> getDevices() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/devices', '/client/r0/devices',
@ -1375,7 +1374,7 @@ class MatrixApi {
/// Gets information on a single device, by device id. /// Gets information on a single device, by device id.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices-deviceid /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices-deviceid
Future<Device> requestDevice(String deviceId) async { Future<Device> getDevice(String deviceId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/devices/${Uri.encodeComponent(deviceId)}', '/client/r0/devices/${Uri.encodeComponent(deviceId)}',
@ -1385,7 +1384,7 @@ class MatrixApi {
/// Updates the metadata on the given device. /// Updates the metadata on the given device.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-devices-deviceid /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-devices-deviceid
Future<void> setDeviceMetadata(String deviceId, {String displayName}) async { Future<void> updateDevice(String deviceId, {String displayName}) async {
await request( await request(
RequestType.PUT, '/client/r0/devices/${Uri.encodeComponent(deviceId)}', RequestType.PUT, '/client/r0/devices/${Uri.encodeComponent(deviceId)}',
data: { data: {
@ -1418,7 +1417,7 @@ class MatrixApi {
/// Publishes end-to-end encryption keys for the device. /// Publishes end-to-end encryption keys for the device.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query
Future<Map<String, int>> uploadDeviceKeys( Future<Map<String, int>> uploadKeys(
{MatrixDeviceKeys deviceKeys, {MatrixDeviceKeys deviceKeys,
Map<String, dynamic> oneTimeKeys, Map<String, dynamic> oneTimeKeys,
Map<String, dynamic> fallbackKeys}) async { Map<String, dynamic> fallbackKeys}) async {
@ -1439,7 +1438,7 @@ class MatrixApi {
/// Returns the current devices and identity keys for the given users. /// Returns the current devices and identity keys for the given users.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query
Future<KeysQueryResponse> requestDeviceKeys( Future<KeysQueryResponse> queryKeys(
Map<String, dynamic> deviceKeys, { Map<String, dynamic> deviceKeys, {
int timeout, int timeout,
String token, String token,
@ -1458,7 +1457,7 @@ class MatrixApi {
/// Claims one-time keys for use in pre-key messages. /// Claims one-time keys for use in pre-key messages.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-claim /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-claim
Future<OneTimeKeysClaimResponse> requestOneTimeKeys( Future<OneTimeKeysClaimResponse> claimKeys(
Map<String, Map<String, String>> oneTimeKeys, { Map<String, Map<String, String>> oneTimeKeys, {
int timeout, int timeout,
}) async { }) async {
@ -1475,8 +1474,7 @@ class MatrixApi {
/// Gets a list of users who have updated their device identity keys since a previous sync token. /// Gets a list of users who have updated their device identity keys since a previous sync token.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload
Future<DeviceListsUpdate> requestDeviceListsUpdate( Future<DeviceListsUpdate> getKeysChanges(String from, String to) async {
String from, String to) async {
final response = final response =
await request(RequestType.GET, '/client/r0/keys/changes', query: { await request(RequestType.GET, '/client/r0/keys/changes', query: {
'from': from, 'from': from,
@ -1538,7 +1536,7 @@ class MatrixApi {
/// Gets all currently active pushers for the authenticated user. /// Gets all currently active pushers for the authenticated user.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushers /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushers
Future<List<Pusher>> requestPushers() async { Future<List<Pusher>> getPushers() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/pushers', '/client/r0/pushers',
@ -1552,7 +1550,7 @@ class MatrixApi {
/// for this user ID. The behaviour of this endpoint varies depending on the /// for this user ID. The behaviour of this endpoint varies depending on the
/// values in the JSON body. /// values in the JSON body.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
Future<void> setPusher(Pusher pusher, {bool append}) async { Future<void> postPusher(Pusher pusher, {bool append}) async {
final data = pusher.toJson(); final data = pusher.toJson();
if (append != null) { if (append != null) {
data['append'] = append; data['append'] = append;
@ -1568,7 +1566,7 @@ class MatrixApi {
/// This API is used to paginate through the list of events that the user has /// This API is used to paginate through the list of events that the user has
/// been, or would have been notified about. /// been, or would have been notified about.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-notifications /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-notifications
Future<NotificationsQueryResponse> requestNotifications({ Future<NotificationsQueryResponse> getNotifications({
String from, String from,
int limit, int limit,
String only, String only,
@ -1589,7 +1587,7 @@ class MatrixApi {
/// on the rulesets by suffixing a scope to this path e.g. /pushrules/global/. /// on the rulesets by suffixing a scope to this path e.g. /pushrules/global/.
/// This will return a subset of this data under the specified key e.g. the global key. /// This will return a subset of this data under the specified key e.g. the global key.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules
Future<PushRuleSet> requestPushRules() async { Future<PushRuleSet> getPushRules() async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/pushrules', '/client/r0/pushrules',
@ -1599,7 +1597,7 @@ class MatrixApi {
/// Retrieve a single specified push rule. /// Retrieve a single specified push rule.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid
Future<PushRule> requestPushRule( Future<PushRule> getPushRule(
String scope, String scope,
PushRuleKind kind, PushRuleKind kind,
String ruleId, String ruleId,
@ -1655,7 +1653,7 @@ class MatrixApi {
/// This endpoint gets whether the specified push rule is enabled. /// This endpoint gets whether the specified push rule is enabled.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid-enabled /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid-enabled
Future<bool> requestPushRuleEnabled( Future<bool> isPushRuleEnabled(
String scope, String scope,
PushRuleKind kind, PushRuleKind kind,
String ruleId, String ruleId,
@ -1669,7 +1667,7 @@ class MatrixApi {
/// This endpoint allows clients to enable or disable the specified push rule. /// This endpoint allows clients to enable or disable the specified push rule.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-pushrules-scope-kind-ruleid-enabled /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-pushrules-scope-kind-ruleid-enabled
Future<void> enablePushRule( Future<void> setPushRuleEnabled(
String scope, String scope,
PushRuleKind kind, PushRuleKind kind,
String ruleId, String ruleId,
@ -1685,7 +1683,7 @@ class MatrixApi {
/// This endpoint get the actions for the specified push rule. /// This endpoint get the actions for the specified push rule.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid-actions /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushrules-scope-kind-ruleid-actions
Future<List<PushRuleAction>> requestPushRuleActions( Future<List<PushRuleAction>> getPushRuleActions(
String scope, String scope,
PushRuleKind kind, PushRuleKind kind,
String ruleId, String ruleId,
@ -1720,7 +1718,7 @@ class MatrixApi {
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-search /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-search
/// Please note: The specification is not 100% clear what it is expecting and sending here. /// Please note: The specification is not 100% clear what it is expecting and sending here.
/// So we stick with pure json until we have more information. /// So we stick with pure json until we have more information.
Future<Map<String, dynamic>> globalSearch(Map<String, dynamic> query) async { Future<Map<String, dynamic>> search(Map<String, dynamic> query) async {
return await request( return await request(
RequestType.POST, RequestType.POST,
'/client/r0/search', '/client/r0/search',
@ -1731,7 +1729,7 @@ class MatrixApi {
/// This will listen for new events related to a particular room and return them to the /// This will listen for new events related to a particular room and return them to the
/// caller. This will block until an event is received, or until the timeout is reached. /// caller. This will block until an event is received, or until the timeout is reached.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-events /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-events
Future<EventsSyncUpdate> requestEvents({ Future<EventsSyncUpdate> getEvents({
String from, String from,
int timeout, int timeout,
String roomId, String roomId,
@ -1747,7 +1745,7 @@ class MatrixApi {
/// List the tags set by a user on a room. /// List the tags set by a user on a room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-rooms-roomid-tags /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-rooms-roomid-tags
Future<Map<String, Tag>> requestRoomTags(String userId, String roomId) async { Future<Map<String, Tag>> getRoomTags(String userId, String roomId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/tags', '/client/r0/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/tags',
@ -1759,7 +1757,7 @@ class MatrixApi {
/// Add a tag to the room. /// Add a tag to the room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag
Future<void> addRoomTag( Future<void> setRoomTag(
String userId, String userId,
String roomId, String roomId,
String tag, { String tag, {
@ -1775,7 +1773,7 @@ class MatrixApi {
/// Remove a tag from the room. /// Remove a tag from the room.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag
Future<void> removeRoomTag(String userId, String roomId, String tag) async { Future<void> deleteRoomTag(String userId, String roomId, String tag) async {
await request( await request(
RequestType.DELETE, RequestType.DELETE,
'/client/r0/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/tags/${Uri.encodeComponent(tag)}', '/client/r0/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/tags/${Uri.encodeComponent(tag)}',
@ -1801,7 +1799,7 @@ class MatrixApi {
/// Get some account_data for the client. This config is only visible to the user that set the account_data. /// Get some account_data for the client. This config is only visible to the user that set the account_data.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-account-data-type /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-account-data-type
Future<Map<String, dynamic>> requestAccountData( Future<Map<String, dynamic>> getAccountData(
String userId, String userId,
String type, String type,
) async { ) async {
@ -1814,7 +1812,7 @@ class MatrixApi {
/// Set some account_data for the client on a given room. This config is only visible to the user that set /// Set some account_data for the client on a given room. This config is only visible to the user that set
/// the account_data. The config will be synced to clients in the per-room account_data. /// the account_data. The config will be synced to clients in the per-room account_data.
/// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type /// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type
Future<void> setRoomAccountData( Future<void> setAccountDataPerRoom(
String userId, String userId,
String roomId, String roomId,
String type, String type,
@ -1830,7 +1828,7 @@ class MatrixApi {
/// Get some account_data for the client on a given room. This config is only visible to the user that set the account_data. /// Get some account_data for the client on a given room. This config is only visible to the user that set the account_data.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-rooms-roomid-account-data-type /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-rooms-roomid-account-data-type
Future<Map<String, dynamic>> requestRoomAccountData( Future<Map<String, dynamic>> getAccountDataPerRoom(
String userId, String userId,
String roomId, String roomId,
String type, String type,
@ -1843,7 +1841,7 @@ class MatrixApi {
/// Gets information about a particular user. /// Gets information about a particular user.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-admin-whois-userid /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-admin-whois-userid
Future<WhoIsInfo> requestWhoIsInfo(String userId) async { Future<WhoIsInfo> getWhoIs(String userId) async {
final response = await request( final response = await request(
RequestType.GET, RequestType.GET,
'/client/r0/admin/whois/${Uri.encodeComponent(userId)}', '/client/r0/admin/whois/${Uri.encodeComponent(userId)}',
@ -1854,7 +1852,7 @@ class MatrixApi {
/// This API returns a number of events that happened just before and after the specified event. /// This API returns a number of events that happened just before and after the specified event.
/// This allows clients to get the context surrounding an event. /// This allows clients to get the context surrounding an event.
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-context-eventid /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-context-eventid
Future<EventContext> requestEventContext( Future<EventContext> getEventContext(
String roomId, String roomId,
String eventId, { String eventId, {
int limit, int limit,
@ -1871,7 +1869,7 @@ class MatrixApi {
/// Reports an event as inappropriate to the server, which may then notify the appropriate people. /// Reports an event as inappropriate to the server, which may then notify the appropriate people.
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-report-eventid /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-report-eventid
Future<void> reportEvent( Future<void> reportContent(
String roomId, String roomId,
String eventId, String eventId,
String reason, String reason,
@ -1961,7 +1959,7 @@ class MatrixApi {
.toList(); .toList();
} }
Future<OpenIdCredentials> requestOpenIdCredentials(String userId) async { Future<OpenIdCredentials> requestOpenIdToken(String userId) async {
final response = await request( final response = await request(
RequestType.POST, RequestType.POST,
'/client/r0/user/${Uri.encodeComponent(userId)}/openid/request_token', '/client/r0/user/${Uri.encodeComponent(userId)}/openid/request_token',

View File

@ -122,7 +122,7 @@ void main() {
}); });
test('getSupportedVersions', () async { test('getSupportedVersions', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final supportedVersions = await matrixApi.requestSupportedVersions(); final supportedVersions = await matrixApi.getVersions();
expect(supportedVersions.versions.contains('r0.5.0'), true); expect(supportedVersions.versions.contains('r0.5.0'), true);
expect(supportedVersions.unstableFeatures['m.lazy_load_members'], true); expect(supportedVersions.unstableFeatures['m.lazy_load_members'], true);
expect(FakeMatrixApi.api['GET']['/client/versions']({}), expect(FakeMatrixApi.api['GET']['/client/versions']({}),
@ -131,8 +131,7 @@ void main() {
}); });
test('getWellKnownInformation', () async { test('getWellKnownInformation', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final wellKnownInformation = final wellKnownInformation = await matrixApi.getWellknown();
await matrixApi.requestWellKnownInformation();
expect(wellKnownInformation.mHomeserver.baseUrl, expect(wellKnownInformation.mHomeserver.baseUrl,
'https://fakeserver.notexisting'); 'https://fakeserver.notexisting');
expect(wellKnownInformation.toJson(), { expect(wellKnownInformation.toJson(), {
@ -147,7 +146,7 @@ void main() {
}); });
test('getLoginTypes', () async { test('getLoginTypes', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final loginTypes = await matrixApi.requestLoginTypes(); final loginTypes = await matrixApi.getLoginFlows();
expect(loginTypes.flows.first.type, 'm.login.password'); expect(loginTypes.flows.first.type, 'm.login.password');
expect(FakeMatrixApi.api['GET']['/client/r0/login']({}), expect(FakeMatrixApi.api['GET']['/client/r0/login']({}),
loginTypes.toJson()); loginTypes.toJson());
@ -273,14 +272,15 @@ void main() {
}); });
test('usernameAvailable', () async { test('usernameAvailable', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final loginResponse = await matrixApi.usernameAvailable('testuser'); final loginResponse =
await matrixApi.checkUsernameAvailability('testuser');
expect(loginResponse, true); expect(loginResponse, true);
matrixApi.homeserver = null; matrixApi.homeserver = null;
}); });
test('getThirdPartyIdentifiers', () async { test('getThirdPartyIdentifiers', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestThirdPartyIdentifiers(); final response = await matrixApi.getAccount3PIDs();
expect(FakeMatrixApi.api['GET']['/client/r0/account/3pid']({}), expect(FakeMatrixApi.api['GET']['/client/r0/account/3pid']({}),
{'threepids': response.map((t) => t.toJson()).toList()}); {'threepids': response.map((t) => t.toJson()).toList()});
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -288,14 +288,14 @@ void main() {
test('addThirdPartyIdentifier', () async { test('addThirdPartyIdentifier', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.addThirdPartyIdentifier('1234', '1234', await matrixApi.add3PID('1234', '1234',
auth: AuthenticationData.fromJson({'type': 'm.login.dummy'})); auth: AuthenticationData.fromJson({'type': 'm.login.dummy'}));
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
test('bindThirdPartyIdentifier', () async { test('bindThirdPartyIdentifier', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.bindThirdPartyIdentifier( await matrixApi.bind3PID(
'1234', '1234',
'1234', '1234',
'https://example.com', 'https://example.com',
@ -306,7 +306,7 @@ void main() {
test('deleteThirdPartyIdentifier', () async { test('deleteThirdPartyIdentifier', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.deleteThirdPartyIdentifier( final response = await matrixApi.delete3pidFromAccount(
'alice@example.com', 'alice@example.com',
ThirdPartyIdentifierMedium.email, ThirdPartyIdentifierMedium.email,
idServer: 'https://example.com', idServer: 'https://example.com',
@ -317,7 +317,7 @@ void main() {
test('unbindThirdPartyIdentifier', () async { test('unbindThirdPartyIdentifier', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.unbindThirdPartyIdentifier( final response = await matrixApi.unbind3pidFromAccount(
'alice@example.com', 'alice@example.com',
ThirdPartyIdentifierMedium.email, ThirdPartyIdentifierMedium.email,
'https://example.com', 'https://example.com',
@ -355,14 +355,14 @@ void main() {
test('requestMsisdnValidationToken', () async { test('requestMsisdnValidationToken', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.whoAmI(); final response = await matrixApi.getTokenOwner();
expect(response, 'alice@example.com'); expect(response, 'alice@example.com');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
test('getServerCapabilities', () async { test('getServerCapabilities', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestServerCapabilities(); final response = await matrixApi.getCapabilities();
expect(FakeMatrixApi.api['GET']['/client/r0/capabilities']({}), expect(FakeMatrixApi.api['GET']['/client/r0/capabilities']({}),
{'capabilities': response.toJson()}); {'capabilities': response.toJson()});
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -371,7 +371,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = final response =
await matrixApi.uploadFilter('alice@example.com', Filter()); await matrixApi.defineFilter('alice@example.com', Filter());
expect(response, '1234'); expect(response, '1234');
final filter = Filter( final filter = Filter(
room: RoomFilter( room: RoomFilter(
@ -442,7 +442,7 @@ void main() {
'not_senders': ['@alice:example.com'] 'not_senders': ['@alice:example.com']
}, },
}); });
await matrixApi.uploadFilter( await matrixApi.defineFilter(
'alice@example.com', 'alice@example.com',
filter, filter,
); );
@ -481,7 +481,7 @@ void main() {
test('downloadFilter', () async { test('downloadFilter', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.downloadFilter('alice@example.com', '1234'); await matrixApi.getFilter('alice@example.com', '1234');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
test('sync', () async { test('sync', () async {
@ -506,7 +506,7 @@ void main() {
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final event = final event =
await matrixApi.requestEvent('!localpart:server.abc', '1234'); await matrixApi.getOneRoomEvent('!localpart:server.abc', '1234');
expect(event.eventId, '143273582443PhrSn:example.org'); expect(event.eventId, '143273582443PhrSn:example.org');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -525,7 +525,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final states = await matrixApi.requestStates('!localpart:server.abc'); final states = await matrixApi.getRoomState('!localpart:server.abc');
expect(states.length, 4); expect(states.length, 4);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -534,7 +534,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final states = await matrixApi.requestMembers( final states = await matrixApi.getMembersByRoom(
'!localpart:server.abc', '!localpart:server.abc',
at: '1234', at: '1234',
membership: Membership.join, membership: Membership.join,
@ -548,7 +548,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final states = await matrixApi.requestJoinedMembers( final states = await matrixApi.getJoinedMembersByRoom(
'!localpart:server.abc', '!localpart:server.abc',
); );
expect(states.length, 1); expect(states.length, 1);
@ -563,7 +563,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final timelineHistoryResponse = await matrixApi.requestMessages( final timelineHistoryResponse = await matrixApi.getRoomEvents(
'!localpart:server.abc', '!localpart:server.abc',
'1234', '1234',
Direction.b, Direction.b,
@ -584,7 +584,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final eventId = await matrixApi.sendState( final eventId = await matrixApi.setRoomStateWithKey(
'!localpart:server.abc', 'm.room.avatar', {'url': 'mxc://1234'}); '!localpart:server.abc', 'm.room.avatar', {'url': 'mxc://1234'});
expect(eventId, 'YUwRidLecu:example.com'); expect(eventId, 'YUwRidLecu:example.com');
@ -610,7 +610,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final eventId = await matrixApi.redact( final eventId = await matrixApi.redactEvent(
'!localpart:server.abc', '!localpart:server.abc',
'1234', '1234',
'1234', '1234',
@ -648,7 +648,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.createRoomAlias( await matrixApi.setRoomAlias(
'#testalias:example.com', '#testalias:example.com',
'!1234:example.com', '!1234:example.com',
); );
@ -659,7 +659,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final roomAliasInformation = await matrixApi.requestRoomAliasInformation( final roomAliasInformation = await matrixApi.getRoomIdByAlias(
'#testalias:example.com', '#testalias:example.com',
); );
@ -674,7 +674,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.removeRoomAlias('#testalias:example.com'); await matrixApi.deleteRoomAlias('#testalias:example.com');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -682,7 +682,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final list = await matrixApi.requestRoomAliases('!localpart:example.com'); final list = await matrixApi.getLocalAliases('!localpart:example.com');
expect(list.length, 3); expect(list.length, 3);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -691,7 +691,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final list = await matrixApi.requestJoinedRooms(); final list = await matrixApi.getJoinedRooms();
expect(list.length, 1); expect(list.length, 1);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -710,7 +710,7 @@ void main() {
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final roomId = '!localpart:example.com'; final roomId = '!localpart:example.com';
final response = await matrixApi.joinRoom( final response = await matrixApi.joinRoomById(
roomId, roomId,
thirdPidSignedSender: '@bob:example.com', thirdPidSignedSender: '@bob:example.com',
thirdPidSignedmxid: '@alice:example.com', thirdPidSignedmxid: '@alice:example.com',
@ -728,7 +728,7 @@ void main() {
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final roomId = '!localpart:example.com'; final roomId = '!localpart:example.com';
final response = await matrixApi.joinRoomOrAlias( final response = await matrixApi.joinRoom(
roomId, roomId,
servers: ['example.com', 'example.abc'], servers: ['example.com', 'example.abc'],
thirdPidSignedSender: '@bob:example.com', thirdPidSignedSender: '@bob:example.com',
@ -762,7 +762,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.kickFromRoom( await matrixApi.kick(
'!localpart:example.com', '!localpart:example.com',
'@bob:example.com', '@bob:example.com',
reason: 'test', reason: 'test',
@ -774,7 +774,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.banFromRoom( await matrixApi.ban(
'!localpart:example.com', '!localpart:example.com',
'@bob:example.com', '@bob:example.com',
reason: 'test', reason: 'test',
@ -786,7 +786,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.unbanInRoom( await matrixApi.unban(
'!localpart:example.com', '!localpart:example.com',
'@bob:example.com', '@bob:example.com',
); );
@ -797,8 +797,8 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final visibility = final visibility = await matrixApi
await matrixApi.requestRoomVisibility('!localpart:example.com'); .getRoomVisibilityOnDirectory('!localpart:example.com');
expect(visibility, Visibility.public); expect(visibility, Visibility.public);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -807,7 +807,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.setRoomVisibility( await matrixApi.setRoomVisibilityOnDirectory(
'!localpart:example.com', Visibility.private); '!localpart:example.com', Visibility.private);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -816,7 +816,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestPublicRooms( final response = await matrixApi.getPublicRooms(
limit: 10, limit: 10,
since: '1234', since: '1234',
server: 'example.com', server: 'example.com',
@ -833,7 +833,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.searchPublicRooms( final response = await matrixApi.queryPublicRooms(
limit: 10, limit: 10,
since: '1234', since: '1234',
server: 'example.com', server: 'example.com',
@ -853,7 +853,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.searchUser( final response = await matrixApi.searchUserDirectory(
'test', 'test',
limit: 10, limit: 10,
); );
@ -867,7 +867,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.setDisplayname('@alice:example.com', 'Alice M'); await matrixApi.setDisplayName('@alice:example.com', 'Alice M');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -875,7 +875,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.requestDisplayname('@alice:example.com'); await matrixApi.getDisplayName('@alice:example.com');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -894,7 +894,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestAvatarUrl('@alice:example.com'); final response = await matrixApi.getAvatarUrl('@alice:example.com');
expect(response, Uri.parse('mxc://test')); expect(response, Uri.parse('mxc://test'));
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -903,7 +903,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestProfile('@alice:example.com'); final response = await matrixApi.getUserProfile('@alice:example.com');
expect( expect(
FakeMatrixApi.api['GET'] FakeMatrixApi.api['GET']
['/client/r0/profile/%40alice%3Aexample.com']({}), ['/client/r0/profile/%40alice%3Aexample.com']({}),
@ -915,7 +915,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestTurnServerCredentials(); final response = await matrixApi.getTurnServer();
expect(FakeMatrixApi.api['GET']['/client/r0/voip/turnServer']({}), expect(FakeMatrixApi.api['GET']['/client/r0/voip/turnServer']({}),
response.toJson()); response.toJson());
@ -925,7 +925,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.sendTypingNotification( await matrixApi.setTyping(
'@alice:example.com', '@alice:example.com',
'!localpart:example.com', '!localpart:example.com',
true, true,
@ -938,7 +938,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.sendReceiptMarker( await matrixApi.postReceipt(
'!localpart:example.com', '!localpart:example.com',
'\$1234:example.com', '\$1234:example.com',
); );
@ -949,7 +949,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.sendReadMarker( await matrixApi.setReadMarker(
'!localpart:example.com', '!localpart:example.com',
'\$1234:example.com', '\$1234:example.com',
readReceiptLocationEventId: '\$1234:example.com', readReceiptLocationEventId: '\$1234:example.com',
@ -961,7 +961,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.sendPresence( await matrixApi.setPresence(
'@alice:example.com', '@alice:example.com',
PresenceType.offline, PresenceType.offline,
statusMsg: 'test', statusMsg: 'test',
@ -973,7 +973,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestPresence( final response = await matrixApi.getPresence(
'@alice:example.com', '@alice:example.com',
); );
expect( expect(
@ -985,11 +985,11 @@ void main() {
}); });
test('upload', () async { test('upload', () async {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
final response = await matrixApi.upload(Uint8List(0), 'file.jpeg'); final response = await matrixApi.uploadContent(Uint8List(0), 'file.jpeg');
expect(response, 'mxc://example.com/AQwafuaFswefuhsfAFAgsw'); expect(response, 'mxc://example.com/AQwafuaFswefuhsfAFAgsw');
var throwsException = false; var throwsException = false;
try { try {
await matrixApi.upload(Uint8List(0), 'file.jpg'); await matrixApi.uploadContent(Uint8List(0), 'file.jpg');
} on MatrixException catch (_) { } on MatrixException catch (_) {
throwsException = true; throwsException = true;
} }
@ -1000,7 +1000,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final openGraphData = await matrixApi.requestOpenGraphDataForUrl( final openGraphData = await matrixApi.getUrlPreview(
Uri.parse('https://matrix.org'), Uri.parse('https://matrix.org'),
ts: 10, ts: 10,
); );
@ -1015,7 +1015,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestMaxUploadSize(); final response = await matrixApi.getConfig();
expect(response, 50000000); expect(response, 50000000);
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
@ -1036,7 +1036,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final devices = await matrixApi.requestDevices(); final devices = await matrixApi.getDevices();
expect(FakeMatrixApi.api['GET']['/client/r0/devices']({})['devices'], expect(FakeMatrixApi.api['GET']['/client/r0/devices']({})['devices'],
devices.map((i) => i.toJson()).toList()); devices.map((i) => i.toJson()).toList());
@ -1046,7 +1046,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.requestDevice('QBUAZIFURK'); await matrixApi.getDevice('QBUAZIFURK');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -1054,7 +1054,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.setDeviceMetadata('QBUAZIFURK', displayName: 'test'); await matrixApi.updateDevice('QBUAZIFURK', displayName: 'test');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -1080,7 +1080,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.uploadDeviceKeys( await matrixApi.uploadKeys(
deviceKeys: MatrixDeviceKeys( deviceKeys: MatrixDeviceKeys(
'@alice:example.com', '@alice:example.com',
'ABCD', 'ABCD',
@ -1097,7 +1097,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestDeviceKeys( final response = await matrixApi.queryKeys(
{ {
'@alice:example.com': [], '@alice:example.com': [],
}, },
@ -1119,7 +1119,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestOneTimeKeys( final response = await matrixApi.claimKeys(
{ {
'@alice:example.com': {'JLAFKJWSCS': 'signed_curve25519'} '@alice:example.com': {'JLAFKJWSCS': 'signed_curve25519'}
}, },
@ -1139,7 +1139,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.requestDeviceListsUpdate('1234', '1234'); await matrixApi.getKeysChanges('1234', '1234');
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -1230,7 +1230,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestPushers(); final response = await matrixApi.getPushers();
expect( expect(
FakeMatrixApi.api['GET']['/client/r0/pushers']({}), FakeMatrixApi.api['GET']['/client/r0/pushers']({}),
{'pushers': response.map((i) => i.toJson()).toList()}, {'pushers': response.map((i) => i.toJson()).toList()},
@ -1242,7 +1242,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.setPusher( await matrixApi.postPusher(
Pusher( Pusher(
'1234', '1234',
'app.id', 'app.id',
@ -1263,7 +1263,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestNotifications( final response = await matrixApi.getNotifications(
from: '1234', from: '1234',
limit: 10, limit: 10,
only: '1234', only: '1234',
@ -1280,7 +1280,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestPushRules(); final response = await matrixApi.getPushRules();
expect( expect(
FakeMatrixApi.api['GET']['/client/r0/pushrules']({}), FakeMatrixApi.api['GET']['/client/r0/pushrules']({}),
{'global': response.toJson()}, {'global': response.toJson()},
@ -1292,8 +1292,8 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestPushRule( final response =
'global', PushRuleKind.content, 'nocake'); await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake');
expect( expect(
FakeMatrixApi.api['GET'] FakeMatrixApi.api['GET']
['/client/r0/pushrules/global/content/nocake']({}), ['/client/r0/pushrules/global/content/nocake']({}),
@ -1338,7 +1338,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final enabled = await matrixApi.requestPushRuleEnabled( final enabled = await matrixApi.isPushRuleEnabled(
'global', PushRuleKind.content, 'nocake'); 'global', PushRuleKind.content, 'nocake');
expect(enabled, true); expect(enabled, true);
@ -1348,7 +1348,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.enablePushRule( await matrixApi.setPushRuleEnabled(
'global', 'global',
PushRuleKind.content, PushRuleKind.content,
'nocake', 'nocake',
@ -1361,7 +1361,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final actions = await matrixApi.requestPushRuleActions( final actions = await matrixApi.getPushRuleActions(
'global', PushRuleKind.content, 'nocake'); 'global', PushRuleKind.content, 'nocake');
expect(actions.first, PushRuleAction.notify); expect(actions.first, PushRuleAction.notify);
@ -1384,7 +1384,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.globalSearch({}); await matrixApi.search({});
matrixApi.homeserver = matrixApi.accessToken = null; matrixApi.homeserver = matrixApi.accessToken = null;
}); });
@ -1392,8 +1392,8 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestEvents( final response =
from: '1234', roomId: '!1234', timeout: 10); await matrixApi.getEvents(from: '1234', roomId: '!1234', timeout: 10);
expect( expect(
FakeMatrixApi.api['GET'] FakeMatrixApi.api['GET']
['/client/r0/events?from=1234&timeout=10&roomId=%211234']({}), ['/client/r0/events?from=1234&timeout=10&roomId=%211234']({}),
@ -1406,7 +1406,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestRoomTags( final response = await matrixApi.getRoomTags(
'@alice:example.com', '!localpart:example.com'); '@alice:example.com', '!localpart:example.com');
expect( expect(
FakeMatrixApi.api['GET'][ FakeMatrixApi.api['GET'][
@ -1420,7 +1420,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.addRoomTag( await matrixApi.setRoomTag(
'@alice:example.com', '@alice:example.com',
'!localpart:example.com', '!localpart:example.com',
'testtag', 'testtag',
@ -1433,7 +1433,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.removeRoomTag( await matrixApi.deleteRoomTag(
'@alice:example.com', '@alice:example.com',
'!localpart:example.com', '!localpart:example.com',
'testtag', 'testtag',
@ -1457,7 +1457,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.requestAccountData( await matrixApi.getAccountData(
'@alice:example.com', '@alice:example.com',
'test.account.data', 'test.account.data',
); );
@ -1468,7 +1468,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.setRoomAccountData( await matrixApi.setAccountDataPerRoom(
'@alice:example.com', '@alice:example.com',
'1234', '1234',
'test.account.data', 'test.account.data',
@ -1481,7 +1481,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.requestRoomAccountData( await matrixApi.getAccountDataPerRoom(
'@alice:example.com', '@alice:example.com',
'1234', '1234',
'test.account.data', 'test.account.data',
@ -1493,7 +1493,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestWhoIsInfo('@alice:example.com'); final response = await matrixApi.getWhoIs('@alice:example.com');
expect( expect(
FakeMatrixApi.api['GET'] FakeMatrixApi.api['GET']
['/client/r0/admin/whois/%40alice%3Aexample.com']({}), ['/client/r0/admin/whois/%40alice%3Aexample.com']({}),
@ -1506,7 +1506,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestEventContext('1234', '1234', final response = await matrixApi.getEventContext('1234', '1234',
limit: 10, filter: '{}'); limit: 10, filter: '{}');
expect( expect(
FakeMatrixApi.api['GET'] FakeMatrixApi.api['GET']
@ -1520,7 +1520,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
await matrixApi.reportEvent( await matrixApi.reportContent(
'1234', '1234',
'1234', '1234',
'test', 'test',
@ -1607,7 +1607,7 @@ void main() {
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting'); matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
matrixApi.accessToken = '1234'; matrixApi.accessToken = '1234';
final response = await matrixApi.requestOpenIdCredentials('1234'); final response = await matrixApi.requestOpenIdToken('1234');
expect( expect(
FakeMatrixApi.api['POST'] FakeMatrixApi.api['POST']
['/client/r0/user/1234/openid/request_token']({}), ['/client/r0/user/1234/openid/request_token']({}),