package com.syaroful.agrilinkvocpro.control_feature.data.network

import com.syaroful.agrilinkvocpro.control_feature.data.model.ActuatorHistoryResponse
import com.syaroful.agrilinkvocpro.control_feature.data.model.ActuatorStatusResponse
import com.syaroful.agrilinkvocpro.control_feature.data.model.ControlLogResponse
import okhttp3.RequestBody
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

interface ControlService {
    // get all actuator status
    @GET("api/actuators/status")
    suspend fun getActuatorStatus(
        @Header("Authorization") authHeader: String,
    ): Response<ActuatorStatusResponse>

    // push control water valve
    @Multipart
    @POST("api/actuators/water-valve/control")
    suspend fun controlWaterValve(
        @Header("Authorization") authHeader: String,
        @Part("action") action: RequestBody
    ): Response<ControlLogResponse>

    // push control nutrient valve
    @Multipart
    @POST("api/actuators/nutrient-valve/control")
    suspend fun controlNutrientValve(
        @Header("Authorization") authHeader: String,
        @Part("action") action: RequestBody
    ): Response<ControlLogResponse>

    // push control pump
    @Multipart
    @POST("api/actuators/pump/control")
    suspend fun controlPump(
        @Header("Authorization") authHeader: String,
        @Part("action") action: RequestBody
    ): Response<ControlLogResponse>

    // get controls log
    @GET("api//actuator-control-logs")
    suspend fun getActuatorsControlLog(
        @Header("Authorization") authHeader: String,
    ): Response<ActuatorHistoryResponse>
}