class ConsentServiceInternalEncrypted implements ConsentServiceEncrypted {

    @Override
    @Transactional(rollbackFor = WrongChecksumException.class)
    public CmsResponse<CmsCreateConsentResponse> createConsent(CmsConsent request) throws WrongChecksumException {
        CmsResponse<CmsCreateConsentResponse> serviceResponse = consentService.createConsent(request);

        if (serviceResponse.hasError()) {
            return serviceResponse;
        }

        CmsCreateConsentResponse cmsCreateConsentResponse = serviceResponse.getPayload();
        Optional<String> encryptIdOptional = securityDataService.encryptId(cmsCreateConsentResponse.getConsentId());

        if (encryptIdOptional.isEmpty()) {
            log.info("Consent ID: [{}]. Create consent failed, couldn't encrypt consent id", cmsCreateConsentResponse.getConsentId());
            return CmsResponse.<CmsCreateConsentResponse>builder()
                       .error(TECHNICAL_ERROR)
                       .build();
        }

        return CmsResponse.<CmsCreateConsentResponse>builder()
                   .payload(new CmsCreateConsentResponse(encryptIdOptional.get(), cmsCreateConsentResponse.getCmsConsent()))
                   .build();
    }

}