class Xs2aPisCommonPaymentMapper {

    public UpdateAuthorisationRequest mapToUpdateAuthorisationRequest(AuthorisationProcessorResponse response, AuthorisationType authorisationType) {
        return Optional.ofNullable(response)
                   .map(data -> {
                       UpdateAuthorisationRequest req = new UpdateAuthorisationRequest();
                       req.setPsuData(((Xs2aUpdatePisCommonPaymentPsuDataResponse) response).getPsuData());
                       req.setAuthenticationMethodId(Optional.ofNullable(data.getChosenScaMethod())
                                                         .map(AuthenticationObject::getAuthenticationMethodId)
                                                         .orElse(null));
                       req.setScaStatus(data.getScaStatus());
                       req.setAuthorisationType(authorisationType);
                       return req;
                   })
                   .orElse(null);
    }

}