package com.iqser.red.service.persistence.service.v1.api.external.resource;

import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.legalbasis.LegalBasis;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;

public interface LegalBasisMappingResource {

    String LEGAL_BASIS_PATH = ExternalApi.BASE_PATH + "/legalBasis";
    String DELETE_PATH = "/delete";
    String DOSSIER_TEMPLATE_PARAMETER_NAME = "dossierTemplateId";
    String DOSSIER_TEMPLATE_PATH_VARIABLE = "/{dossierTemplateId}";


    @ResponseStatus(HttpStatus.NO_CONTENT)
    @PostMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + DELETE_PATH, consumes = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "delete some legal basis by their names.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")})
    void deleteLegalBasis(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody List<String> legalBasisNames);


    @ResponseStatus(HttpStatus.NO_CONTENT)
    @PutMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "Add or update one legalBasis.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")})
    void addOrUpdateLegalBasis(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody LegalBasis legalBasis);


    @ResponseStatus(HttpStatus.NO_CONTENT)
    @PostMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "Set the mapping between legal basis and redaction reason.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK")})
    void setLegalBasisMapping(@RequestBody List<LegalBasis> legalBasisMapping, @PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);


    @ResponseBody
    @ResponseStatus(value = HttpStatus.OK)
    @GetMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "Set the mapping between legal basis and redaction reason.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
    List<LegalBasis> getLegalBasisMapping(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);

}
