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

import static com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter.convert;

import org.springframework.web.bind.annotation.RestController;

import com.iqser.red.service.persistence.management.v1.processor.service.DigitalSignatureKmsService;
import com.iqser.red.service.persistence.management.v1.processor.service.DigitalSignatureService;
import com.iqser.red.service.persistence.management.v1.processor.service.DigitalSignatureTypeService;
import com.iqser.red.service.persistence.service.v1.api.internal.resources.DigitalSignatureResource;
import com.iqser.red.service.persistence.service.v1.api.shared.model.DigitalSignatureKms;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.DigitalSignature;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.DigitalSignatureType;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequiredArgsConstructor
public class DigitalSignatureInternalController implements DigitalSignatureResource {

    private final DigitalSignatureTypeService digitalSignatureTypeService;
    private final DigitalSignatureService digitalSignatureService;
    private final DigitalSignatureKmsService digitalSignatureKmsService;


    @Override
    public DigitalSignatureType getActiveDigitalSignatureType() {

        return digitalSignatureTypeService.getActiveDigitalSignatureType();

    }


    @Override
    public DigitalSignature getDigitalSignature() {

        return convert(digitalSignatureService.getDigitalSignature(), DigitalSignature.class);
    }


    @Override
    public DigitalSignatureKms getDigitalSignatureKms() {

        return digitalSignatureKmsService.convert(digitalSignatureKmsService.getDigitalSignature());
    }

}
