package es.verdnatura.domain

import android.content.Context
import es.verdnatura.presentation.view.feature.ajustes.model.Printers
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.login.model.*
import retrofit2.Call

class GetLoginUserCase(context: Context) : RestClient(context)
{

    fun device_checkLogin(
        usuario: String,
        password: String,
        android_id: String
                         ): Call<LoginDevice>
    {
        val params: ArrayList<String> = ArrayList()
        params.add(usuario)
        params.add(android_id)
        return restClient!!.device_checkLogin(
            "json",
            "1",
            usuario,
            password,
            "application/json",
            params
                                             )
    }

    fun worker_getId(usuario: String, password: String): Call<String>
    {
        val params: ArrayList<String> = ArrayList()
        return restClient!!.worker_getId("json", "1", usuario, password, "application/json", params)
    }

    fun deviceLog_add(
        usuario: String,
        password: String,
        app: String,
        versionApp: String,
        android_id: String
                     ): Call<Void>
    {
        val params: ArrayList<String> = ArrayList()
        params.add(app)
        params.add(versionApp)
        params.add(android_id)
        return restClient!!.deviceLog_add(
            "json",
            "1",
            usuario,
            password,
            "application/json",
            params
                                         )
    }

    fun salixLogin(usuario: String, password: String): Call<LoginSalixVO>
    {
        return salixClient!!.login("application/json", LoginSalixVO(usuario, password))
    }
    //NODEJS TEST

    /*fun nodeJsTest(
        smarttag: String,
        wagon: String,
        shelving: String
                  ): Call<NodeJsService.SmartTagNode>
    {
        //https://smart-tag.verdnatura.es/bindShelving/A0A3B8224DBF&ABC&1
        return nodejsClient!!.bindShelving("application/json", "A0A3B8224DBF", "AAA", "1")
        // return nodejsClient!!.bindShelving("application/json", NodeJsService.SmartTagNode(smarttag, wagon, shelving),"A0A3B8224DBF","ABC","2")

    }*/
    // SALIX SERGIO MENSAJE : PARA NO ENVIAR MENSAJES A COMERCIALES PONGO QUE LAS MODIFICACIONES SE ENVIAN AL CANAL CREADO.
    // SE CAMBIA VARIABLE A TRUE/FALSE


fun sendChekingPresence(token:String,workerId:Int,message:String) : Call<Boolean>{

    var working_in_test=false // Enviar a grupo test Android o a los usuarios
    if (!working_in_test) {

        return salixClient!!.sendChekingPresence(
            content_type = "application/json",
            authorization = token,
            params = SalixMessageVO(workerId = workerId, message = message)
        )
    }else{

       return salixClient!!.sendGroup(
            content_type = "application/json",
            authorization = token,
            params = SalixGrupo(to = "#android-test", message = message))
    }
    }


 /*fun sendChekingPresence(token: String, workerId: Int, message: String): Call<Boolean>
{
   return salixClient!!.sendGroup(
       content_type = "application/json",
       authorization = token,
       params = SalixGrupo(to = "#android-test", message = message)
                                 )
}*/

fun checkVersion(usuario: String, password: String, nameApp: String): Call<versionApp>
{
val params: ArrayList<String> = ArrayList()
params.add(nameApp)
return restClient!!.getVersion("json", "1", usuario, password, "application/json", params)
}
    fun worker_getSector(usuario: String, password: String): Call<SectorItemVO> {


        return restClient!!.worker_getSector("json", "1", usuario, password, "application/json")
    }

    fun operator_getNumberOfWagons(usuario: String, password: String): Call<Int?> {

        return restClient!!.operator_getNumberOfWagons("json", "1", usuario, password, "application/json")
    }

    fun operator_add(usuario: String, password: String): Call<Any> {

        return restClient!!.operator_add("json", "1", usuario, password, "application/json")
    }

    fun worker_getPrinter(usuario: String, password: String): Call<List<Printers>> {

        return restClient!!.worker_getPrinter("json", "1", usuario, password, "application/json")
    }
}