class ConfirmationOfFundsController implements ConfirmationOfFundsApi {

    @Override
    public ResponseEntity createConsentConfirmationOfFunds(UUID xRequestID, ConsentsConfirmationOfFunds body, String digest, String signature, byte[] tpPSignatureCertificate,
                                                           String psuId, String psUIDType, String psUCorporateID, String psUCorporateIDType,
                                                           String tpPRedirectPreferred, String tpPRedirectURI, String tpPNokRedirectURI, String tpPExplicitAuthorisationPreferred,
                                                           String psUIPAddress, String psUIPPort, String psUAccept, String psUAcceptCharset, String psUAcceptEncoding, String psUAcceptLanguage,
                                                           String psUUserAgent, String psUHttpMethod, UUID psUDeviceID, String psUGeoLocation) {

        if (profileService.getPiisConsentSupported() != PiisConsentSupported.TPP_CONSENT_SUPPORTED) {
            MessageError messageError = new MessageError(ErrorType.PIIS_405, of(MessageErrorCode.SERVICE_INVALID_405));
            return responseErrorMapper.generateErrorResponse(messageError);
        }

        PsuIdData psuData = new PsuIdData(psuId, psUIDType, psUCorporateID, psUCorporateIDType, psUIPAddress,
                                          new AdditionalPsuIdData(psUIPPort, psUUserAgent, psUGeoLocation, psUAccept, psUAcceptCharset, psUAcceptEncoding, psUAcceptLanguage, psUHttpMethod, psUDeviceID));

        CreatePiisConsentRequest createPiisConsentRequest = piisConsentModelMapper.toCreatePiisConsentRequest(body);
        ResponseObject<Xs2aConfirmationOfFundsResponse> xs2aConfirmationOfFundsResponseResponseObject = piisConsentService.createPiisConsentWithResponse(createPiisConsentRequest, psuData, BooleanUtils.toBoolean(tpPExplicitAuthorisationPreferred));
        if (xs2aConfirmationOfFundsResponseResponseObject.hasError()) {
            return responseErrorMapper.generateErrorResponse(xs2aConfirmationOfFundsResponseResponseObject.getError());
        }

        Xs2aConfirmationOfFundsResponse xs2aConfirmationOfFundsResponse = xs2aConfirmationOfFundsResponseResponseObject.getBody();

        ResponseHeaders headers = consentHeadersBuilder.buildCreateConsentHeaders(xs2aConfirmationOfFundsResponse.getAuthorizationId(),
                                                                                  Optional.ofNullable(xs2aConfirmationOfFundsResponse.getLinks().getSelf())
                                                                                      .map(HrefType::getHref)
                                                                                      .orElseThrow(() -> new IllegalArgumentException("Wrong href type in self link")));

        return responseMapper.created(xs2aConfirmationOfFundsResponseResponseObject, piisConsentModelMapper::mapToConsentsConfirmationOfFundsResponse, headers);
    }

}