class ConsentModelMapper {

    public CreateConsentReq mapToCreateConsentReq(Consents consent, TppRedirectUri tppRedirectUri,
                                                  TppNotificationData tppNotificationData, String tppBrandLoggingInformation,
                                                  String instanceId) {
        return Optional.ofNullable(consent)
                   .map(cnst -> {
                       CreateConsentReq createConsentReq = new CreateConsentReq();
                       createConsentReq.setAccess(mapToAccountAccessInner(cnst.getAccess()));
                       createConsentReq.setRecurringIndicator(cnst.getRecurringIndicator());
                       createConsentReq.setValidUntil(cnst.getValidUntil());
                       createConsentReq.setFrequencyPerDay(cnst.getFrequencyPerDay());
                       createConsentReq.setCombinedServiceIndicator(BooleanUtils.toBoolean(cnst.isCombinedServiceIndicator()));
                       createConsentReq.setTppRedirectUri(tppRedirectUri);
                       createConsentReq.setTppNotificationData(tppNotificationData);
                       createConsentReq.setAvailableAccounts(mapToAccountAccessTypeFromAvailableAccounts(cnst.getAccess().getAvailableAccounts()));
                       createConsentReq.setAllPsd2(mapToAccountAccessTypeFromAllPsd2Enum(cnst.getAccess().getAllPsd2()));
                       createConsentReq.setAvailableAccountsWithBalance(mapToAccountAccessTypeFromAvailableAccountsWithBalance(cnst.getAccess().getAvailableAccountsWithBalance()));
                       createConsentReq.setTppBrandLoggingInformation(tppBrandLoggingInformation);
                       createConsentReq.setInstanceId(instanceId);
                       return createConsentReq;
                   })
                   .orElse(null);
    }

}