package com.develop.food.base.api

import androidx.lifecycle.LiveData
import com.develop.food.base.api.response.*
import com.develop.food.base.common.CURRENT_LANGUAGE
import com.develop.food.base.http.ApiResponse
import com.develop.food.base.http.BaseRequest
import com.develop.food.base.http.HttpFactory
import com.develop.food.base.utils.MmkvUtils
import com.develop.food.base.utils.getSN
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

interface FoodApiService {
    companion object {
        fun get(): FoodApiService {
            return BaseRequest.get(
                FoodApiService::class.java,
                HttpFactory("http://nat.kuyuntech.com:19973/dev/", FoodInterceptor())
//                HttpFactory("http://192.168.1.20:9973/dev/", FoodInterceptor())
            )
        }

        fun clear() {
            BaseRequest.clearMap()
        }
    }


    @POST("register")
    fun register(@Body registerBody: RequestBody): LiveData<ApiResponse<BaseResult<RegisterResult>>>

    @POST("login")
    fun login(@Body loginBody: RequestBody): LiveData<ApiResponse<BaseResult<LoginResult>>>

    @POST("perfetInfo")
    fun perfectInfo(@Body perfectInfoBody: RequestBody): LiveData<ApiResponse<BaseResult<PerfectInfoResult>>>

    @POST("sendVerifyCode")
    fun sendVerifyCode(@Body sendVerifyCodeBody: RequestBody): LiveData<ApiResponse<BaseResult<VerifyCodeResult>>>

    @POST("updatePassword")
    fun updatePassword(@Body updatePassWordBody: RequestBody): LiveData<ApiResponse<BaseResult<Any>>>

    @POST("score")
    fun score(@Body scoreBody: RequestBody): LiveData<ApiResponse<BaseResult<ScoreResult>>>

    @GET("recipes")
    fun recipesList(
        @Query("category") category: String,
        @Query("name") name: String,
        @Query("sn") sn: String = getSN(), @Query("lang") lang: String = MmkvUtils.getString(
            CURRENT_LANGUAGE
        ) ?: "EN",
        @Query("pageIndex") pageIndex: Int = 1,
        @Query("pageSize") pageSize: Int = 10
    ): LiveData<ApiResponse<BaseResult<RecipesListResult>>>

    @GET("recipeDetail")
    fun recipeDetail(
        @Query("recipeNumber") recipeNumber: String,
        @Query("recipeEditon") recipeEdition: String,
        @Query("lang") lang: String = MmkvUtils.getString(
            CURRENT_LANGUAGE
        ) ?: "EN"
    ): LiveData<ApiResponse<BaseResult<RecipeDetailResult>>>

    @GET("categorys")
    fun getCategoryList(
        @Query("sn") sn: String = getSN(), @Query("lang") lang: String = MmkvUtils.getString(
            CURRENT_LANGUAGE
        ) ?: "EN"
    ): LiveData<ApiResponse<BaseResult<CategoryListResult>>>

    @POST("active")
    fun active(@Body activeBody: RequestBody): LiveData<ApiResponse<BaseResult<Any>>>


    @POST("devInfo")
    fun deviceInfo(@Body devInfoBody: RequestBody): LiveData<ApiResponse<BaseResult<DevInfoResult>>>

    @GET("notices")
    fun getNotices(
        @Query("lang") lang: String = MmkvUtils.getString(CURRENT_LANGUAGE) ?: "EN",
    ): LiveData<ApiResponse<BaseResult<NoticeResult>>>

    @GET("hotTags")
    fun hotTags(
        @Query("sn") sn: String = getSN(), @Query("lang") lang: String = MmkvUtils.getString(
            CURRENT_LANGUAGE
        ) ?: "EN"
    ): LiveData<ApiResponse<BaseResult<HotTagsResult>>>
}