package com.storycove.dto;

import java.util.ArrayList;
import java.util.List;

public class ZIPAnalysisResponse {

    private boolean success;
    private String message;
    private String zipFileName;
    private int totalFiles;
    private int validFiles;
    private List<FileInfoDto> files;
    private List<String> warnings;

    public ZIPAnalysisResponse() {
        this.files = new ArrayList<>();
        this.warnings = new ArrayList<>();
    }

    public static ZIPAnalysisResponse success(String zipFileName, List<FileInfoDto> files) {
        ZIPAnalysisResponse response = new ZIPAnalysisResponse();
        response.setSuccess(true);
        response.setMessage("ZIP file analyzed successfully");
        response.setZipFileName(zipFileName);
        response.setFiles(files);
        response.setTotalFiles(files.size());
        response.setValidFiles((int) files.stream().filter(f -> f.getError() == null).count());
        return response;
    }

    public static ZIPAnalysisResponse error(String message) {
        ZIPAnalysisResponse response = new ZIPAnalysisResponse();
        response.setSuccess(false);
        response.setMessage(message);
        return response;
    }

    public void addWarning(String warning) {
        this.warnings.add(warning);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getZipFileName() {
        return zipFileName;
    }

    public void setZipFileName(String zipFileName) {
        this.zipFileName = zipFileName;
    }

    public int getTotalFiles() {
        return totalFiles;
    }

    public void setTotalFiles(int totalFiles) {
        this.totalFiles = totalFiles;
    }

    public int getValidFiles() {
        return validFiles;
    }

    public void setValidFiles(int validFiles) {
        this.validFiles = validFiles;
    }

    public List<FileInfoDto> getFiles() {
        return files;
    }

    public void setFiles(List<FileInfoDto> files) {
        this.files = files;
    }

    public List<String> getWarnings() {
        return warnings;
    }

    public void setWarnings(List<String> warnings) {
        this.warnings = warnings;
    }
}
