package es.verdnatura.domain

import com.google.gson.JsonObject
import es.verdnatura.presentation.common.itemBarCodeSalix
import es.verdnatura.presentation.common.itemPackingTypeSalix
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
import es.verdnatura.presentation.view.feature.collection.SalixSaleQuantity
import es.verdnatura.presentation.view.feature.collection.listSaleSalix
import es.verdnatura.presentation.view.feature.collection.saleSalix
import es.verdnatura.presentation.view.feature.historicoshelvinglog.model.ShelvingLogSalix
import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO
import es.verdnatura.presentation.view.feature.login.model.SalixGrupo
import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.workermistake.model.DepartmentMistake
import org.json.JSONObject
import retrofit2.Call
import retrofit2.http.*
import java.net.URLEncoder

interface SalixService {

    @POST("Accounts/login")
    fun login(@Header("Content-Type") content_type: String,
              @Body params: LoginSalixVO):
            Call<LoginSalixVO>

    @POST("chats/sendCheckingPresence")
    fun sendChekingPresence(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Body params: SalixMessageVO):
            Call<Boolean>

    @POST("chats/send")
    fun sendGroup(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Body params: SalixGrupo
    ):
            Call<Boolean>

    @GET("collections/getSectors")
    fun getSectorsSalix(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,

    ):
            Call<List<SectorItemVO>>

    @GET("collections/getCollection")
    fun getCollectionSalix(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
    ):
            Call<List<CollectionVO>>


    @GET("collections/sectorCollection_get")
    fun sectorCollection_get(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
    ):
            Call<List<CollectionVO>>

    @POST("collections/setSaleQuantity")
    fun collectionIncreaseQuantitySalix(
        @Header("aplicacion") aplicacion: String,
        @Header("version") version: String,
        @Header("Authorization") authorization: String,
        @Header("Content-Type") content_type: String,
        @Body params: SalixSaleQuantity
    ):
            Call<Any>


    @POST("tickets/{idTicket}/transferSales") //-->saleMove en Silex
    fun transferSalesSalix(
        @Header("aplicacion") aplicacion: String,
        @Header("version") version: String,
        @Header("Authorization") authorization: String,
        @Header("Content-Type") content_type: String,
        @Path("idTicket") idTicket:String,
        @Body params: listSaleSalix
    ):
            Call<Any>


    //https://test-salix.verdnatura.es/api/Departments?filter={"fields": {"id": true, "name": true},"where": {"name": "COMPRAS"}}
   // http://test-salix.verdnatura.es/api/Departments?filter={"fields": {"id": true, "name": true},"where": {"hasToMistake": "FALSE"}}

  //  @GET("api/Departments?filter={\"fields\": {\"id\": true, \"name\": true},\"where\": {\"hasToMistake\": \"FALSE\"}}")
    @GET("Departments")
    fun department_getHasMistake(
      @Header("Content-Type") content_type: String,
      @Header("Authorization") authorization: String,
      @Query("filter") filter:String = "{\"fields\": {\"id\": true, \"name\": true},\"where\": {\"name\": \"INFORMATICA\"}}"
     // @Query("name") name:String ="COMPRAS"
        ):
            Call<List<DepartmentMistake>>

    @GET("Workers/{idWorker}/sip")
    fun sip_getExtension(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Path("idWorker") idWorker:String

    ):
            Call<Any>

    @PATCH("Items/{itemFk}")
    fun update_ItemPackingType(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Path("itemFk") itemFk:String,
        @Body params: itemPackingTypeSalix
    ):
            Call<Any>

    //Fins que Salix 8.3 no puje no descomentar
    @GET("ItemPackingTypes")
    fun get_ItemPackingType(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,

    ):
            Call<List<ItemPackingType>>




    @PUT("ItemBarCodes")//REVISADA
    fun barcodes_edit(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Body params: itemBarCodeSalix
    ):
            Call<Any>


    @GET("ItemBarCodes/{barCodeValue}/toItem")//REVISADA
    fun barcodes_toitem(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Path("barCodeValue") barCodeValue:String
    ):
            Call<String>

    @GET("Shelvings")
    fun Shelvings(
        @Header("Content-Type") content_type: String,
        @Header("Authorization") authorization: String,
        @Query("filter") filter:String

    ):
            Call<List<ShelvingLogSalix>>
}