package app.mealsmadeeasy.api.image;

import app.mealsmadeeasy.api.image.spec.ImageCreateSpec;
import app.mealsmadeeasy.api.image.spec.ImageUpdateSpec;
import app.mealsmadeeasy.api.user.User;
import org.jetbrains.annotations.Nullable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public interface ImageService {

    Image create(User owner, String userFilename, InputStream inputStream, long objectSize, ImageCreateSpec infoSpec)
            throws IOException, ImageException;

    Image getById(Integer id, @Nullable User viewer);
    Image getByOwnerAndFilename(User owner, String filename, User viewer);
    Image getByUsernameAndFilename(String username, String filename, User viewer);

    InputStream getImageContent(Image image, @Nullable User viewer) throws IOException;
    List<Image> getImagesOwnedBy(User user);
    Slice<Image> getOwnedImages(User user, Pageable pageable);
    int countOwnedImages(User user);

    boolean exists(User viewer, String username, String filename);

    Image update(Image image, User modifier, ImageUpdateSpec spec);

    void deleteImage(Image image, User modifier) throws IOException;

}
