package com.kaixed.kchat.network.service

import com.kaixed.kchat.data.objectbox.entity.Contact
import com.kaixed.kchat.model.friend.FriendRequestItem
import com.kaixed.kchat.model.search.User
import com.kaixed.kchat.network.ApiResponse
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

interface ContactService {

    // 获取联系人请求列表
    @FormUrlEncoded
    @POST("friend/request/list")
    suspend fun getContactRequestList(
        @Field("userId") username: String
    ): ApiResponse<List<FriendRequestItem>?>

    // 接受联系人请求
    @FormUrlEncoded
    @POST("friend/accept")
    suspend fun acceptContactRequest(
        @Field("requestId") contactId: String,
        @Field("receiverId") username: String,
        @Field("remark") remark: String
    ): ApiResponse<Contact?>

    // 添加联系人
    @FormUrlEncoded
    @POST("friend/request")
    suspend fun addContact(
        @Field("senderId") senderId: String,
        @Field("receiverId") receiverId: String,
        @Field("message") message: String
    ): ApiResponse<String>

    // 搜索联系人
    @GET("users/{username}")
    suspend fun searchContact(
        @Path("username") username: String
    ): ApiResponse<User?>

    // 获取联系人列表
    @FormUrlEncoded
    @POST("friend/list")
    suspend fun getContactList(
        @Field("userId") username: String
    ): ApiResponse<List<Contact>?>

    // 删除联系人
    @FormUrlEncoded
    @POST("friend/delete")
    suspend fun deleteContact(
        @Field("userId") username: String,
        @Field("contactId") contactId: String,
    ): ApiResponse<String?>
}
