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.processing.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2021-08-27T09:46:49+0000",
comments = "version: 1.4.1.Final, compiler: javac, environment: Java 11.0.12 (Azul Systems, Inc.)"
)
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.setConsentId( java.util.UUID.randomUUID().toString() );
createConsentResponse.setAuthorisationId( java.util.UUID.randomUUID().toString() );
createConsentResponse.setBankApiConsentData( bankApiConsentData );
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();
Double amount = balanceBalanceAmountAmount( balance );
if ( amount != null ) {
balance1.amount( BigDecimal.valueOf( amount ) );
}
balance1.date( balance.getReferenceDate() );
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;
}
}