de.adorsys.multibanking.ing.IngMapperImpl Maven / Gradle / Ivy
package de.adorsys.multibanking.ing;
import de.adorsys.multibanking.domain.Balance;
import de.adorsys.multibanking.domain.Balance.BalanceBuilder;
import de.adorsys.multibanking.domain.BankAccount;
import de.adorsys.multibanking.domain.Booking;
import de.adorsys.multibanking.domain.ScaApproach;
import de.adorsys.multibanking.domain.response.CreateConsentResponse;
import de.adorsys.multibanking.domain.response.UpdateAuthResponse;
import de.adorsys.multibanking.ing.api.Account;
import de.adorsys.multibanking.ing.api.Amount;
import de.adorsys.multibanking.ing.api.Transaction;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2020-09-15T14:03:41+0000",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_252 (Private Build)"
)
class IngMapperImpl implements IngMapper {
@Override
public CreateConsentResponse toCreateConsentResponse(IngSessionData bankApiConsentData, String redirectUrl) {
if ( bankApiConsentData == null && redirectUrl == null ) {
return null;
}
CreateConsentResponse createConsentResponse = new CreateConsentResponse();
if ( redirectUrl != null ) {
createConsentResponse.setRedirectUrl( redirectUrl );
}
createConsentResponse.setAuthorisationId( java.util.UUID.randomUUID().toString() );
createConsentResponse.setBankApiConsentData( bankApiConsentData );
createConsentResponse.setConsentId( java.util.UUID.randomUUID().toString() );
createConsentResponse.setScaApproach( ScaApproach.OAUTH );
return createConsentResponse;
}
@Override
public UpdateAuthResponse toUpdateAuthResponse(IngSessionData ingSessionData, UpdateAuthResponse updateAuthResponse) {
if ( ingSessionData == null ) {
return null;
}
return updateAuthResponse;
}
@Override
public List mapToBookings(List transactions) {
if ( transactions == null ) {
return null;
}
List list = new ArrayList( transactions.size() );
for ( Transaction transaction : transactions ) {
list.add( toBooking( transaction ) );
}
return list;
}
@Override
public Balance toBalance(de.adorsys.multibanking.ing.api.Balance balance) {
if ( balance == null ) {
return null;
}
BalanceBuilder balance1 = Balance.builder();
balance1.date( balance.getReferenceDate() );
Double amount = balanceBalanceAmountAmount( balance );
if ( amount != null ) {
balance1.amount( BigDecimal.valueOf( amount ) );
}
balance1.currency( balanceBalanceAmountCurrency( balance ) );
return balance1.build();
}
@Override
public List toBankAccounts(List accountDetails) {
if ( accountDetails == null ) {
return null;
}
List list = new ArrayList( accountDetails.size() );
for ( Account account : accountDetails ) {
list.add( toBankAccount( account ) );
}
return list;
}
@Override
public BankAccount toBankAccount(Account accountDetails) {
if ( accountDetails == null ) {
return null;
}
BankAccount bankAccount = new BankAccount();
bankAccount.setCurrency( accountDetails.getCurrency() );
bankAccount.setName( accountDetails.getName() );
bankAccount.setIban( accountDetails.getIban() );
bankAccount.setExternalIdMap( getExternalIdMap(accountDetails.getResourceId().toString()) );
bankAccount.setBlz( getBlz(accountDetails) );
bankAccount.setAccountNumber( getAccountNumber(accountDetails) );
return bankAccount;
}
private Double balanceBalanceAmountAmount(de.adorsys.multibanking.ing.api.Balance balance) {
if ( balance == null ) {
return null;
}
Amount balanceAmount = balance.getBalanceAmount();
if ( balanceAmount == null ) {
return null;
}
Double amount = balanceAmount.getAmount();
if ( amount == null ) {
return null;
}
return amount;
}
private String balanceBalanceAmountCurrency(de.adorsys.multibanking.ing.api.Balance balance) {
if ( balance == null ) {
return null;
}
Amount balanceAmount = balance.getBalanceAmount();
if ( balanceAmount == null ) {
return null;
}
String currency = balanceAmount.getCurrency();
if ( currency == null ) {
return null;
}
return currency;
}
}