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;

// api calls for products
public interface ProductApi {
    // endpoint for downloading the product's image file
    String PRODUCT_IMAGE_PATH = "api/v1/products/%d/image";

    // Get all products with filters
    @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 product by id
    @GET("api/v1/products/{id}")
    Call<ProductDTO> getProductById(@Path("id") Long id);

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

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

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

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

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

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

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