package com.example.petstoremobile.api;

import com.example.petstoremobile.dtos.DropdownDTO;
import com.example.petstoremobile.dtos.PageResponse;
import com.example.petstoremobile.dtos.ProductDTO;
import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.*;

import java.util.List;

public interface ProductApi {
    String PRODUCT_IMAGE_PATH = "api/v1/products/%d/image";

    @GET("api/v1/products")
    Call<PageResponse<ProductDTO>> getAllProducts(
            @Query("q") String query,
            @Query("categoryId") Long categoryId,
            @Query("page") int page,
            @Query("size") int size,
            @Query("sort") String sort);

    @GET("api/v1/products/{id}")
    Call<ProductDTO> getProductById(@Path("id") Long id);

    @POST("api/v1/products")
    Call<ProductDTO> createProduct(@Body ProductDTO product);

    @PUT("api/v1/products/{id}")
    Call<ProductDTO> updateProduct(@Path("id") Long id, @Body ProductDTO product);

    @DELETE("api/v1/products/{id}")
    Call<Void> deleteProduct(@Path("id") Long id);

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

    @DELETE("api/v1/products/{id}/image")
    Call<Void> deleteProductImage(@Path("id") Long id);

    @GET("api/v1/dropdowns/products")
    Call<List<DropdownDTO>> getProductDropdowns();

    @GET("api/v1/dropdowns/categories")
    Call<List<DropdownDTO>> getCategoryDropdowns();
}