package kr.co.vividnext.sodalive.user

import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.explorer.profile.MemberBlockRequest
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailUser
import kr.co.vividnext.sodalive.main.GaidUpdateRequest
import kr.co.vividnext.sodalive.main.PushTokenUpdateRequest
import kr.co.vividnext.sodalive.mypage.MyPageResponse
import kr.co.vividnext.sodalive.mypage.block.GetBlockedMemberListResponse
import kr.co.vividnext.sodalive.mypage.profile.ProfileResponse
import kr.co.vividnext.sodalive.mypage.profile.ProfileUpdateRequest
import kr.co.vividnext.sodalive.mypage.profile.nickname.GetChangeNicknamePriceResponse
import kr.co.vividnext.sodalive.settings.notification.GetMemberInfoResponse
import kr.co.vividnext.sodalive.settings.notification.UpdateNotificationSettingRequest
import kr.co.vividnext.sodalive.settings.signout.SignOutRequest
import kr.co.vividnext.sodalive.user.find_password.ForgotPasswordRequest
import kr.co.vividnext.sodalive.user.login.LoginRequest
import kr.co.vividnext.sodalive.user.login.LoginResponse
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface UserApi {
    @POST("/member/login")
    fun login(@Body request: LoginRequest): Single<ApiResponse<LoginResponse>>

    @POST("/member/signup")
    @Multipart
    fun signUp(
        @Part profileImage: MultipartBody.Part?,
        @Part("request") request: RequestBody
    ): Single<ApiResponse<LoginResponse>>

    @POST("/member/forgot-password")
    fun findPassword(@Body request: ForgotPasswordRequest): Single<ApiResponse<Any>>

    @GET("/member/info")
    fun getMemberInfo(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetMemberInfoResponse>>

    @POST("/member/notification")
    fun updateNotificationSettings(
        @Body request: UpdateNotificationSettingRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/member/push-token/update")
    fun updatePushToken(
        @Body request: PushTokenUpdateRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/member/mypage")
    fun getMyPage(
        @Query("container") container: String = "aos",
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<MyPageResponse>>

    @POST("/member/block")
    fun memberBlock(
        @Body request: MemberBlockRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/member/unblock")
    fun memberUnBlock(
        @Body request: MemberBlockRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/member/creator/follow")
    fun creatorFollow(
        @Body request: CreatorFollowRequestRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/member/creator/unfollow")
    fun creatorUnFollow(
        @Body request: CreatorFollowRequestRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/member/search")
    fun searchUser(
        @Query("nickname") nickname: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetRoomDetailUser>>>

    @POST("/member/sign_out")
    fun signOut(
        @Body request: SignOutRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/member/logout")
    fun logout(@Header("Authorization") authHeader: String): Single<ApiResponse<Any>>

    @POST("/member/logout/all")
    fun logoutAll(@Header("Authorization") authHeader: String): Single<ApiResponse<Any>>

    @GET("/member/change/nickname/price")
    fun getChangeNicknamePrice(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetChangeNicknamePriceResponse>>

    @GET("/member/check/nickname")
    fun checkNickname(@Query("nickname") nickname: String): Single<ApiResponse<Any>>

    @PUT("/member/change/nickname")
    fun changeNickname(
        @Body request: ProfileUpdateRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/member")
    fun getMyProfile(
        @Query("container") container: String = "aos",
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<ProfileResponse>>

    @PUT("/member")
    fun updateProfile(
        @Body request: ProfileUpdateRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<ProfileResponse>>

    @Multipart
    @POST("/member/image")
    fun updateProfileImage(
        @Part multipartFile: MultipartBody.Part,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<String>>

    @PUT("/member/adid/update")
    fun updateGaid(
        @Body request: GaidUpdateRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/member/block")
    fun getBlockedMemberList(
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetBlockedMemberListResponse>>

    @GET("/member/block/id")
    fun getBlockedMemberIdList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<Long>>>

    @GET("/member/profile/{id}")
    fun getMemberProfile(
        @Path("id") id: Long,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetMemberProfileResponse>>
}
