class AuthorisationServiceInternal implements AuthorisationService {

    @Transactional
    @Override
    public CmsResponse<Authorisation> updateAuthorisation(String authorisationId, UpdateAuthorisationRequest request) {
        Optional<AuthorisationEntity> authorisationOptional = getAuthorisation(authorisationId);

        if (authorisationOptional.isEmpty()) {
            log.info("Authorisation ID: [{}]. Update authorisation has failed, because authorisation couldn't be found",
                     authorisationId);
            return CmsResponse.<Authorisation>builder()
                       .error(LOGICAL_ERROR)
                       .build();
        }

        AuthorisationEntity authorisation = authorisationOptional.get();
        PsuIdData psuDataFromRequest = request.getPsuData();
        authorisationClosingService.closePreviousAuthorisationsByAuthorisation(authorisation, psuDataFromRequest);

        if (authorisation.getScaStatus().isFinalisedStatus()) {
            log.info("Authorisation ID: [{}], SCA status: [{}]. Update authorisation has failed, because authorisation has finalised status",
                     authorisationId, authorisation.getScaStatus().getValue());
            return CmsResponse.<Authorisation>builder()
                       .error(LOGICAL_ERROR)
                       .build();
        }

        AuthorisationEntity updatedAuthorisation = authServiceResolver.getAuthService(request.getAuthorisationType()).doUpdateAuthorisation(authorisation, request);

        return CmsResponse.<Authorisation>builder()
                   .payload(authorisationMapper.mapToAuthorisation(updatedAuthorisation))
                   .build();
    }

}