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.DeleteMapping;
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.RequestParam;
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.DossierAttributes;
import com.iqser.red.service.persistence.service.v1.api.shared.model.DossierAttributesConfig;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.DossierAttributeConfig;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.DossierAttribute;

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 DossierAttributesResource {

    String DOSSIER_ATTRIBUTES_PATH = ExternalApi.BASE_PATH + "/dossier-attributes";
    String CONFIG_PATH = "/config";
    String SET_PATH = "/set";
    String UPDATE_PATH = "/update";

    String DOSSIER_TEMPLATE_ID = "dossierTemplateId";
    String DOSSIER_TEMPLATE_ID_PATH_VARIABLE = "/{" + DOSSIER_TEMPLATE_ID + "}";

    String DOSSIER_ATTRIBUTE_ID = "dossierAttributeId";
    String DOSSIER_ATTRIBUTE_IDS = "dossierAttributeIds";
    String DOSSIER_ATTRIBUTE_ID_PATH = "/{" + DOSSIER_ATTRIBUTE_ID + "}";

    String DELETE_PATH = "/delete";

    String DOSSIER_ID = "dossierId";
    String DOSSIER_ID_PATH_VARIABLE = "/{" + DOSSIER_ID + "}";


    @ResponseBody
    @ResponseStatus(HttpStatus.OK)
    @Operation(summary = "Set dossier attributes base configuration.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})

    @PutMapping(value = DOSSIER_ATTRIBUTES_PATH + CONFIG_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributesConfig setDossierAttributesConfig(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @RequestBody DossierAttributesConfig dossierAttributesConfig);


    @ResponseBody
    @ResponseStatus(HttpStatus.OK)
    @Operation(summary = "Add or update a dossier attribute in base configuration.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
    @PostMapping(value = DOSSIER_ATTRIBUTES_PATH + CONFIG_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributeConfig addOrUpdateDossierAttributeConfig(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @RequestBody DossierAttributeConfig dossierAttributes);


    @ResponseBody
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @Operation(summary = "Delete a specific dossier attribute.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "NO_CONTENT")})
    @DeleteMapping(value = DOSSIER_ATTRIBUTES_PATH + CONFIG_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + DOSSIER_ATTRIBUTE_ID_PATH)
    void deleteDossierAttributeConfig(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @PathVariable(DOSSIER_ATTRIBUTE_ID) String dossierAttributeId);


    @ResponseBody
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @Operation(summary = "Bulk delete dossier attributes.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "NO_CONTENT")})
    @PostMapping(value = DOSSIER_ATTRIBUTES_PATH + CONFIG_PATH + DELETE_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE)
    void deleteDossierAttributesConfig(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @RequestParam(DOSSIER_ATTRIBUTE_IDS) List<String> dossierAttributeIds);


    @ResponseStatus(HttpStatus.OK)
    @Operation(summary = "Get the dossier attributes configuration.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})

    @GetMapping(value = DOSSIER_ATTRIBUTES_PATH + CONFIG_PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributesConfig getDossierAttributesConfig(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId);


    @Operation(summary = "Set dossier attributes to an existing dossier", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})

    @PostMapping(value = DOSSIER_ATTRIBUTES_PATH + SET_PATH + DOSSIER_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributes setDossierAttributes(@PathVariable(DOSSIER_ID) String dossierId, @RequestBody DossierAttributes dossierAttributes);


    @ResponseBody
    @ResponseStatus(HttpStatus.OK)
    @Operation(summary = "Add or update a dossier attribute in existing dossier.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})

    @PostMapping(value = DOSSIER_ATTRIBUTES_PATH + UPDATE_PATH + DOSSIER_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributes addOrUpdateDossierAttribute(@PathVariable(DOSSIER_ID) String dossierId, @RequestBody DossierAttribute dossierAttribute);


    @ResponseStatus(HttpStatus.OK)
    @Operation(summary = "Get the dossier attributes.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})

    @GetMapping(value = DOSSIER_ATTRIBUTES_PATH + DOSSIER_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    DossierAttributes getDossierAttributes(@PathVariable(DOSSIER_ID) String dossierId);


    @ResponseBody
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @Operation(summary = "Delete a specific dossier attribute.", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "NO_CONTENT")})

    @DeleteMapping(value = DOSSIER_ATTRIBUTES_PATH + SET_PATH + DOSSIER_ID_PATH_VARIABLE + DOSSIER_ATTRIBUTE_ID_PATH)
    void deleteDossierAttribute(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(DOSSIER_ATTRIBUTE_ID) String dossierAttributeId);

}
