ProfileAPI.kt 4.28 KB
Newer Older
1
/*
2
 * Copyright 2020 The Matrix.org Foundation C.I.C.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 *
 * 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.
 *
 */

Benoît Marty's avatar
Benoît Marty committed
18
package org.matrix.android.sdk.internal.session.profile
19

Benoît Marty's avatar
Benoît Marty committed
20
import org.matrix.android.sdk.api.util.JsonDict
Benoit Marty's avatar
Benoit Marty committed
21
22
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
Benoît Marty's avatar
Benoît Marty committed
23
import org.matrix.android.sdk.internal.network.NetworkConstants
Benoît Marty's avatar
Benoît Marty committed
24
import retrofit2.http.Body
25
import retrofit2.http.GET
Benoît Marty's avatar
Benoît Marty committed
26
import retrofit2.http.POST
27
import retrofit2.http.PUT
28
import retrofit2.http.Path
Benoit Marty's avatar
Benoit Marty committed
29
import retrofit2.http.Url
30

Benoît Marty's avatar
Benoît Marty committed
31
internal interface ProfileAPI {
32
    /**
ganfra's avatar
ganfra committed
33
34
35
     * 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.
Onuray Sahin's avatar
Onuray Sahin committed
36
     * If server is configured as limit_profile_requests_to_users_who_share_rooms: true then response can be HTTP 403.
37
38
39
     * @param userId the user id to fetch profile info
     */
    @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}")
40
    suspend fun getProfile(@Path("userId") userId: String): JsonDict
41
42
43
44
45

    /**
     * List all 3PIDs linked to the Matrix user account.
     */
    @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "account/3pid")
46
    suspend fun getThreePIDs(): AccountThreePidsResponse
Benoît Marty's avatar
Benoît Marty committed
47

48
49
50
51
    /**
     * Change user display name
     */
    @PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/displayname")
52
53
    suspend fun setDisplayName(@Path("userId") userId: String,
                               @Body body: SetDisplayNameBody)
54

55
56
57
58
    /**
     * Change user avatar url.
     */
    @PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "profile/{userId}/avatar_url")
59
60
    suspend fun setAvatarUrl(@Path("userId") userId: String,
                             @Body body: SetAvatarUrlBody)
61

Benoît Marty's avatar
Benoît Marty committed
62
63
64
65
66
    /**
     * 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")
67
    suspend fun bindThreePid(@Body body: BindThreePidBody)
Benoît Marty's avatar
Benoît Marty committed
68
69
70
71
72
73

    /**
     * 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")
74
    suspend fun unbindThreePid(@Body body: UnbindThreePidBody): UnbindThreePidResponse
75
76
77
78
79

    /**
     * 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")
80
    suspend fun addEmail(@Body body: AddEmailBody): AddEmailResponse
Benoit Marty's avatar
Benoit Marty committed
81
82
83
84
85

    /**
     * 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")
86
    suspend fun addMsisdn(@Body body: AddMsisdnBody): AddMsisdnResponse
87

Benoit Marty's avatar
Benoit Marty committed
88
89
90
91
    /**
     * Validate Msisdn code (same model than for Identity server API)
     */
    @POST
92
93
    suspend fun validateMsisdn(@Url url: String,
                               @Body params: ValidationCodeBody): SuccessResult
Benoit Marty's avatar
Benoit Marty committed
94

95
96
97
98
    /**
     * 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")
99
    suspend fun finalizeAddThreePid(@Body body: FinalizeAddThreePidBody)
100
101
102
103
104

    /**
     * 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")
105
    suspend fun deleteThreePid(@Body body: DeleteThreePidBody): DeleteThreePidResponse
106
}