package com.example.ops_android.data.remote.api

import com.example.ops_android.data.model.Cookie
import com.example.ops_android.data.model.UserDetail
import com.example.ops_android.data.model.UserInfo
import com.example.ops_android.data.remote.ApiResponse
import retrofit2.http.Body
import retrofit2.http.POST

data class LoginRequest(
    val username: String,
    val password: String,
    val remember: Boolean = true
)

data class LoginResponse(
    val cookie: Cookie?
)

data class RegisterRequest(
    val username: String,
    val useremail: String,
    val userpass: String
)

data class ChangePasswordRequest(
    val oldpass: String,
    val newpass: String
)

data class ChangeEmailRequest(
    val newemail: String
)

data class UpdateInfoRequest(
    val username: String? = null,
    val remark: String? = null,
    val birthday: String? = null
)

data class UserInfoResponse(
    val user: UserInfo?,
    val userInfo: UserDetail?
)

class EmptyBody

interface UserApi {

    @POST("/users/login")
    suspend fun login(@Body request: LoginRequest): ApiResponse<LoginResponse>

    @POST("/users/register")
    suspend fun register(@Body request: RegisterRequest): ApiResponse<Any>

    @POST("/users/getinfo")
    suspend fun getUserInfo(@Body request: EmptyBody = EmptyBody()): ApiResponse<UserInfoResponse>

    @POST("/users/changePassword")
    suspend fun changePassword(@Body request: ChangePasswordRequest): ApiResponse<Any>

    @POST("/users/changeEmail")
    suspend fun changeEmail(@Body request: ChangeEmailRequest): ApiResponse<Any>

    @POST("/users/updateInfo")
    suspend fun updateInfo(@Body request: UpdateInfoRequest): ApiResponse<Any>
}
