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

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.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.dossiertemplate.configuration.Colors;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;

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

    String DICTIONARY_PATH = "/dictionary";
    String TYPE_PATH = DICTIONARY_PATH + "/type";

    String TYPE_PARAMETER_NAME = "type";
    String TYPE_PATH_VARIABLE = "/{" + TYPE_PARAMETER_NAME + "}";

    String INCLUDE_DELETED_PARAMETER_NAME = "includeDeleted";
    String DOSSIER_TEMPLATE_PARAMETER_NAME = "dossierTemplateId";
    String DOSSIER_TEMPLATE_PATH_VARIABLE = "/{" + DOSSIER_TEMPLATE_PARAMETER_NAME + "}";

    String DOSSIER_ID_PARAMETER_NAME = "dossierId";
    String DOSSIER_PATH = "/dossier";
    String DOSSIER_ID_PATH_VARIABLE = "/{" + DOSSIER_ID_PARAMETER_NAME + "}";

    String FROM_VERSION_PARAM = "fromVersion";

    String COLOR_PATH = "/color";
    String VERSION_PATH = "/version";


    @GetMapping(value = InternalApi.BASE_PATH+TYPE_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    List<Type> getAllTypesForDossierTemplate(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
                                             @RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted);


    @GetMapping(value = InternalApi.BASE_PATH+TYPE_PATH + DOSSIER_PATH + DOSSIER_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    List<Type> getAllTypesForDossier(@PathVariable(DOSSIER_ID_PARAMETER_NAME) String dossierId,
                                     @RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted);


    @GetMapping(value = InternalApi.BASE_PATH+DICTIONARY_PATH + TYPE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    Type getDictionaryForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId, @RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion);


    @GetMapping(value = InternalApi.BASE_PATH+VERSION_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE)
    long getVersion(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);


    @GetMapping(value = InternalApi.BASE_PATH+VERSION_PATH + DOSSIER_PATH + DOSSIER_ID_PATH_VARIABLE)
    long getVersionForDossier(@PathVariable(DOSSIER_ID_PARAMETER_NAME) String dossierId);


    @ResponseBody
    @GetMapping(value = InternalApi.BASE_PATH+COLOR_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
    Colors getColors(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);

}
