package com.example.petstoremobile.api;

import com.example.petstoremobile.dtos.BulkDeleteRequest;
import com.example.petstoremobile.dtos.DropdownDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.PetDTO;

import java.util.List;

import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;

//api calls to CRUD pets
public interface PetApi {
    // endpoint for downloading the pet's image file
    String PET_IMAGE_PATH = "api/v1/pets/%d/image";

    // Get all pets with filters
    @GET("api/v1/pets")
    Call<PageResponse<PetDTO>> getAllPets(
            @Query("page") int page,
            @Query("size") int size,
            @Query("q") String query,
            @Query("status") String status,
            @Query("species") String species,
            @Query("storeId") Long storeId,
            @Query("customerId") Long customerId,
            @Query("sort") String sort
    );

    @GET("api/v1/dropdowns/customers/{customerId}/pets")
    Call<List<DropdownDTO>> getCustomerPets(@Path("customerId") Long customerId);

    @GET("api/v1/dropdowns/adoption-pets")
    Call<List<DropdownDTO>> getAdoptionPets(@Query("storeId") Long storeId);

    @GET("api/v1/dropdowns/pets")
    Call<List<DropdownDTO>> getPetDropdowns();

    @GET("api/v1/dropdowns/pet-species")
    Call<List<DropdownDTO>> getPetSpeciesDropdowns();

    @GET("api/v1/dropdowns/pet-breeds")
    Call<List<DropdownDTO>> getPetBreedsDropdowns(@Query("species") String species);

    // Get pet by id
    @GET("api/v1/pets/{id}")
    Call<PetDTO> getPetById(@Path("id") Long id);

    // Create pet
    @POST("api/v1/pets")
    Call<PetDTO> createPet(@Body PetDTO pet);

    // Update pet
    @PUT("api/v1/pets/{id}")
    Call<PetDTO> updatePet(@Path("id") Long id, @Body PetDTO pet);

    // Delete pet
    @DELETE("api/v1/pets/{id}")
    Call<Void> deletePet(@Path("id") Long id);

    // Bulk delete pets
    @HTTP(method = "DELETE", path = "api/v1/pets", hasBody = true)
    Call<Void> bulkDeletePets(@Body BulkDeleteRequest request);

    // Upload pet image
    @Multipart
    @POST("api/v1/pets/{id}/image")
    Call<Void> uploadPetImage(@Path("id") Long id, @Part MultipartBody.Part image);

    // Delete pet image
    @DELETE("api/v1/pets/{id}/image")
    Call<Void> deletePetImage(@Path("id") Long id);

}
