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.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.iqser.red.service.persistence.service.v1.api.shared.model.WatermarkModel;
import com.iqser.red.service.persistence.service.v1.api.shared.model.common.JSONPrimitive;

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

@ResponseStatus(value = HttpStatus.OK)
public interface WatermarkResource {

    String WATERMARK_PATH = ExternalApi.BASE_PATH + "/watermark";
    String CHECK_USED_REST_PATH = "/used";
    String WATERMARK_ID_PARAMETER_NAME = "watermarkId";
    String WATERMARK_ID_PATH_VARIABLE = "/{" + WATERMARK_ID_PARAMETER_NAME + "}";
    String DOSSIER_TEMPLATE_ID_PARAMETER_NAME = "dossierTemplateId";


    @Operation(summary = "Save/Update watermark configuration", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid Watermark Data."), @ApiResponse(responseCode = "403", description = "Forbidden.")})
    @ResponseStatus(HttpStatus.OK)
    @PostMapping(value = WATERMARK_PATH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    WatermarkModel saveWatermark(@RequestBody WatermarkModel watermark);


    @Operation(summary = "Get a specific watermark configuration", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "403", description = "Forbidden.")})

    @GetMapping(value = WATERMARK_PATH + WATERMARK_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    WatermarkModel getWatermark(@PathVariable(WATERMARK_ID_PARAMETER_NAME) long watermarkId);


    @Operation(summary = "Get watermarks for a dossierTemplateId", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "403", description = "Forbidden.")})
    @GetMapping(value = WATERMARK_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
    List<WatermarkModel> getWatermarksForDossierTemplateId(@RequestParam(DOSSIER_TEMPLATE_ID_PARAMETER_NAME) String dossierTemplateId);


    @Operation(summary = "Remove watermark configuration", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK"), @ApiResponse(responseCode = "403", description = "Forbidden.")})

    @ResponseStatus(HttpStatus.NO_CONTENT)
    @DeleteMapping(value = WATERMARK_PATH + WATERMARK_ID_PATH_VARIABLE)
    void deleteWatermark(@PathVariable(WATERMARK_ID_PARAMETER_NAME) long watermarkId);


    @Operation(summary = "Check if a specific watermark configuration is in use", description = "None")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "403", description = "Forbidden.")})

    @GetMapping(value = WATERMARK_PATH + CHECK_USED_REST_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
    JSONPrimitive<Boolean> isWatermarkUsed(@RequestParam(WATERMARK_ID_PARAMETER_NAME) long watermarkId);

}
