package com.iqser.red.service.persistence.service.v1.api.internal.resources;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.iqser.red.service.persistence.service.v1.api.shared.model.FileUploadResult;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;

public interface UploadResource {

    String DOSSIER_ID = "dossierId";
    String FILE_ID = "fileId";
    String UPLOAD_PATH = InternalApi.BASE_PATH + "/upload";
    String DOSSIER_ID_PATH_VARIABLE = "/{" + DOSSIER_ID + "}";
    String FILE_ID_PATH_VARIABLE = "/{" + FILE_ID + "}";
    String DISABLE_AUTOMATIC_ANALYSIS_PARAM = "disableAutomaticAnalysis";


    @ResponseBody
    @PostMapping(value = UPLOAD_PATH + DOSSIER_ID_PATH_VARIABLE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    FileUploadResult upload(@Schema(type = "string", format = "binary", name = "file") @RequestPart(name = "file") MultipartFile file,
                            @PathVariable(DOSSIER_ID) String dossierId,
                            @RequestParam(value = "keepManualRedactions", required = false, defaultValue = "false") boolean keepManualRedactions,
                            @Parameter(name = DISABLE_AUTOMATIC_ANALYSIS_PARAM, description = "Disables automatic analysis for the uploaded file, imports only imported redactions") @RequestParam(value = DISABLE_AUTOMATIC_ANALYSIS_PARAM, required = false, defaultValue = "false") boolean disableAutomaticAnalysis);

}
