1
0
mirror of https://github.com/vector-im/riotX-android synced 2025-10-06 08:12:46 +02:00

Compare commits

...

36 Commits

Author SHA1 Message Date
ganfra
f0a225d96a Extract matrix client : ktlint (+ remove from gradle dependency for now) 2021-08-24 14:48:11 +02:00
ganfra
33062d49a5 Extract matrix client: Inject in Dagger graph 2021-08-20 17:30:20 +02:00
ganfra
90dd075ad2 Extract matrix client: add accessToken 2021-08-20 16:21:19 +02:00
ganfra
5e46dfd197 Extract matrix client: offers APIs through MatrixAuthenticatedClient 2021-08-19 12:05:41 +02:00
ganfra
e58c349885 Extract matrix client: remove internal keyword 2021-08-19 11:31:43 +02:00
ganfra
7afe50b1bc Extract matrix client: makes it compile 2021-08-19 11:28:10 +02:00
ganfra
810f6f0eca Extract matrix client: RoomKeysAPI 2021-08-19 11:01:34 +02:00
ganfra
8db573bec2 Extract matrix client: SpaceAPI 2021-08-19 10:59:21 +02:00
ganfra
13aa6fa10a Extract matrix client: VoipAPI 2021-08-19 10:56:53 +02:00
ganfra
e7a6ade7f9 Extract matrix client: rename some Api to API 2021-08-19 10:55:40 +02:00
ganfra
dcf164f6e6 Extract matrix client: PushRuleAPI 2021-08-19 10:54:44 +02:00
ganfra
f642bbcc20 Extract matrix client: FilterAPI 2021-08-19 10:53:18 +02:00
ganfra
814b27e693 Extract matrix client: CryptoAPI 2021-08-19 10:51:03 +02:00
ganfra
3503fb6ff0 Extract matrix client: WidgetAPI 2021-08-19 10:41:22 +02:00
ganfra
cd05e96464 Extract matrix client: WellKnownAPI 2021-08-19 10:39:43 +02:00
ganfra
fd7a9e1acb Extract matrix client: ThirdPartyAPI 2021-08-19 10:37:45 +02:00
ganfra
b9efc65327 Extract matrix client: TermsAPI 2021-08-19 10:36:19 +02:00
ganfra
10f8e57062 Extract matrix client: SyncAPI 2021-08-19 10:34:45 +02:00
ganfra
0630ced068 Extract matrix client: SignOutAPI 2021-08-19 10:32:11 +02:00
ganfra
55ad8177ca Extract matrix client: SearchUserAPI 2021-08-19 10:19:25 +02:00
ganfra
3efe80fb25 Extract matrix client: SearchAPI 2021-08-19 10:18:22 +02:00
ganfra
e6f695db9e Extract matrix client: RoomAPI 2021-08-19 10:13:50 +02:00
ganfra
45b02ce15e Extract matrix client: PushGatewayAPI 2021-08-19 09:53:34 +02:00
ganfra
427819be45 Extract matrix client: PushersAPI 2021-08-19 09:52:11 +02:00
ganfra
f8f56802a6 Extract matrix client: ProfileAPI 2021-08-19 09:50:09 +02:00
ganfra
a8d73bf71b Extract matrix client: OpenIdAPI 2021-08-19 09:34:02 +02:00
ganfra
161603f28a Extract matrix client: MediaAPI 2021-08-19 09:32:07 +02:00
ganfra
aba692e068 Extract matrix client: IdentityAuthAPI 2021-08-19 09:31:09 +02:00
ganfra
46bb24e8ca Extract matrix client: IdentityAPI 2021-08-19 09:30:06 +02:00
ganfra
8c29e254b3 Extract matrix client: GroupAPI 2021-08-19 09:28:32 +02:00
ganfra
6e51c1d2ba Extract matrix client: FederationAPI 2021-08-19 09:26:02 +02:00
ganfra
c45ef67a98 Extract matrix client: DirectoryAPI 2021-08-19 09:23:25 +02:00
ganfra
6a2e5ece51 Extract matrix client: CapabilitiesAPI 2021-08-19 09:19:39 +02:00
ganfra
fa1259932d Extract matrix client: AuthAPI 2021-08-19 09:15:16 +02:00
ganfra
e1b9ed7f2b Extract matrix client: AccountDataAPI 2021-08-19 08:57:26 +02:00
ganfra
2b0681d429 Extract matrix client: AccountAPI 2021-08-19 08:54:40 +02:00
236 changed files with 10429 additions and 1 deletions

1
matrix-api-client/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,27 @@
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm'
id 'kotlin-kapt'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
def retrofit_version = '2.9.0'
def moshi_version = '1.12.0'
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.1"))
implementation 'com.squareup.okhttp3:okhttp'
implementation 'com.squareup.okhttp3:logging-interceptor'
implementation 'com.squareup.okhttp3:okhttp-urlconnection'
implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
}

View File

@@ -0,0 +1,171 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client
import com.squareup.moshi.Moshi
import okhttp3.OkHttpClient
import org.matrix.client.api.AccountAPI
import org.matrix.client.api.AccountDataAPI
import org.matrix.client.api.CapabilitiesAPI
import org.matrix.client.api.CryptoAPI
import org.matrix.client.api.DirectoryAPI
import org.matrix.client.api.FederationAPI
import org.matrix.client.api.FilterAPI
import org.matrix.client.api.GroupAPI
import org.matrix.client.api.IdentityAPI
import org.matrix.client.api.IdentityAuthAPI
import org.matrix.client.api.MediaAPI
import org.matrix.client.api.OpenIdAPI
import org.matrix.client.api.ProfileAPI
import org.matrix.client.api.PushGatewayAPI
import org.matrix.client.api.PushRulesAPI
import org.matrix.client.api.PushersAPI
import org.matrix.client.api.RoomAPI
import org.matrix.client.api.RoomKeysAPI
import org.matrix.client.api.SearchAPI
import org.matrix.client.api.SearchUserAPI
import org.matrix.client.api.SignOutAPI
import org.matrix.client.api.SpaceAPI
import org.matrix.client.api.SyncAPI
import org.matrix.client.api.TermsAPI
import org.matrix.client.api.ThirdPartyAPI
import org.matrix.client.api.VoipAPI
import org.matrix.client.api.WellKnownAPI
import org.matrix.client.api.WidgetsAPI
import org.matrix.client.utils.RetrofitFactory
class MatrixAuthenticatedClient(private val okHttpClient: OkHttpClient,
private val moshi: Moshi,
private val baseUrl: String,
private val accessTokenProvider: () -> String?) {
private val retrofit by lazy {
RetrofitFactory(moshi).create(okHttpClient, baseUrl, accessTokenProvider)
}
val accountAPI by lazy {
retrofit.create(AccountAPI::class.java)
}
val accountDataAPI by lazy {
retrofit.create(AccountDataAPI::class.java)
}
val capabilitiesAPI by lazy {
retrofit.create(CapabilitiesAPI::class.java)
}
val cryptoAPI by lazy {
retrofit.create(CryptoAPI::class.java)
}
val directoryAPI by lazy {
retrofit.create(DirectoryAPI::class.java)
}
val federationAPI by lazy {
retrofit.create(FederationAPI::class.java)
}
val filterAPI by lazy {
retrofit.create(FilterAPI::class.java)
}
val groupAPI by lazy {
retrofit.create(GroupAPI::class.java)
}
val identityAPI by lazy {
retrofit.create(IdentityAPI::class.java)
}
val identityAuthAPI by lazy {
retrofit.create(IdentityAuthAPI::class.java)
}
val mediaAPI by lazy {
retrofit.create(MediaAPI::class.java)
}
val openIdAPI by lazy {
retrofit.create(OpenIdAPI::class.java)
}
val profileAPI by lazy {
retrofit.create(ProfileAPI::class.java)
}
val pushersAPI by lazy {
retrofit.create(PushersAPI::class.java)
}
val pushGatewayAPI by lazy {
retrofit.create(PushGatewayAPI::class.java)
}
val pushRulesAPI by lazy {
retrofit.create(PushRulesAPI::class.java)
}
val roomAPI by lazy {
retrofit.create(RoomAPI::class.java)
}
val roomKeysAPI by lazy {
retrofit.create(RoomKeysAPI::class.java)
}
val searchAPI by lazy {
retrofit.create(SearchAPI::class.java)
}
val searchUserAPI by lazy {
retrofit.create(SearchUserAPI::class.java)
}
val signOutAPI by lazy {
retrofit.create(SignOutAPI::class.java)
}
val spaceAPI by lazy {
retrofit.create(SpaceAPI::class.java)
}
val syncAPI by lazy {
retrofit.create(SyncAPI::class.java)
}
val termsAPI by lazy {
retrofit.create(TermsAPI::class.java)
}
val thirdPartyAPI by lazy {
retrofit.create(ThirdPartyAPI::class.java)
}
val voipAPI by lazy {
retrofit.create(VoipAPI::class.java)
}
val wellKnownAPI by lazy {
retrofit.create(WellKnownAPI::class.java)
}
val widgetsAPI by lazy {
retrofit.create(WidgetsAPI::class.java)
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client
import com.squareup.moshi.Moshi
import okhttp3.OkHttpClient
import org.matrix.client.api.AuthAPI
import org.matrix.client.utils.RetrofitFactory
class MatrixUnauthenticatedClient(private val okHttpClient: OkHttpClient,
private val moshi: Moshi,
private val baseUrl: String) {
private val retrofit by lazy {
RetrofitFactory(moshi).create(okHttpClient, baseUrl) { null }
}
val authAPI by lazy {
retrofit.create(AuthAPI::class.java)
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.ChangePasswordParams
import org.matrix.client.model.DeactivateAccountParams
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
interface AccountAPI {
/**
* Ask the homeserver to change the password with the provided new password.
* @param params parameters to change password.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
suspend fun changePassword(@Body params: ChangePasswordParams)
/**
* Deactivate the user account
*
* @param params the deactivate account params
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/deactivate")
suspend fun deactivate(@Body params: DeactivateAccountParams)
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.PUT
import retrofit2.http.Path
interface AccountDataAPI {
/**
* Set some account_data for the client.
*
* @param userId the user id
* @param type the type
* @param params the put params
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/account_data/{type}")
suspend fun setAccountData(@Path("userId") userId: String,
@Path("type") type: String,
@Body params: Any)
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.AddThreePidRegistrationParams
import org.matrix.client.model.AddThreePidRegistrationResponse
import org.matrix.client.model.Availability
import org.matrix.client.model.Credentials
import org.matrix.client.model.LoginFlowResponse
import org.matrix.client.model.PasswordLoginParams
import org.matrix.client.model.RegistrationParams
import org.matrix.client.model.ResetPasswordMailConfirmed
import org.matrix.client.model.SuccessResult
import org.matrix.client.model.TokenLoginParams
import org.matrix.client.model.ValidationCodeBody
import org.matrix.client.model.WebClientConfig
import org.matrix.client.utils.JsonDict
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.Url
/**
* The login REST API.
*/
interface AuthAPI {
/**
* Get a Web client config file, using the name including the domain
*/
@GET("config.{domain}.json")
suspend fun getWebClientConfigDomain(@Path("domain") domain: String): WebClientConfig
/**
* Get a Web client default config file
*/
@GET("config.json")
suspend fun getWebClientConfig(): WebClientConfig
/**
* Register to the homeserver, or get error 401 with a RegistrationFlowResponse object if registration is incomplete
* Ref: https://matrix.org/docs/spec/client_server/latest#account-registration-and-management
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
suspend fun register(@Body registrationParams: RegistrationParams): Credentials
/**
* Checks to see if a username is available, and valid, for the server.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/available")
suspend fun registerAvailable(@Query("username") username: String): Availability
/**
* 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.
* This API may return keys which are not limited to displayname or avatar_url.
* @param userId the user id to fetch profile info
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
suspend fun getProfile(@Path("userId") userId: String): JsonDict
/**
* Add 3Pid during registration
* Ref: https://gist.github.com/jryans/839a09bf0c5a70e2f36ed990d50ed928
* https://github.com/matrix-org/matrix-doc/pull/2290
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "register/{threePid}/requestToken")
suspend fun add3Pid(@Path("threePid") threePid: String,
@Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
/**
* Validate 3pid
*/
@POST
suspend fun validate3Pid(@Url url: String,
@Body params: ValidationCodeBody): SuccessResult
/**
* Get the supported login flow
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
suspend fun getLoginFlows(): LoginFlowResponse
/**
* Pass params to the server for the current login phase.
* Set all the timeouts to 1 minute
*
* @param loginParams the login parameters
*/
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
suspend fun login(@Body loginParams: PasswordLoginParams): Credentials
// Unfortunately we cannot use interface for @Body parameter, so I duplicate the method for the type TokenLoginParams
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
suspend fun login(@Body loginParams: TokenLoginParams): Credentials
/**
* Ask the homeserver to reset the password associated with the provided email.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password/email/requestToken")
suspend fun resetPassword(@Body params: AddThreePidRegistrationParams): AddThreePidRegistrationResponse
/**
* Ask the homeserver to reset the password with the provided new password once the email is validated.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/password")
suspend fun resetPasswordMailConfirmed(@Body params: ResetPasswordMailConfirmed)
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.GetCapabilitiesResult
import org.matrix.client.model.Versions
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
interface CapabilitiesAPI {
/**
* Request the homeserver capabilities
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "capabilities")
suspend fun getCapabilities(): GetCapabilitiesResult
/**
* Request the versions
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
suspend fun getVersions(): Versions
/**
* Ping the homeserver. We do not care about the returned data, so there is no use to parse them
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_ + "versions")
suspend fun ping()
}

View File

@@ -0,0 +1,156 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.DeleteDeviceParams
import org.matrix.client.model.DeviceInfo
import org.matrix.client.model.DevicesListResponse
import org.matrix.client.model.KeyChangesResponse
import org.matrix.client.model.KeysClaimBody
import org.matrix.client.model.KeysClaimResponse
import org.matrix.client.model.KeysQueryBody
import org.matrix.client.model.KeysQueryResponse
import org.matrix.client.model.KeysUploadBody
import org.matrix.client.model.KeysUploadResponse
import org.matrix.client.model.SendToDeviceBody
import org.matrix.client.model.SignatureUploadResponse
import org.matrix.client.model.UpdateDeviceInfoBody
import org.matrix.client.model.UploadSigningKeysBody
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.HTTP
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
interface CryptoAPI {
/**
* Get the devices list
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices")
suspend fun getDevices(): DevicesListResponse
/**
* Get the device info by id
* Doc: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-devices-deviceid
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{deviceId}")
suspend fun getDeviceInfo(@Path("deviceId") deviceId: String): DeviceInfo
/**
* Upload device and/or one-time keys.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-keys-upload
*
* @param body the keys to be sent.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/upload")
suspend fun uploadKeys(@Body body: KeysUploadBody): KeysUploadResponse
/**
* Download device keys.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-keys-query
*
* @param params the params.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/query")
suspend fun downloadKeysForUsers(@Body params: KeysQueryBody): KeysQueryResponse
/**
* CrossSigning - Uploading signing keys
* Public keys for the cross-signing keys are uploaded to the servers using /keys/device_signing/upload.
* This endpoint requires UI Auth.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/device_signing/upload")
suspend fun uploadSigningKeys(@Body params: UploadSigningKeysBody): KeysQueryResponse
/**
* CrossSigning - Uploading signatures
* Signatures of device keys can be up
* loaded using /keys/signatures/upload.
* For example, Alice signs one of her devices (HIJKLMN) (using her self-signing key),
* her own master key (using her HIJKLMN device), Bob's master key (using her user-signing key).
*
* The response contains a failures property, which is a map of user ID to device ID to failure reason, if any of the uploaded keys failed.
* The homeserver should verify that the signatures on the uploaded keys are valid.
* If a signature is not valid, the homeserver should set the corresponding entry in failures to a JSON object
* with the errcode property set to M_INVALID_SIGNATURE.
*
* After Alice uploads a signature for her own devices or master key,
* her signature will be included in the results of the /keys/query request when anyone requests her keys.
* However, signatures made for other users' keys, made by her user-signing key, will not be included.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "keys/signatures/upload")
suspend fun uploadSignatures(@Body params: Map<String, @JvmSuppressWildcards Any>?): SignatureUploadResponse
/**
* Claim one-time keys.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-keys-claim
*
* @param params the params.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/claim")
suspend fun claimOneTimeKeysForUsersDevices(@Body body: KeysClaimBody): KeysClaimResponse
/**
* Send an event to a specific list of devices
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-sendtodevice-eventtype-txnid
*
* @param eventType the type of event to send
* @param transactionId the transaction ID for this event
* @param body the body
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sendToDevice/{eventType}/{txnId}")
suspend fun sendToDevice(@Path("eventType") eventType: String,
@Path("txnId") transactionId: String,
@Body body: SendToDeviceBody)
/**
* Delete a device.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#delete-matrix-client-r0-devices-deviceid
*
* @param deviceId the device id
* @param params the deletion parameters
*/
@HTTP(path = NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}", method = "DELETE", hasBody = true)
suspend fun deleteDevice(@Path("device_id") deviceId: String,
@Body params: DeleteDeviceParams)
/**
* Update the device information.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-devices-deviceid
*
* @param deviceId the device id
* @param params the params
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "devices/{device_id}")
suspend fun updateDeviceInfo(@Path("device_id") deviceId: String,
@Body params: UpdateDeviceInfoBody)
/**
* Get the update devices list from two sync token.
* Doc: https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-keys-changes
*
* @param oldToken the start token.
* @param newToken the up-to token.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "keys/changes")
suspend fun getKeyChanges(@Query("from") oldToken: String,
@Query("to") newToken: String): KeyChangesResponse
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.AddRoomAliasBody
import org.matrix.client.model.RoomAliasDescription
import org.matrix.client.model.RoomDirectoryVisibilityJson
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Path
interface DirectoryAPI {
/**
* Get the room ID associated to the room alias.
*
* @param roomAlias the room alias.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
suspend fun getRoomIdByAlias(@Path("roomAlias") roomAlias: String): RoomAliasDescription
/**
* Get the room directory visibility.
*
* @param roomId the room id.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
suspend fun getRoomDirectoryVisibility(@Path("roomId") roomId: String): RoomDirectoryVisibilityJson
/**
* Set the room directory visibility.
*
* @param roomId the room id.
* @param body the body containing the new directory visibility
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/list/room/{roomId}")
suspend fun setRoomDirectoryVisibility(@Path("roomId") roomId: String,
@Body body: RoomDirectoryVisibilityJson)
/**
* Add alias to the room.
* @param roomAlias the room alias.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
suspend fun addRoomAlias(@Path("roomAlias") roomAlias: String,
@Body body: AddRoomAliasBody)
/**
* Delete a room alias
* @param roomAlias the room alias.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "directory/room/{roomAlias}")
suspend fun deleteRoomAlias(@Path("roomAlias") roomAlias: String)
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.matrix.client.api
import org.matrix.client.model.FederationGetVersionResult
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
interface FederationAPI {
@GET(NetworkConstants.URI_FEDERATION_PATH + "version")
suspend fun getVersion(): FederationGetVersionResult
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2018 Matthias Kesler
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.Filter
import org.matrix.client.model.FilterResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
interface FilterAPI {
/**
* Upload FilterBody to get a filter_id which can be used for /sync requests
*
* @param userId the user id
* @param body the Json representation of a FilterBody object
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter")
suspend fun uploadFilter(@Path("userId") userId: String,
@Body body: Filter): FilterResponse
/**
* Gets a filter with a given filterId from the homeserver
*
* @param userId the user id
* @param filterId the filterID
* @return Filter
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/filter/{filterId}")
suspend fun getFilterById(@Path("userId") userId: String,
@Path("filterId") filterId: String): Filter
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.GroupRooms
import org.matrix.client.model.GroupSummaryResponse
import org.matrix.client.model.GroupUsers
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
import retrofit2.http.Path
interface GroupAPI {
/**
* Request a group summary
*
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/summary")
suspend fun getSummary(@Path("groupId") groupId: String): GroupSummaryResponse
/**
* Request the rooms list.
*
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/rooms")
suspend fun getRooms(@Path("groupId") groupId: String): GroupRooms
/**
* Request the users list.
*
* @param groupId the group id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "groups/{groupId}/users")
suspend fun getUsers(@Path("groupId") groupId: String): GroupUsers
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.IdentityAccountResponse
import org.matrix.client.model.IdentityHashDetailResponse
import org.matrix.client.model.IdentityLookUpParams
import org.matrix.client.model.IdentityLookUpResponse
import org.matrix.client.model.IdentityRequestOwnershipParams
import org.matrix.client.model.IdentityRequestTokenForEmailBody
import org.matrix.client.model.IdentityRequestTokenForMsisdnBody
import org.matrix.client.model.IdentityRequestTokenResponse
import org.matrix.client.model.SuccessResult
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
/**
* Ref: https://matrix.org/docs/spec/identity_service/latest
* This contain the requests which need an identity server token
*/
interface IdentityAPI {
/**
* Gets information about what user owns the access token used in the request.
* Will return a 403 for when terms are not signed
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-account
*/
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "account")
suspend fun getAccount(): IdentityAccountResponse
/**
* Logs out the access token, preventing it from being used to authenticate future requests to the server.
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/logout")
suspend fun logout()
/**
* Request the hash detail to request a bunch of 3PIDs
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-hash-details
*/
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "hash_details")
suspend fun hashDetails(): IdentityHashDetailResponse
/**
* Request a bunch of 3PIDs
* Ref: https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-lookup
*
* @param body the body request
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "lookup")
suspend fun lookup(@Body body: IdentityLookUpParams): IdentityLookUpResponse
/**
* Create a session to change the bind status of an email to an identity server
* The identity server will also send an email
*
* @param body
* @return the sid
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/email/requestToken")
suspend fun requestTokenToBindEmail(@Body body: IdentityRequestTokenForEmailBody): IdentityRequestTokenResponse
/**
* Create a session to change the bind status of an phone number to an identity server
* The identity server will also send an SMS on the ThreePid provided
*
* @param body
* @return the sid
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/msisdn/requestToken")
suspend fun requestTokenToBindMsisdn(@Body body: IdentityRequestTokenForMsisdnBody): IdentityRequestTokenResponse
/**
* Validate ownership of an email address, or a phone number.
* Ref:
* - https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-validate-msisdn-submittoken
* - https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-validate-email-submittoken
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "validate/{medium}/submitToken")
suspend fun submitToken(@Path("medium") medium: String,
@Body body: IdentityRequestOwnershipParams): SuccessResult
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.IdentityRegisterResponse
import org.matrix.client.model.OpenIdToken
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
/**
* Ref: https://matrix.org/docs/spec/identity_service/latest
* This contain the requests which do not need an identity server token
*/
interface IdentityAuthAPI {
/**
* https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
* Simple ping call to check if server exists and is alive
*
* Ref: https://matrix.org/docs/spec/identity_service/unstable#status-check
* https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2
*
* @return 200 in case of success
*/
@GET(NetworkConstants.URI_IDENTITY_PREFIX_PATH)
suspend fun ping()
/**
* Ping v1 will be used to check outdated identity server
*/
@GET("_matrix/identity/api/v1")
suspend fun pingV1()
/**
* Exchanges an OpenID token from the homeserver for an access token to access the identity server.
* The request body is the same as the values returned by /openid/request_token in the Client-Server API.
*/
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "account/register")
suspend fun register(@Body openIdToken: OpenIdToken): IdentityRegisterResponse
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.GetMediaConfigResult
import org.matrix.client.utils.JsonDict
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
import retrofit2.http.Query
interface MediaAPI {
/**
* Retrieve the configuration of the content repository
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
*/
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "config")
suspend fun getMediaConfig(): GetMediaConfigResult
/**
* 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.
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-preview-url
* @param url Required. The URL to get a preview of.
* @param ts The preferred point in time to return a preview for. The server may return a newer version
* if it does not have the requested version available.
*/
@GET(NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "preview_url")
suspend fun getPreviewUrlData(@Query("url") url: String, @Query("ts") ts: Long?): JsonDict
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.OpenIdToken
import org.matrix.client.utils.JsonDict
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
import retrofit2.http.Path
interface OpenIdAPI {
/**
* Gets a bearer token from the homeserver that the user can
* present to a third party in order to prove their ownership
* of the Matrix account they are logged into.
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-user-userid-openid-request-token
*
* @param userId the user id
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/openid/request_token")
suspend fun openIdToken(@Path("userId") userId: String,
@Body body: JsonDict = emptyMap()): OpenIdToken
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.matrix.client.api
import org.matrix.client.model.AccountThreePidsResponse
import org.matrix.client.model.AddEmailBody
import org.matrix.client.model.AddEmailResponse
import org.matrix.client.model.AddMsisdnBody
import org.matrix.client.model.AddMsisdnResponse
import org.matrix.client.model.BindThreePidBody
import org.matrix.client.model.DeleteThreePidBody
import org.matrix.client.model.DeleteThreePidResponse
import org.matrix.client.model.FinalizeAddThreePidBody
import org.matrix.client.model.SetAvatarUrlBody
import org.matrix.client.model.SetDisplayNameBody
import org.matrix.client.model.SuccessResult
import org.matrix.client.model.UnbindThreePidBody
import org.matrix.client.model.UnbindThreePidResponse
import org.matrix.client.model.ValidationCodeBody
import org.matrix.client.utils.JsonDict
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Url
interface ProfileAPI {
/**
* 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.
* This API may return keys which are not limited to displayname or avatar_url.
* If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response can be HTTP 403.
* @param userId the user id to fetch profile info
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
suspend fun getProfile(@Path("userId") userId: String): JsonDict
/**
* List all 3PIDs linked to the Matrix user account.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid")
suspend fun getThreePIDs(): AccountThreePidsResponse
/**
* Change user display name
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
suspend fun setDisplayName(@Path("userId") userId: String,
@Body body: SetDisplayNameBody)
/**
* Change user avatar url.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
suspend fun setAvatarUrl(@Path("userId") userId: String,
@Body body: SetAvatarUrlBody)
/**
* Bind a threePid
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-bind
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/bind")
suspend fun bindThreePid(@Body body: BindThreePidBody)
/**
* Unbind a threePid
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-account-3pid-unbind
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "account/3pid/unbind")
suspend fun unbindThreePid(@Body body: UnbindThreePidBody): UnbindThreePidResponse
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-email-requesttoken
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/email/requestToken")
suspend fun addEmail(@Body body: AddEmailBody): AddEmailResponse
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-msisdn-requesttoken
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/msisdn/requestToken")
suspend fun addMsisdn(@Body body: AddMsisdnBody): AddMsisdnResponse
/**
* Validate Msisdn code (same model than for identity server API)
*/
@POST
suspend fun validateMsisdn(@Url url: String,
@Body params: ValidationCodeBody): SuccessResult
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-add
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/add")
suspend fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody)
/**
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-account-3pid-delete
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid/delete")
suspend fun deleteThreePid(@Body body: DeleteThreePidBody): DeleteThreePidResponse
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.PushGatewayNotifyBody
import org.matrix.client.model.PushGatewayNotifyResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
interface PushGatewayAPI {
/**
* Ask the Push Gateway to send a push to the current device.
*
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#post-matrix-push-v1-notify
*/
@POST(NetworkConstants.URI_PUSH_GATEWAY_PREFIX_PATH + "notify")
suspend fun notify(@Body body: PushGatewayNotifyBody): PushGatewayNotifyResponse
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.GetPushRulesResponse
import org.matrix.client.model.PushRule
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Path
interface PushRulesAPI {
/**
* Get all push rules
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/")
suspend fun getAllRules(): GetPushRulesResponse
/**
* Update the ruleID enable status
*
* @param kind the notification kind (sender, room...)
* @param ruleId the ruleId
* @param enable the new enable status
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
suspend fun updateEnableRuleStatus(@Path("kind") kind: String,
@Path("ruleId") ruleId: String,
@Body enable: Boolean?)
/**
* Update the ruleID action
* Ref: https://matrix.org/docs/spec/client_server/latest#put-matrix-client-r0-pushrules-scope-kind-ruleid-actions
*
* @param kind the notification kind (sender, room...)
* @param ruleId the ruleId
* @param actions the actions
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/actions")
suspend fun updateRuleActions(@Path("kind") kind: String,
@Path("ruleId") ruleId: String,
@Body actions: Any)
/**
* Delete a rule
*
* @param kind the notification kind (sender, room...)
* @param ruleId the ruleId
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
suspend fun deleteRule(@Path("kind") kind: String,
@Path("ruleId") ruleId: String)
/**
* Add the ruleID enable status
*
* @param kind the notification kind (sender, room...)
* @param ruleId the ruleId.
* @param rule the rule to add.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}")
suspend fun addRule(@Path("kind") kind: String,
@Path("ruleId") ruleId: String,
@Body rule: PushRule)
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.GetPushersResponse
import org.matrix.client.model.JsonPusher
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
interface PushersAPI {
/**
* Get the pushers for this user.
*
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushers
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers")
suspend fun getPushers(): GetPushersResponse
/**
* This endpoint allows the creation, modification and deletion of pushers for this user ID.
* The behaviour of this endpoint varies depending on the values in the JSON body.
*
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushers/set")
suspend fun setPusher(@Body jsonPusher: JsonPusher)
}

View File

@@ -0,0 +1,385 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.Content
import org.matrix.client.model.CreateRoomBody
import org.matrix.client.model.CreateRoomResponse
import org.matrix.client.model.Event
import org.matrix.client.model.EventContextResponse
import org.matrix.client.model.GetAliasesResponse
import org.matrix.client.model.InviteBody
import org.matrix.client.model.JoinRoomResponse
import org.matrix.client.model.Membership
import org.matrix.client.model.PaginationResponse
import org.matrix.client.model.PublicRoomsParams
import org.matrix.client.model.PublicRoomsResponse
import org.matrix.client.model.RelationsResponse
import org.matrix.client.model.ReportContentBody
import org.matrix.client.model.RoomMembersResponse
import org.matrix.client.model.RoomUpgradeBody
import org.matrix.client.model.RoomUpgradeResponse
import org.matrix.client.model.SendResponse
import org.matrix.client.model.TagBody
import org.matrix.client.model.ThreePidInviteBody
import org.matrix.client.model.TypingBody
import org.matrix.client.model.UserIdAndReason
import org.matrix.client.utils.JsonDict
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
interface RoomAPI {
/**
* Lists the public rooms on the server, with optional filter.
* This API returns paginated responses. The rooms are ordered by the number of joined members, with the largest rooms first.
*
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-publicrooms
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "publicRooms")
suspend fun publicRooms(@Query("server") server: String?,
@Body publicRoomsParams: PublicRoomsParams
): PublicRoomsResponse
/**
* Create a room.
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-createroom
* Set all the timeouts to 1 minute, because if the server takes time to answer, we will not execute the
* create direct chat request if any
*
* @param param the creation room parameter
*/
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "createRoom")
suspend fun createRoom(@Body param: CreateRoomBody): CreateRoomResponse
/**
* Get a list of messages starting from a reference.
*
* @param roomId the room id
* @param from the token identifying where to start. Required.
* @param dir The direction to return messages from. Required.
* @param limit the maximum number of messages to retrieve. Optional.
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/messages")
suspend fun getRoomMessagesFrom(@Path("roomId") roomId: String,
@Query("from") from: String,
@Query("dir") dir: String,
@Query("limit") limit: Int,
@Query("filter") filter: String?
): PaginationResponse
/**
* Get all members of a room
*
* @param roomId the room id where to get the members
* @param syncToken the sync token (optional)
* @param membership to include only one type of membership (optional)
* @param notMembership to exclude one type of membership (optional)
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/members")
suspend fun getMembers(@Path("roomId") roomId: String,
@Query("at") syncToken: String?,
@Query("membership") membership: Membership?,
@Query("not_membership") notMembership: Membership?
): RoomMembersResponse
/**
* Send an event to a room.
*
* @param txId the transaction Id
* @param roomId the room id
* @param eventType the event type
* @param content the event content
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send/{eventType}/{txId}")
suspend fun send(@Path("txId") txId: String,
@Path("roomId") roomId: String,
@Path("eventType") eventType: String,
@Body content: Content?
): SendResponse
/**
* Get the context surrounding an event.
*
* @param roomId the room id
* @param eventId the event Id
* @param limit the maximum number of messages to retrieve
* @param filter A JSON RoomEventFilter to filter returned events with. Optional.
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/context/{eventId}")
suspend fun getContextOfEvent(@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
@Query("limit") limit: Int,
@Query("filter") filter: String? = null): EventContextResponse
/**
* Retrieve an event from its room id / events id
*
* @param roomId the room id
* @param eventId the event Id
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/event/{eventId}")
suspend fun getEvent(@Path("roomId") roomId: String,
@Path("eventId") eventId: String): Event
/**
* Send read markers.
*
* @param roomId the room id
* @param markers the read markers
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/read_markers")
suspend fun sendReadMarker(@Path("roomId") roomId: String,
@Body markers: Map<String, String>)
/**
* Send receipt to a room
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/receipt/{receiptType}/{eventId}")
suspend fun sendReceipt(@Path("roomId") roomId: String,
@Path("receiptType") receiptType: String,
@Path("eventId") eventId: String)
/**
* Invite a user to the given room.
* Ref: https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-invite
*
* @param roomId the room id
* @param body a object that just contains a user id
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
suspend fun invite(@Path("roomId") roomId: String,
@Body body: InviteBody)
/**
* Invite a user to a room, using a ThreePid
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#id101
* @param roomId Required. The room identifier (not alias) to which to invite the user.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/invite")
suspend fun invite3pid(@Path("roomId") roomId: String,
@Body body: ThreePidInviteBody)
/**
* Send a generic state event
*
* @param roomId the room id.
* @param stateEventType the state event type
* @param params the request parameters
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}")
suspend fun sendStateEvent(@Path("roomId") roomId: String,
@Path("state_event_type") stateEventType: String,
@Body params: JsonDict)
/**
* Send a generic state event
*
* @param roomId the room id.
* @param stateEventType the state event type
* @param stateKey the state keys
* @param params the request parameters
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}/{state_key}")
suspend fun sendStateEvent(@Path("roomId") roomId: String,
@Path("state_event_type") stateEventType: String,
@Path("state_key") stateKey: String,
@Body params: JsonDict)
/**
* Get state events of a room
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-state
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state")
suspend fun getRoomState(@Path("roomId") roomId: String): List<Event>
/**
* Send a relation event to a room.
*
* @param txId the transaction Id
* @param roomId the room id
* @param eventType the event type
* @param content the event content
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
suspend fun sendRelation(@Path("roomId") roomId: String,
@Path("parent_id") parentId: String,
@Path("relation_type") relationType: String,
@Path("event_type") eventType: String,
@Body content: Content?
): SendResponse
/**
* Paginate relations for event based in normal topological order
*
* @param relationType filter for this relation type
* @param eventType filter for this event type
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}/{eventType}")
suspend fun getRelations(@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
@Path("relationType") relationType: String,
@Path("eventType") eventType: String
): RelationsResponse
/**
* Join the given room.
*
* @param roomIdOrAlias the room id or alias
* @param viaServers the servers to attempt to join the room through
* @param params the request body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}")
suspend fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
@Query("server_name") viaServers: List<String>,
@Body params: Map<String, String?>): JoinRoomResponse
/**
* Leave the given room.
*
* @param roomId the room id
* @param params the request body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave")
suspend fun leave(@Path("roomId") roomId: String,
@Body params: Map<String, String?>)
/**
* Ban a user from the given room.
*
* @param roomId the room id
* @param userIdAndReason the banned user object (userId and reason for ban)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/ban")
suspend fun ban(@Path("roomId") roomId: String,
@Body userIdAndReason: UserIdAndReason)
/**
* unban a user from the given room.
*
* @param roomId the room id
* @param userIdAndReason the unbanned user object (userId and reason for unban)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/unban")
suspend fun unban(@Path("roomId") roomId: String,
@Body userIdAndReason: UserIdAndReason)
/**
* Kick a user from the given room.
*
* @param roomId the room id
* @param userIdAndReason the kicked user object (userId and reason for kicking)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/kick")
suspend fun kick(@Path("roomId") roomId: String,
@Body userIdAndReason: UserIdAndReason)
/**
* Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room.
* This cannot be undone.
* Users may redact their own events, and any user with a power level greater than or equal to the redact power level of the room may redact events there.
*
* @param txId the transaction Id
* @param roomId the room id
* @param eventId the event to delete
* @param reason json containing reason key {"reason": "Indecent material"}
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/redact/{eventId}/{txnId}")
suspend fun redactEvent(
@Path("txnId") txId: String,
@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
@Body reason: Map<String, String>
): SendResponse
/**
* Reports an event as inappropriate to the server, which may then notify the appropriate people.
*
* @param roomId the room id
* @param eventId the event to report content
* @param body body containing score and reason
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/report/{eventId}")
suspend fun reportContent(@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
@Body body: ReportContentBody)
/**
* Get a list of aliases maintained by the local server for the given room.
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-rooms-roomid-aliases
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2432/rooms/{roomId}/aliases")
suspend fun getAliases(@Path("roomId") roomId: String): GetAliasesResponse
/**
* Inform that the user is starting to type or has stopped typing
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/typing/{userId}")
suspend fun sendTypingState(@Path("roomId") roomId: String,
@Path("userId") userId: String,
@Body body: TypingBody)
/**
* Room tagging
*/
/**
* Add a tag to a room.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
suspend fun putTag(@Path("userId") userId: String,
@Path("roomId") roomId: String,
@Path("tag") tag: String,
@Body body: TagBody)
/**
* Delete a tag from a room.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/tags/{tag}")
suspend fun deleteTag(@Path("userId") userId: String,
@Path("roomId") roomId: String,
@Path("tag") tag: String)
/**
* Set an AccountData event to the room.
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user/{userId}/rooms/{roomId}/account_data/{type}")
suspend fun setRoomAccountData(@Path("userId") userId: String,
@Path("roomId") roomId: String,
@Path("type") type: String,
@Body content: JsonDict)
/**
* Upgrades the given room to a particular room version.
* Errors:
* 400, The request was invalid. One way this can happen is if the room version requested is not supported by the homeserver
* (M_UNSUPPORTED_ROOM_VERSION)
* 403: The user is not permitted to upgrade the room.(M_FORBIDDEN)
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/upgrade")
suspend fun upgradeRoom(@Path("roomId") roomId: String,
@Body body: RoomUpgradeBody): RoomUpgradeResponse
}

View File

@@ -0,0 +1,191 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.BackupKeysResult
import org.matrix.client.model.CreateKeysBackupVersionBody
import org.matrix.client.model.KeyBackupData
import org.matrix.client.model.KeysBackupData
import org.matrix.client.model.KeysVersion
import org.matrix.client.model.KeysVersionResult
import org.matrix.client.model.RoomKeysBackupData
import org.matrix.client.model.UpdateKeysBackupVersionBody
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
/**
* Ref: https://matrix.org/docs/spec/client_server/unstable#server-side-key-backups
*/
interface RoomKeysAPI {
/* ==========================================================================================
* Backup versions management
* ========================================================================================== */
/**
* Create a new keys backup version.
* @param createKeysBackupVersionBody the body
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
suspend fun createKeysBackupVersion(@Body createKeysBackupVersionBody: CreateKeysBackupVersionBody): KeysVersion
/**
* Get the key backup last version
* If not supported by the server, an error is returned: {"errcode":"M_NOT_FOUND","error":"No backup found"}
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version")
suspend fun getKeysBackupLastVersion(): KeysVersionResult
/**
* Get information about the given version.
* If not supported by the server, an error is returned: {"errcode":"M_NOT_FOUND","error":"No backup found"}
*
* @param version version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
suspend fun getKeysBackupVersion(@Path("version") version: String): KeysVersionResult
/**
* Update information about the given version.
* @param version version
* @param updateKeysBackupVersionBody the body
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
suspend fun updateKeysBackupVersion(@Path("version") version: String,
@Body keysBackupVersionBody: UpdateKeysBackupVersionBody)
/* ==========================================================================================
* Storing keys
* ========================================================================================== */
/**
* Store the key for the given session in the given room, using the given backup version.
*
*
* If the server already has a backup in the backup version for the given session and room, then it will
* keep the "better" one. To determine which one is "better", key backups are compared first by the is_verified
* flag (true is better than false), then by the first_message_index (a lower number is better), and finally by
* forwarded_count (a lower number is better).
*
* @param roomId the room id
* @param sessionId the session id
* @param version the version of the backup
* @param keyBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
suspend fun storeRoomSessionData(@Path("roomId") roomId: String,
@Path("sessionId") sessionId: String,
@Query("version") version: String,
@Body keyBackupData: KeyBackupData): BackupKeysResult
/**
* Store several keys for the given room, using the given backup version.
*
* @param roomId the room id
* @param version the version of the backup
* @param roomKeysBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
suspend fun storeRoomSessionsData(@Path("roomId") roomId: String,
@Query("version") version: String,
@Body roomKeysBackupData: RoomKeysBackupData): BackupKeysResult
/**
* Store several keys, using the given backup version.
*
* @param version the version of the backup
* @param keysBackupData the data to send
*/
@PUT(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
suspend fun storeSessionsData(@Query("version") version: String,
@Body keysBackupData: KeysBackupData): BackupKeysResult
/* ==========================================================================================
* Retrieving keys
* ========================================================================================== */
/**
* Retrieve the key for the given session in the given room from the backup.
*
* @param roomId the room id
* @param sessionId the session id
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
suspend fun getRoomSessionData(@Path("roomId") roomId: String,
@Path("sessionId") sessionId: String,
@Query("version") version: String): KeyBackupData
/**
* Retrieve all the keys for the given room from the backup.
*
* @param roomId the room id
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
suspend fun getRoomSessionsData(@Path("roomId") roomId: String,
@Query("version") version: String): RoomKeysBackupData
/**
* Retrieve all the keys from the backup.
*
* @param version the version of the backup, or empty String to retrieve the last version
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
suspend fun getSessionsData(@Query("version") version: String): KeysBackupData
/* ==========================================================================================
* Deleting keys
* ========================================================================================== */
/**
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}/{sessionId}")
suspend fun deleteRoomSessionData(@Path("roomId") roomId: String,
@Path("sessionId") sessionId: String,
@Query("version") version: String)
/**
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys/{roomId}")
suspend fun deleteRoomSessionsData(@Path("roomId") roomId: String,
@Query("version") version: String)
/**
* Deletes keys from the backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/keys")
suspend fun deleteSessionsData(@Query("version") version: String)
/* ==========================================================================================
* Deleting backup
* ========================================================================================== */
/**
* Deletes a backup.
*/
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "room_keys/version/{version}")
suspend fun deleteBackup(@Path("version") version: String)
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.SearchRequestBody
import org.matrix.client.model.SearchResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
import retrofit2.http.Query
interface SearchAPI {
/**
* Performs a full text search across different categories.
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-search
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "search")
suspend fun search(@Query("next_batch") nextBatch: String?,
@Body body: SearchRequestBody): SearchResponse
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.SearchUsersParams
import org.matrix.client.model.SearchUsersResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
interface SearchUserAPI {
/**
* Perform a user search.
*
* @param searchUsersParams the search params.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "user_directory/search")
suspend fun searchUsers(@Body searchUsersParams: SearchUsersParams): SearchUsersResponse
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.Credentials
import org.matrix.client.model.PasswordLoginParams
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.POST
interface SignOutAPI {
/**
* Attempt to login again to the same account.
* Set all the timeouts to 1 minute
* It is similar to [AuthAPI.login]
*
* @param loginParams the login parameters
*/
@Headers("CONNECT_TIMEOUT:60000", "READ_TIMEOUT:60000", "WRITE_TIMEOUT:60000")
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "login")
suspend fun loginAgain(@Body loginParams: PasswordLoginParams): Credentials
/**
* Invalidate the access token, so that it can no longer be used for authorization.
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "logout")
suspend fun signOut()
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.SpaceSummaryParams
import org.matrix.client.model.SpacesResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.Body
import retrofit2.http.POST
import retrofit2.http.Path
interface SpaceAPI {
/**
*
* POST /_matrix/client/r0/rooms/{roomID}/spaces
* {
* "max_rooms_per_space": 5, // The maximum number of rooms/subspaces to return for a given space, if negative unbounded. default: -1.
* "auto_join_only": true, // If true, only return m.space.child events with auto_join:true, default: false, which returns all events.
* "limit": 100, // The maximum number of rooms/subspaces to return, server can override this, default: 100.
* "batch": "opaque_string" // A token to use if this is a subsequent HTTP hit, default: "".
* }
*
* Ref:
* - MSC 2946 https://github.com/matrix-org/matrix-doc/blob/kegan/spaces-summary/proposals/2946-spaces-summary.md
* - https://hackmd.io/fNYh4tjUT5mQfR1uuRzWDA
*/
@POST(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc2946/rooms/{roomId}/spaces")
suspend fun getSpaces(@Path("roomId") spaceId: String,
@Body params: SpaceSummaryParams): SpacesResponse
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import okhttp3.ResponseBody
import org.matrix.client.model.SyncResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.QueryMap
import retrofit2.http.Streaming
interface SyncAPI {
/**
* Set all the timeouts to 1 minute by default
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sync")
suspend fun sync(@QueryMap params: Map<String, String>): SyncResponse
/**
* Set all the timeouts to 1 minute by default
*/
@Streaming
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sync")
fun syncStream(@QueryMap params: Map<String, String>): Call<ResponseBody>
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.AcceptTermsBody
import org.matrix.client.model.TermsResponse
import org.matrix.client.utils.HttpHeaders
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Url
interface TermsAPI {
/**
* This request does not require authentication
*/
@GET
suspend fun getTerms(@Url url: String): TermsResponse
/**
* This request requires authentication
*/
@POST
suspend fun agreeToTerms(@Url url: String,
@Body params: AcceptTermsBody,
@Header(HttpHeaders.Authorization) token: String)
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.ThirdPartyProtocol
import org.matrix.client.model.ThirdPartyUser
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.QueryMap
interface ThirdPartyAPI {
/**
* Get the third party server protocols.
*
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-r0-thirdparty-protocols
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "thirdparty/protocols")
suspend fun thirdPartyProtocols(): Map<String, ThirdPartyProtocol>
/**
* Retrieve a Matrix User ID linked to a user on the third party service, given a set of user parameters.
*
* Ref: https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-thirdparty-user-protocol
*/
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "thirdparty/user/{protocol}")
suspend fun getThirdPartyUser(@Path("protocol") protocol: String,
@QueryMap params: Map<String, String>?): List<ThirdPartyUser>
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.TurnServerResponse
import org.matrix.client.utils.NetworkConstants
import retrofit2.http.GET
interface VoipAPI {
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "voip/turnServer")
suspend fun getTurnServer(): TurnServerResponse
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.WellKnown
import retrofit2.http.GET
import retrofit2.http.Path
interface WellKnownAPI {
@GET("https://{domain}/.well-known/matrix/client")
suspend fun getWellKnown(@Path("domain") domain: String): WellKnown
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.api
import org.matrix.client.model.OpenIdToken
import org.matrix.client.model.RegisterWidgetResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query
interface WidgetsAPI {
/**
* register to the server
*
* @param body the body content (Ref: https://github.com/matrix-org/matrix-doc/pull/1961)
*/
@POST("register")
suspend fun register(@Body body: OpenIdToken,
@Query("v") version: String?): RegisterWidgetResponse
@GET("account")
suspend fun validateToken(@Query("scalar_token") scalarToken: String?,
@Query("v") version: String?)
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represent a list of urls of terms the user wants to accept
*/
@JsonClass(generateAdapter = true)
data class AcceptTermsBody(
@Json(name = "user_accepts")
val acceptedTermUrls: List<String>
)

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Class representing the ThreePids response
*/
@JsonClass(generateAdapter = true)
data class AccountThreePidsResponse(
@Json(name = "threepids")
val threePids: List<ThirdPartyIdentifier>? = null
)

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddEmailBody(
/**
* Required. A unique string generated by the client, and used to identify the validation attempt.
* It must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed
* 255 characters and it must not be empty.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The email address to validate.
*/
@Json(name = "email")
val email: String,
/**
* Required. The server will only send an email if the send_attempt is a number greater than the most
* recent one which it has seen, scoped to that email + client_secret pair. This is to avoid repeatedly
* sending the same email in the case of request retries between the POSTing user and the identity server.
* The client should increment this value if they desire a new email (e.g. a reminder) to be sent.
* If they do not, the server should respond with success but not resend the email.
*/
@Json(name = "send_attempt")
val sendAttempt: Int
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddEmailResponse(
/**
* Required. The session ID. Session IDs are opaque strings that must consist entirely
* of the characters [0-9a-zA-Z.=_-]. Their length must not exceed 255 characters and they must not be empty.
*/
@Json(name = "sid")
val sid: String
)

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddMsisdnBody(
/**
* Required. A unique string generated by the client, and used to identify the validation attempt.
* It must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed
* 255 characters and it must not be empty.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The two-letter uppercase ISO-3166-1 alpha-2 country code that the number in
* phone_number should be parsed as if it were dialled from.
*/
@Json(name = "country")
val country: String,
/**
* Required. The phone number to validate.
*/
@Json(name = "phone_number")
val phoneNumber: String,
/**
* Required. The server will only send an SMS if the send_attempt is a number greater than the most
* recent one which it has seen, scoped to that country + phone_number + client_secret triple. This
* is to avoid repeatedly sending the same SMS in the case of request retries between the POSTing user
* and the identity server. The client should increment this value if they desire a new SMS (e.g. a
* reminder) to be sent.
*/
@Json(name = "send_attempt")
val sendAttempt: Int
)

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddMsisdnResponse(
/**
* Required. The session ID. Session IDs are opaque strings that must consist entirely of the characters [0-9a-zA-Z.=_-].
* Their length must not exceed 255 characters and they must not be empty.
*/
@Json(name = "sid")
val sid: String,
/**
* An optional field containing a URL where the client must submit the validation token to, with identical parameters to the Identity
* Service API's POST /validate/email/submitToken endpoint (without the requirement for an access token).
* The homeserver must send this token to the user (if applicable), who should then be prompted to provide it to the client.
*
* If this field is not present, the client can assume that verification will happen without the client's involvement provided
* the homeserver advertises this specification version in the /versions response (ie: r0.5.0).
*/
@Json(name = "submit_url")
val submitUrl: String? = null,
/* ==========================================================================================
* It seems that the homeserver is sending more data, we may need it
* ========================================================================================== */
@Json(name = "msisdn")
val msisdn: String? = null,
@Json(name = "intl_fmt")
val formattedMsisdn: String? = null,
@Json(name = "success")
val success: Boolean? = null
)

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddRoomAliasBody(
/**
* Required. The room id which the alias will be added to.
*/
@Json(name = "room_id") val roomId: String
)

View File

@@ -0,0 +1,82 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Add a three Pid during authentication
*/
@JsonClass(generateAdapter = true)
data class AddThreePidRegistrationParams(
/**
* Required. A unique string generated by the client, and used to identify the validation attempt.
* It must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed 255 characters and it must not be empty.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The server will only send an email if the send_attempt is a number greater than the most recent one which it has seen,
* scoped to that email + client_secret pair. This is to avoid repeatedly sending the same email in the case of request retries between
* the POSTing user and the identity server. The client should increment this value if they desire a new email (e.g. a reminder) to be sent.
* If they do not, the server should respond with success but not resend the email.
*/
@Json(name = "send_attempt")
val sendAttempt: Int,
/**
* Optional. When the validation is completed, the identity server will redirect the user to this URL. This option is ignored when
* submitting 3PID validation information through a POST request.
*/
@Json(name = "next_link")
val nextLink: String? = null,
/**
* Required. The hostname of the identity server to communicate with. May optionally include a port.
* This parameter is ignored when the homeserver handles 3PID verification.
*/
@Json(name = "id_server")
val idServer: String? = null,
/* ==========================================================================================
* For emails
* ========================================================================================== */
/**
* Required. The email address to validate.
*/
@Json(name = "email")
val email: String? = null,
/* ==========================================================================================
* For Msisdn
* ========================================================================================== */
/**
* Required. The two-letter uppercase ISO country code that the number in phone_number should be parsed as if it were dialled from.
*/
@Json(name = "country")
val countryCode: String? = null,
/**
* Required. The phone number to validate.
*/
@Json(name = "phone_number")
val msisdn: String? = null
)

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class AddThreePidRegistrationResponse(
/**
* Required. The session ID. Session IDs are opaque strings that must consist entirely of the characters [0-9a-zA-Z.=_-].
* Their length must not exceed 255 characters and they must not be empty.
*/
@Json(name = "sid")
val sid: String,
/**
* An optional field containing a URL where the client must submit the validation token to, with identical parameters to the Identity
* Service API's POST /validate/email/submitToken endpoint. The homeserver must send this token to the user (if applicable),
* who should then be prompted to provide it to the client.
*
* If this field is not present, the client can assume that verification will happen without the client's involvement provided
* the homeserver advertises this specification version in the /versions response (ie: r0.5.0).
*/
@Json(name = "submit_url")
val submitUrl: String? = null,
/* ==========================================================================================
* It seems that the homeserver is sending more data, we may need it
* ========================================================================================== */
@Json(name = "msisdn")
val msisdn: String? = null,
@Json(name = "intl_fmt")
val formattedMsisdn: String? = null,
@Json(name = "success")
val success: Boolean? = null
)

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.JsonClass
/**
* <code>
* {
* "chunk": [
* {
* "type": "m.reaction",
* "key": "👍",
* "count": 3
* }
* ],
* "limited": false,
* "count": 1
* },
* </code>
*/
@JsonClass(generateAdapter = true)
data class AggregatedAnnotation(
override val limited: Boolean? = false,
override val count: Int? = 0,
val chunk: List<RelationChunkInfo>? = null
) : UnsignedRelationInfo

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* <code>
* {
* "m.annotation": {
* "chunk": [
* {
* "type": "m.reaction",
* "key": "👍",
* "count": 3
* }
* ],
* "limited": false,
* "count": 1
* },
* "m.reference": {
* "chunk": [
* {
* "type": "m.room.message",
* "event_id": "$some_event_id"
* }
* ],
* "limited": false,
* "count": 1
* }
* }
* </code>
*/
@JsonClass(generateAdapter = true)
data class AggregatedRelations(
@Json(name = "m.annotation") val annotations: AggregatedAnnotation? = null,
@Json(name = "m.reference") val references: DefaultUnsignedRelationInfo? = null
)

View File

@@ -0,0 +1,101 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Open class, parent to all possible authentication parameters
*/
@JsonClass(generateAdapter = true)
data class AuthParams(
@Json(name = "type")
val type: String,
/**
* Note: session can be null for reset password request
*/
@Json(name = "session")
val session: String?,
/**
* parameter for "m.login.recaptcha" type
*/
@Json(name = "response")
val captchaResponse: String? = null,
/**
* parameter for "m.login.email.identity" type
*/
@Json(name = "threepid_creds")
val threePidCredentials: ThreePidCredentials? = null
) {
companion object {
fun createForCaptcha(session: String, captchaResponse: String): AuthParams {
return AuthParams(
type = LoginFlowTypes.RECAPTCHA,
session = session,
captchaResponse = captchaResponse
)
}
fun createForEmailIdentity(session: String, threePidCredentials: ThreePidCredentials): AuthParams {
return AuthParams(
type = LoginFlowTypes.EMAIL_IDENTITY,
session = session,
threePidCredentials = threePidCredentials
)
}
/**
* Note that there is a bug in Synapse (I have to investigate where), but if we pass LoginFlowTypes.MSISDN,
* the homeserver answer with the login flow with MatrixError fields and not with a simple MatrixError 401.
*/
fun createForMsisdnIdentity(session: String, threePidCredentials: ThreePidCredentials): AuthParams {
return AuthParams(
type = LoginFlowTypes.MSISDN,
session = session,
threePidCredentials = threePidCredentials
)
}
fun createForResetPassword(clientSecret: String, sid: String): AuthParams {
return AuthParams(
type = LoginFlowTypes.EMAIL_IDENTITY,
session = null,
threePidCredentials = ThreePidCredentials(
clientSecret = clientSecret,
sid = sid
)
)
}
}
}
@JsonClass(generateAdapter = true)
data class ThreePidCredentials(
@Json(name = "client_secret")
val clientSecret: String? = null,
@Json(name = "id_server")
val idServer: String? = null,
@Json(name = "sid")
val sid: String? = null
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class Availability(
/**
* A flag to indicate that the username is available. This should always be true when the server replies with 200 OK.
*/
@Json(name = "available")
val available: Boolean? = null
)

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class BackupKeysResult(
// The hash value which is an opaque string representing stored keys in the backup
@Json(name = "etag")
val hash: String,
// The number of keys stored in the backup.
@Json(name = "count")
val count: Int
)

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class BindThreePidBody(
/**
* Required. The client secret used in the session with the identity server.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The identity server to use. (without "https://")
*/
@Json(name = "id_server")
var identityServerUrlWithoutProtocol: String,
/**
* Required. An access token previously registered with the identity server.
*/
@Json(name = "id_access_token")
var identityServerAccessToken: String,
/**
* Required. The session identifier given by the identity server.
*/
@Json(name = "sid")
var sid: String
)

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Class to pass request parameters to update the password.
*/
@JsonClass(generateAdapter = true)
data class ChangePasswordParams(
@Json(name = "auth")
val auth: UserPasswordAuth? = null,
@Json(name = "new_password")
val newPassword: String? = null
) {
companion object {
fun create(userId: String, oldPassword: String, newPassword: String): ChangePasswordParams {
return ChangePasswordParams(
auth = UserPasswordAuth(user = userId, password = oldPassword),
newPassword = newPassword
)
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.client.utils.JsonDict
@JsonClass(generateAdapter = true)
data class CreateKeysBackupVersionBody(
/**
* The algorithm used for storing backups. Currently, only "m.megolm_backup.v1.curve25519-aes-sha2" is defined
*/
@Json(name = "algorithm")
override val algorithm: String,
/**
* algorithm-dependent data, for "m.megolm_backup.v1.curve25519-aes-sha2"
* see [org.matrix.android.sdk.internal.crypto.keysbackup.MegolmBackupAuthData]
*/
@Json(name = "auth_data")
override val authData: JsonDict
) : KeysAlgorithmAndData

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Parameter to create a room
*/
@JsonClass(generateAdapter = true)
data class CreateRoomBody(
/**
* A public visibility indicates that the room will be shown in the published room list.
* A private visibility will hide the room from the published room list.
* Rooms default to private visibility if this key is not included.
* NB: This should not be confused with join_rules which also uses the word public. One of: ["public", "private"]
*/
@Json(name = "visibility")
val visibility: RoomDirectoryVisibility?,
/**
* The desired room alias local part. If this is included, a room alias will be created and mapped to the newly created room.
* The alias will belong on the same homeserver which created the room.
* For example, if this was set to "foo" and sent to the homeserver "example.com" the complete room alias would be #foo:example.com.
*/
@Json(name = "room_alias_name")
val roomAliasName: String?,
/**
* If this is included, an m.room.name event will be sent into the room to indicate the name of the room.
* See Room Events for more information on m.room.name.
*/
@Json(name = "name")
val name: String?,
/**
* If this is included, an m.room.topic event will be sent into the room to indicate the topic for the room.
* See Room Events for more information on m.room.topic.
*/
@Json(name = "topic")
val topic: String?,
/**
* A list of user IDs to invite to the room.
* This will tell the server to invite everyone in the list to the newly created room.
*/
@Json(name = "invite")
val invitedUserIds: List<String>?,
/**
* A list of objects representing third party IDs to invite into the room.
*/
@Json(name = "invite_3pid")
val invite3pids: List<ThreePidInviteBody>?,
/**
* Extra keys, such as m.federate, to be added to the content of the m.room.create event.
* The server will clobber the following keys: creator, room_version.
* Future versions of the specification may allow the server to clobber other keys.
*/
@Json(name = "creation_content")
val creationContent: Any?,
/**
* A list of state events to set in the new room.
* This allows the user to override the default state events set in the new room.
* The expected format of the state events are an object with type, state_key and content keys set.
* Takes precedence over events set by presets, but gets overridden by name and topic keys.
*/
@Json(name = "initial_state")
val initialStates: List<Event>?,
/**
* Convenience parameter for setting various default state events based on a preset. Must be either:
* private_chat => join_rules is set to invite. history_visibility is set to shared.
* trusted_private_chat => join_rules is set to invite. history_visibility is set to shared. All invitees are given the same power level as the
* room creator.
* public_chat: => join_rules is set to public. history_visibility is set to shared.
*/
@Json(name = "preset")
val preset: CreateRoomPreset?,
/**
* This flag makes the server set the is_direct flag on the m.room.member events sent to the users in invite and invite_3pid.
* See Direct Messaging for more information.
*/
@Json(name = "is_direct")
val isDirect: Boolean?,
/**
* The power level content to override in the default power level event
*/
@Json(name = "power_level_content_override")
val powerLevelContentOverride: PowerLevelsContent?,
/**
* The room version to set for the room. If not provided, the homeserver is to use its configured default.
* If provided, the homeserver will return a 400 error with the errcode M_UNSUPPORTED_ROOM_VERSION if it does not support the room version.
*/
@Json(name = "room_version")
val roomVersion: String?
)

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = false)
enum class CreateRoomPreset {
@Json(name = "private_chat")
PRESET_PRIVATE_CHAT,
@Json(name = "public_chat")
PRESET_PUBLIC_CHAT,
@Json(name = "trusted_private_chat")
PRESET_TRUSTED_PRIVATE_CHAT
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class CreateRoomResponse(
/**
* Required. The created room's ID.
*/
@Json(name = "room_id") val roomId: String
)
typealias JoinRoomResponse = CreateRoomResponse

View File

@@ -0,0 +1,58 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This data class hold credentials user data.
* You shouldn't have to instantiate it.
* The access token should be use to authenticate user in all server requests.
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-login
*/
@JsonClass(generateAdapter = true)
data class Credentials(
/**
* The fully-qualified Matrix ID that has been registered.
*/
@Json(name = "user_id") val userId: String,
/**
* An access token for the account. This access token can then be used to authorize other requests.
*/
@Json(name = "access_token") val accessToken: String,
/**
* Not documented
*/
@Json(name = "refresh_token") val refreshToken: String?,
/**
* The server_name of the homeserver on which the account has been registered.
* @Deprecated. Clients should extract the server_name from user_id (by splitting at the first colon)
* if they require it. Note also that homeserver is not spelt this way.
*/
@Json(name = "home_server") val homeServer: String?,
/**
* ID of the logged-in device. Will be the same as the corresponding parameter in the request, if one was specified.
*/
@Json(name = "device_id") val deviceId: String?,
/**
* Optional client configuration provided by the server. If present, clients SHOULD use the provided object to
* reconfigure themselves, optionally validating the URLs within.
* This object takes the same form as the one returned from .well-known autodiscovery.
*/
@Json(name = "well_known") val discoveryInformation: DiscoveryInformation? = null
)

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeactivateAccountParams(
// Set to true to erase all data of the account
@Json(name = "erase")
val erase: Boolean,
@Json(name = "auth")
val auth: Map<String, *>? = null
) {
companion object {
fun create(auth: UIABaseAuth?, erase: Boolean): DeactivateAccountParams {
return DeactivateAccountParams(
auth = auth?.asMap(),
erase = erase
)
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DefaultUnsignedRelationInfo(
override val limited: Boolean? = false,
override val count: Int? = 0,
val chunk: List<Map<String, Any>>? = null
) : UnsignedRelationInfo

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class provides the parameter to delete a device
*/
@JsonClass(generateAdapter = true)
data class DeleteDeviceParams(
@Json(name = "auth")
val auth: Map<String, *>? = null
)

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeleteThreePidBody(
/**
* Required. The medium of the third party identifier being removed. One of: ["email", "msisdn"]
*/
@Json(name = "medium") val medium: String,
/**
* Required. The third party address being removed.
*/
@Json(name = "address") val address: String
)

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeleteThreePidResponse(
/**
* Required. An indicator as to whether or not the homeserver was able to unbind the 3PID from
* the identity server. success indicates that the identity server has unbound the identifier
* whereas no-support indicates that the identity server refuses to support the request or the
* homeserver was not able to determine an identity server to unbind from. One of: ["no-support", "success"]
*/
@Json(name = "id_server_unbind_result")
val idServerUnbindResult: String? = null
)

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class describes the device information
*/
@JsonClass(generateAdapter = true)
data class DeviceInfo(
/**
* The owner user id
*/
@Json(name = "user_id")
val userId: String? = null,
/**
* The device id
*/
@Json(name = "device_id")
val deviceId: String? = null,
/**
* The device display name
*/
@Json(name = "display_name")
val displayName: String? = null,
/**
* The last time this device has been seen.
*/
@Json(name = "last_seen_ts")
val lastSeenTs: Long = 0,
/**
* The last ip address
*/
@Json(name = "last_seen_ip")
val lastSeenIp: String? = null
)

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeviceKeys(
/**
* Required. The ID of the user the device belongs to. Must match the user ID used when logging in.
*/
@Json(name = "user_id")
val userId: String,
/**
* Required. The ID of the device these keys belong to. Must match the device ID used when logging in.
*/
@Json(name = "device_id")
val deviceId: String,
/**
* Required. The encryption algorithms supported by this device.
*/
@Json(name = "algorithms")
val algorithms: List<String>?,
/**
* Required. Public identity keys. The names of the properties should be in the format <algorithm>:<device_id>.
* The keys themselves should be encoded as specified by the key algorithm.
*/
@Json(name = "keys")
val keys: Map<String, String>?,
/**
* Required. Signatures for the device key object. A map from user ID, to a map from <algorithm>:<device_id> to the signature.
* The signature is calculated using the process described at https://matrix.org/docs/spec/appendices.html#signing-json.
*/
@Json(name = "signatures")
val signatures: Map<String, Map<String, String>>?
)

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeviceKeysWithUnsigned(
/**
* Required. The ID of the user the device belongs to. Must match the user ID used when logging in.
*/
@Json(name = "user_id")
val userId: String,
/**
* Required. The ID of the device these keys belong to. Must match the device ID used when logging in.
*/
@Json(name = "device_id")
val deviceId: String,
/**
* Required. The encryption algorithms supported by this device.
*/
@Json(name = "algorithms")
val algorithms: List<String>?,
/**
* Required. Public identity keys. The names of the properties should be in the format <algorithm>:<device_id>.
* The keys themselves should be encoded as specified by the key algorithm.
*/
@Json(name = "keys")
val keys: Map<String, String>?,
/**
* Required. Signatures for the device key object. A map from user ID, to a map from <algorithm>:<device_id> to the signature.
* The signature is calculated using the process described at https://matrix.org/docs/spec/appendices.html#signing-json.
*/
@Json(name = "signatures")
val signatures: Map<String, Map<String, String>>?,
/**
* Additional data added to the device key information by intermediate servers, and not covered by the signatures.
*/
@Json(name = "unsigned")
val unsigned: UnsignedDeviceInfo? = null
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.JsonClass
/**
* This class describes the device list response from a sync request
*/
@JsonClass(generateAdapter = true)
data class DeviceListResponse(
// user ids list which have new crypto devices
val changed: List<String> = emptyList(),
// List of user ids who are no more tracked.
val left: List<String> = emptyList()
)

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class DeviceOneTimeKeysCountSyncResponse(
@Json(name = "signed_curve25519") val signedCurve25519: Int? = null
)

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.JsonClass
/**
* This class describes the
*/
@JsonClass(generateAdapter = true)
data class DevicesListResponse(
val devices: List<DeviceInfo>? = null
)

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This is a light version of Wellknown model, used for login response
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-login
*/
@JsonClass(generateAdapter = true)
data class DiscoveryInformation(
/**
* Required. Used by clients to discover homeserver information.
*/
@Json(name = "m.homeserver")
val homeServer: WellKnownBaseConfig? = null,
/**
* Used by clients to discover identity server information.
* Note: matrix.org does not send this field
*/
@Json(name = "m.identity_server")
val identityServer: WellKnownBaseConfig? = null
)

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.client.utils.JsonDict
typealias Content = JsonDict
/**
* Generic event class with all possible fields for events.
*/
@JsonClass(generateAdapter = true)
data class Event(
@Json(name = "type") val type: String? = null,
@Json(name = "event_id") val eventId: String? = null,
@Json(name = "content") val content: Content? = null,
@Json(name = "prev_content") val prevContent: Content? = null,
@Json(name = "origin_server_ts") val originServerTs: Long? = null,
@Json(name = "sender") val senderId: String? = null,
@Json(name = "state_key") val stateKey: String? = null,
@Json(name = "room_id") val roomId: String? = null,
@Json(name = "unsigned") val unsignedData: UnsignedData? = null,
@Json(name = "redacts") val redacts: String? = null
)

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class EventContextResponse(
/**
* Details of the requested event.
*/
@Json(name = "event") val event: Event,
/**
* A token that can be used to paginate backwards with.
*/
@Json(name = "start") override val start: String? = null,
/**
* A list of room events that happened just before the requested event, in reverse-chronological order.
*/
@Json(name = "events_before") val eventsBefore: List<Event>? = null,
/**
* A list of room events that happened just after the requested event, in chronological order.
*/
@Json(name = "events_after") val eventsAfter: List<Event>? = null,
/**
* A token that can be used to paginate forwards with.
*/
@Json(name = "end") override val end: String? = null,
/**
* The state of the room at the last event returned.
*/
@Json(name = "state") override val stateEvents: List<Event>? = null
) : TokenChunkEvent {
override val events: List<Event> by lazy {
eventsAfter.orEmpty().reversed() + event + eventsBefore.orEmpty()
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Represents "Filter" as mentioned in the SPEC
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class EventFilter(
/**
* The maximum number of events to return.
*/
@Json(name = "limit") val limit: Int? = null,
/**
* A list of senders IDs to include. If this list is absent then all senders are included.
*/
@Json(name = "senders") val senders: List<String>? = null,
/**
* A list of sender IDs to exclude. If this list is absent then no senders are excluded.
* A matching sender will be excluded even if it is listed in the 'senders' filter.
*/
@Json(name = "not_senders") val notSenders: List<String>? = null,
/**
* A list of event types to include. If this list is absent then all event types are included.
* A '*' can be used as a wildcard to match any sequence of characters.
*/
@Json(name = "types") val types: List<String>? = null,
/**
* A list of event types to exclude. If this list is absent then no event types are excluded.
* A matching type will be excluded even if it is listed in the 'types' filter.
* A '*' can be used as a wildcard to match any sequence of characters.
*/
@Json(name = "not_types") val notTypes: List<String>? = null
) {
fun hasData(): Boolean {
return limit != null
|| senders != null
|| notSenders != null
|| types != null
|| notTypes != null
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Ref: https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-version
*/
@JsonClass(generateAdapter = true)
data class FederationGetVersionResult(
@Json(name = "server")
val server: FederationGetVersionServer?
)
@JsonClass(generateAdapter = true)
data class FederationGetVersionServer(
/**
* Arbitrary name that identify this implementation.
*/
@Json(name = "name")
val name: String?,
/**
* Version of this implementation. The version format depends on the implementation.
*/
@Json(name = "version")
val version: String?
)

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class FieldType(
/**
* Required. A regular expression for validation of a field's value. This may be relatively coarse to verify the value as the application
* service providing this protocol may apply additional
*/
@Json(name = "regexp")
val regexp: String? = null,
/**
* Required. An placeholder serving as a valid example of the field value.
*/
@Json(name = "placeholder")
val placeholder: String? = null
)

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Class which can be parsed to a filter json string. Used for POST and GET
* Have a look here for further information:
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class Filter(
/**
* List of event fields to include. If this list is absent then all fields are included. The entries may
* include '.' characters to indicate sub-fields. So ['content.body'] will include the 'body' field of the
* 'content' object. A literal '.' character in a field name may be escaped using a '\'. A server may
* include more fields than were requested.
*/
@Json(name = "event_fields") val eventFields: List<String>? = null,
/**
* The format to use for events. 'client' will return the events in a format suitable for clients.
* 'federation' will return the raw event as received over federation. The default is 'client'. One of: ["client", "federation"]
*/
@Json(name = "event_format") val eventFormat: String? = null,
/**
* The presence updates to include.
*/
@Json(name = "presence") val presence: EventFilter? = null,
/**
* The user account data that isn't associated with rooms to include.
*/
@Json(name = "account_data") val accountData: EventFilter? = null,
/**
* Filters to be applied to room data.
*/
@Json(name = "room") val room: RoomFilter? = null
)

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Represents the body which is the response when creating a filter on the server
* https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter
*/
@JsonClass(generateAdapter = true)
data class FilterResponse(
/**
* Required. The ID of the filter that was created. Cannot start with a { as this character
* is used to determine if the filter provided is inline JSON or a previously declared
* filter by homeservers on some APIs.
*/
@Json(name = "filter_id") val filterId: String
)

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class FinalizeAddThreePidBody(
/**
* Required. The client secret used in the session with the homeserver.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The session identifier given by the homeserver.
*/
@Json(name = "sid")
val sid: String,
/**
* Additional authentication information for the user-interactive authentication API.
*/
@Json(name = "auth")
val auth: Map<String, *>? = null
)

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GetAliasesResponse(
/**
* Required. The server's local aliases on the room. Can be empty.
*/
@Json(name = "aliases") val aliases: List<String> = emptyList()
)

View File

@@ -0,0 +1,88 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.client.utils.JsonDict
/**
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-capabilities
*/
@JsonClass(generateAdapter = true)
data class GetCapabilitiesResult(
/**
* Required. The custom capabilities the server supports, using the Java package naming convention.
*/
@Json(name = "capabilities")
val capabilities: Capabilities? = null
)
@JsonClass(generateAdapter = true)
data class Capabilities(
/**
* Capability to indicate if the user can change their password.
*/
@Json(name = "m.change_password")
val changePassword: ChangePassword? = null,
/**
* This capability describes the default and available room versions a server supports, and at what level of stability.
* Clients should make use of this capability to determine if users need to be encouraged to upgrade their rooms.
*/
@Json(name = "m.room_versions")
val roomVersions: RoomVersions? = null
)
@JsonClass(generateAdapter = true)
data class ChangePassword(
/**
* Required. True if the user can change their password, false otherwise.
*/
@Json(name = "enabled")
val enabled: Boolean?
)
@JsonClass(generateAdapter = true)
data class RoomVersions(
/**
* Required. The default room version the server is using for new rooms.
*/
@Json(name = "default")
val default: String?,
/**
* Required. A detailed description of the room versions the server supports.
*/
@Json(name = "available")
val available: JsonDict? = null,
/**
* "room_capabilities": {
* "knock" : {
* "preferred": "7",
* "support" : ["7"]
* },
* "restricted" : {
* "preferred": "9",
* "support" : ["8", "9"]
* }
* }
*/
@Json(name = "room_capabilities")
val roomCapabilities: JsonDict? = null
)

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GetMediaConfigResult(
/**
* The maximum size an upload can be in bytes. Clients SHOULD use this as a guide when uploading content.
* If not listed or null, the size limit should be treated as unknown.
*/
@Json(name = "m.upload.size")
val maxUploadSize: Long? = null
)

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* All push rulesets for a user.
* Ref: https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-pushrules
*/
@JsonClass(generateAdapter = true)
data class GetPushRulesResponse(
/**
* Global rules, account level applying to all devices
*/
@Json(name = "global")
val global: RuleSet,
/**
* Device specific rules, apply only to current device
*/
@Json(name = "device")
val device: RuleSet? = null
)

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
class GetPushersResponse(
@Json(name = "pushers")
val pushers: List<JsonPusher>? = null
)

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Interface representing an room key action request
* Note: this class cannot be abstract because of [org.matrix.androidsdk.core.JsonUtils.toRoomKeyShare]
*/
interface GossipingToDeviceObject : SendToDeviceObject {
val action: String?
val requestingDeviceId: String?
val requestId: String?
companion object {
const val ACTION_SHARE_REQUEST = "request"
const val ACTION_SHARE_CANCELLATION = "request_cancellation"
}
}
@JsonClass(generateAdapter = true)
data class GossipingDefaultContent(
@Json(name = "action") override val action: String?,
@Json(name = "requesting_device_id") override val requestingDeviceId: String?,
@Json(name = "m.request_id") override val requestId: String? = null
) : GossipingToDeviceObject

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represents a community profile in the server responses.
*/
@JsonClass(generateAdapter = true)
data class GroupProfile(
@Json(name = "short_description") val shortDescription: String? = null,
/**
* Tell whether the group is public.
*/
@Json(name = "is_public") val isPublic: Boolean? = null,
/**
* The URL for the group's avatar. May be nil.
*/
@Json(name = "avatar_url") val avatarUrl: String? = null,
/**
* The group's name.
*/
@Json(name = "name") val name: String? = null,
/**
* The optional HTML formatted string used to described the group.
*/
@Json(name = "long_description") val longDescription: String? = null
)

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupRoom(
@Json(name = "aliases") val aliases: List<String> = emptyList(),
@Json(name = "canonical_alias") val canonicalAlias: String? = null,
@Json(name = "name") val name: String? = null,
@Json(name = "num_joined_members") val numJoinedMembers: Int = 0,
@Json(name = "room_id") val roomId: String,
@Json(name = "topic") val topic: String? = null,
@Json(name = "world_readable") val worldReadable: Boolean = false,
@Json(name = "guest_can_join") val guestCanJoin: Boolean = false,
@Json(name = "avatar_url") val avatarUrl: String? = null
)

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupRooms(
@Json(name = "total_room_count_estimate") val totalRoomCountEstimate: Int? = null,
@Json(name = "chunk") val rooms: List<GroupRoom> = emptyList()
)

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represents the summary of a community in the server response.
*/
@JsonClass(generateAdapter = true)
data class GroupSummaryResponse(
/**
* The group profile.
*/
@Json(name = "profile") val profile: GroupProfile? = null,
/**
* The group users.
*/
@Json(name = "users_section") val usersSection: GroupSummaryUsersSection? = null,
/**
* The current user status.
*/
@Json(name = "user") val user: GroupSummaryUser? = null,
/**
* The rooms linked to the community.
*/
@Json(name = "rooms_section") val roomsSection: GroupSummaryRoomsSection? = null
)

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represents the community rooms in a group summary response.
*/
@JsonClass(generateAdapter = true)
data class GroupSummaryRoomsSection(
@Json(name = "total_room_count_estimate") val totalRoomCountEstimate: Int? = null,
@Json(name = "rooms") val rooms: List<String> = emptyList()
// @TODO: Check the meaning and the usage of these categories. This dictionary is empty FTM.
// public Map<Object, Object> categories;
)

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represents the current user status in a group summary response.
*/
@JsonClass(generateAdapter = true)
data class GroupSummaryUser(
/**
* The current user membership in this community.
*/
@Json(name = "membership") val membership: String? = null,
/**
* Tell whether the user published this community on his profile.
*/
@Json(name = "is_publicised") val isPublicised: Boolean? = null
)

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* This class represents the community members in a group summary response.
*/
@JsonClass(generateAdapter = true)
data class GroupSummaryUsersSection(
@Json(name = "total_user_count_estimate") val totalUserCountEstimate: Int,
@Json(name = "users") val users: List<String> = emptyList()
// @TODO: Check the meaning and the usage of these roles. This dictionary is empty FTM.
// public Map<Object, Object> roles;
)

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupSyncProfile(
/**
* The name of the group, if any. May be nil.
*/
@Json(name = "name") val name: String? = null,
/**
* The URL for the group's avatar. May be nil.
*/
@Json(name = "avatar_url") val avatarUrl: String? = null
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupUser(
@Json(name = "display_name") val displayName: String = "",
@Json(name = "user_id") val userId: String,
@Json(name = "is_privileged") val isPrivileged: Boolean = false,
@Json(name = "avatar_url") val avatarUrl: String? = "",
@Json(name = "is_public") val isPublic: Boolean = false
)

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupUsers(
@Json(name = "total_user_count_estimate") val totalUserCountEstimate: Int,
@Json(name = "chunk") val users: List<GroupUser> = emptyList()
)

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class GroupsSyncResponse(
/**
* Joined groups: An array of groups ids.
*/
@Json(name = "join") val join: Map<String, Any> = emptyMap(),
/**
* Invitations. The groups that the user has been invited to: keys are groups ids.
*/
@Json(name = "invite") val invite: Map<String, InvitedGroupSync> = emptyMap(),
/**
* Left groups. An array of groups ids: the groups that the user has left or been banned from.
*/
@Json(name = "leave") val leave: Map<String, Any> = emptyMap()
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class IdentityAccountResponse(
/**
* Required. The user ID which registered the token.
*/
@Json(name = "user_id")
val userId: String
)

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Ref: https://github.com/matrix-org/matrix-doc/blob/hs/hash-identity/proposals/2134-identity-hash-lookup.md
*/
@JsonClass(generateAdapter = true)
data class IdentityHashDetailResponse(
/**
* Required. The pepper the client MUST use in hashing identifiers, and MUST supply to the /lookup endpoint when performing lookups.
* Servers SHOULD rotate this string often.
*/
@Json(name = "lookup_pepper")
val pepper: String,
/**
* Required. The algorithms the server supports. Must contain at least "sha256".
* "none" can be another possible value.
*/
@Json(name = "algorithms")
val algorithms: List<String>
) {
companion object {
const val ALGORITHM_SHA256 = "sha256"
const val ALGORITHM_NONE = "none"
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Ref: https://github.com/matrix-org/matrix-doc/blob/hs/hash-identity/proposals/2134-identity-hash-lookup.md
*/
@JsonClass(generateAdapter = true)
data class IdentityLookUpParams(
/**
* Required. The addresses to look up. The format of the entries here depend on the algorithm used.
* Note that queries which have been incorrectly hashed or formatted will lead to no matches.
*/
@Json(name = "addresses")
val hashedAddresses: List<String>,
/**
* Required. The algorithm the client is using to encode the addresses. This should be one of the available options from /hash_details.
*/
@Json(name = "algorithm")
val algorithm: String,
/**
* Required. The pepper from /hash_details. This is required even when the algorithm does not make use of it.
*/
@Json(name = "pepper")
val pepper: String
)

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* Ref: https://github.com/matrix-org/matrix-doc/blob/hs/hash-identity/proposals/2134-identity-hash-lookup.md
*/
@JsonClass(generateAdapter = true)
data class IdentityLookUpResponse(
/**
* Required. Any applicable mappings of addresses to Matrix User IDs. Addresses which do not have associations will
* not be included, which can make this property be an empty object.
*/
@Json(name = "mappings")
val mappings: Map<String, String>
)

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class IdentityRegisterResponse(
/**
* Required. An opaque string representing the token to authenticate future requests to the identity server with.
*/
@Json(name = "token")
val token: String
)

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class IdentityRequestOwnershipParams(
/**
* Required. The client secret that was supplied to the requestToken call.
*/
@Json(name = "client_secret")
val clientSecret: String,
/**
* Required. The session ID, generated by the requestToken call.
*/
@Json(name = "sid")
val sid: String,
/**
* Required. The token generated by the requestToken call and sent to the user.
*/
@Json(name = "token")
val token: String
)

View File

@@ -0,0 +1,82 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// Just to consider common parameters
private interface IdentityRequestTokenBody {
/**
* Required. A unique string generated by the client, and used to identify the validation attempt.
* It must be a string consisting of the characters [0-9a-zA-Z.=_-].
* Its length must not exceed 255 characters and it must not be empty.
*/
val clientSecret: String
val sendAttempt: Int
}
@JsonClass(generateAdapter = true)
data class IdentityRequestTokenForEmailBody(
@Json(name = "client_secret")
override val clientSecret: String,
/**
* Required. The server will only send an email if the send_attempt is a number greater than the most
* recent one which it has seen, scoped to that email + client_secret pair. This is to avoid repeatedly
* sending the same email in the case of request retries between the POSTing user and the identity server.
* The client should increment this value if they desire a new email (e.g. a reminder) to be sent.
* If they do not, the server should respond with success but not resend the email.
*/
@Json(name = "send_attempt")
override val sendAttempt: Int,
/**
* Required. The email address to validate.
*/
@Json(name = "email")
val email: String
) : IdentityRequestTokenBody
@JsonClass(generateAdapter = true)
data class IdentityRequestTokenForMsisdnBody(
@Json(name = "client_secret")
override val clientSecret: String,
/**
* Required. The server will only send an SMS if the send_attempt is a number greater than the most recent one
* which it has seen, scoped to that country + phone_number + client_secret triple. This is to avoid repeatedly
* sending the same SMS in the case of request retries between the POSTing user and the identity server.
* The client should increment this value if they desire a new SMS (e.g. a reminder) to be sent.
*/
@Json(name = "send_attempt")
override val sendAttempt: Int,
/**
* Required. The phone number to validate.
*/
@Json(name = "phone_number")
val phoneNumber: String,
/**
* Required. The two-letter uppercase ISO-3166-1 alpha-2 country code that the number in phone_number
* should be parsed as if it were dialled from.
*/
@Json(name = "country")
val countryCode: String
) : IdentityRequestTokenBody

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class IdentityRequestTokenResponse(
/**
* Required. The session ID. Session IDs are opaque strings generated by the identity server.
* They must consist entirely of the characters [0-9a-zA-Z.=_-].
* Their length must not exceed 255 characters and they must not be empty.
*/
@Json(name = "sid")
val sid: String
)

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.client.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* An interactive authentication flow.
*/
@JsonClass(generateAdapter = true)
data class InteractiveAuthenticationFlow(
@Json(name = "type")
val type: String? = null,
@Json(name = "stages")
val stages: List<String>? = null
)

Some files were not shown because too many files have changed in this diff Show More