auth to server-V74
This commit is contained in:
parent
b1d892f8f4
commit
e32f6332be
3 changed files with 21 additions and 0 deletions
|
|
@ -65,4 +65,11 @@ interface TecnologiaApi {
|
|||
suspend fun rejectFriendRequest(
|
||||
@Path("fromUserId") fromUserId: String
|
||||
): Response<Unit>
|
||||
|
||||
// add friends
|
||||
@POST("api/friends/request")
|
||||
suspend fun sendFriendRequest(
|
||||
@Body request: AddFriendRequest
|
||||
): Response<Unit>
|
||||
|
||||
}
|
||||
|
|
@ -65,6 +65,10 @@ data class PendingFriendApiModel(
|
|||
@Json(name = "created_at")
|
||||
val createdAt: String?
|
||||
)
|
||||
//add friends
|
||||
data class AddFriendRequest(
|
||||
@Json(name = "friend_id") val friendId: String
|
||||
)
|
||||
|
||||
val PendingFriendApiModel.fullPendingAvatarUrl: Any
|
||||
get() = if (pendingAvatarUrl.isNullOrBlank()) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.example.login_v3.data.repository.basic
|
||||
|
||||
import com.example.login_v3.data.api.TecnologiaApi
|
||||
import com.example.login_v3.data.api.api_class.AddFriendRequest
|
||||
import com.example.login_v3.data.api.api_class.Friend
|
||||
import com.example.login_v3.data.api.api_class.PendingFriendApiModel
|
||||
import retrofit2.Response
|
||||
|
|
@ -54,4 +55,13 @@ class FriendsRepository @Inject constructor(
|
|||
Result.failure(e)
|
||||
}
|
||||
}
|
||||
//add friends
|
||||
suspend fun sendFriendRequest(friendId: String): Result<Unit> {
|
||||
return safeApiCall {
|
||||
// 確保這裡的參數名稱與 Data Class 定義的一模一樣
|
||||
val request = AddFriendRequest(friendId = friendId)
|
||||
apiService.sendFriendRequest(request)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue