Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Update to finapi v1.107 #331

Merged
merged 5 commits into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/proshin/finapi/bank/Bank.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.time.OffsetDateTime;
import java.util.Optional;
import org.proshin.finapi.bank.out.BankGroup;
import org.proshin.finapi.bank.out.BankInterface;
import org.proshin.finapi.bank.out.LoginFields;

Expand Down Expand Up @@ -82,6 +83,8 @@ public interface Bank {

Iterable<BankInterface> interfaces();

Optional<BankGroup> bankGroup();

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/proshin/finapi/bank/FpBank.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.time.OffsetDateTime;
import java.util.Optional;
import org.json.JSONObject;
import org.proshin.finapi.bank.out.BankGroup;
import org.proshin.finapi.bank.out.BankInterface;
import org.proshin.finapi.bank.out.FpBankGroup;
import org.proshin.finapi.bank.out.FpBankInterface;
import org.proshin.finapi.bank.out.FpLoginFields;
import org.proshin.finapi.bank.out.LoginFields;
Expand Down Expand Up @@ -124,6 +126,12 @@ public Iterable<BankInterface> interfaces() {
);
}

@Override
public Optional<BankGroup> bankGroup() {
return Optional.ofNullable(this.origin.getJSONObject("bankGroup"))
.map(FpBankGroup::new);
}

@Override
public Optional<OffsetDateTime> lastCommunicationAttempt() {
return new OptionalOffsetDateTimeOf(this.origin, "lastCommunicationAttempt").get();
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/proshin/finapi/bank/out/BankGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2020 Roman Proshin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.proshin.finapi.bank.out;

public interface BankGroup {

Long id();

String name();
}
2 changes: 2 additions & 0 deletions src/main/java/org/proshin/finapi/bank/out/BankInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface BankInterface {

Optional<OffsetDateTime> lastSuccessfulCommunication();

boolean isMoneyTransferSupported();

enum BankInterfaceProperty {
REDIRECT_APPROACH, DECOUPLED_APPROACH, DETAILED_CONSENT
}
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/org/proshin/finapi/bank/out/FpBankGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2020 Roman Proshin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.proshin.finapi.bank.out;

import org.json.JSONObject;

public class FpBankGroup implements BankGroup {

private final JSONObject origin;

public FpBankGroup(final JSONObject origin) {
this.origin = origin;
}

@Override
public Long id() {
return this.origin.getLong("id");
}

@Override
public String name() {
return this.origin.getString("name");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@ public Optional<OffsetDateTime> lastCommunicationAttempt() {
public Optional<OffsetDateTime> lastSuccessfulCommunication() {
return new OptionalOffsetDateTimeOf(this.origin, "lastSuccessfulCommunication").get();
}

@Override
public boolean isMoneyTransferSupported() {
return this.origin.getBoolean("isMoneyTransferSupported");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public interface BankConnectionInterface {

TwoStepProcedures twoStepProcedures();

BankConsent aisConsent();
Optional<BankConsent> aisConsent();
ccostin93 marked this conversation as resolved.
Show resolved Hide resolved

Optional<UpdateResult> lastManualUpdate();

Optional<UpdateResult> lastAutoUpdate();

boolean userActionRequired();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public TwoStepProcedures twoStepProcedures() {
}

@Override
public BankConsent aisConsent() {
return new FpBankConsent(this.origin.getJSONObject("aisConsent"));
public Optional<BankConsent> aisConsent() {
return new OptionalObjectOf(this.origin, "aisConsent").get()
.map(FpBankConsent::new);
}

@Override
Expand All @@ -63,4 +64,9 @@ public Optional<UpdateResult> lastAutoUpdate() {
return new OptionalObjectOf(this.origin, "lastAutoUpdate").get()
.map(FpUpdateResult::new);
}

@Override
public boolean userActionRequired() {
return this.origin.getBoolean("userActionRequired");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public interface Configuration {
@Deprecated
boolean isXs2aEnabled();

boolean isStandalonePaymentsEnabled();

Iterable<String> availableBankGroups();

Optional<String> applicationName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public boolean isXs2aEnabled() {
return this.origin.getBoolean("isXs2aEnabled");
}

@Override
public boolean isStandalonePaymentsEnabled() {
return this.origin.getBoolean("isStandalonePaymentsEnabled");
}

@Override
public Iterable<String> availableBankGroups() {
return new IterableJsonArray<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public CreateTppCredentialParameters withTppApiKey(final String tppApiKey) {
return this;
}

public CreateTppCredentialParameters withTppName(final String tppName) {
this.origin.put("tppName", tppName);
return this;
}

public CreateTppCredentialParameters withValidFromDate(final LocalDate validFromDate) {
this.origin.put("validFromDate", new StringOf(validFromDate));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public EditTppCredentialParameters withTppApiKey(final String tppApiKey) {
return this;
}

public EditTppCredentialParameters withTppName(final String tppName) {
this.origin.put("tppName", tppName);
return this;
}

public EditTppCredentialParameters withValidFromDate(final LocalDate validFromDate) {
this.origin.put("validFromDate", new StringOf(validFromDate));
return this;
Expand Down
24 changes: 23 additions & 1 deletion src/test/java/org/proshin/finapi/bank/FpBankTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.jupiter.api.Test;
import static org.proshin.finapi.bank.Bank.DataSource.FINTS_SERVER;
import static org.proshin.finapi.bank.Bank.DataSource.WEB_SCRAPER;
import org.proshin.finapi.bank.out.BankGroup;
import org.proshin.finapi.bank.out.BankInterface;
import static org.proshin.finapi.bank.out.BankInterface.BankInterfaceProperty.REDIRECT_APPROACH;
import org.proshin.finapi.bank.out.LoginCredential;
Expand Down Expand Up @@ -72,9 +73,17 @@ public void test() {
" \"properties\": [" +
" \"REDIRECT_APPROACH\"" +
" ]," +
" \"loginHint\": \"Bitte geben Sie nur die ersten fünf Stellen Ihrer PIN ein.\"" +
" \"loginHint\": \"Bitte geben Sie nur die ersten fünf Stellen Ihrer PIN ein.\"," +
" \"health\": 100," +
" \"lastCommunicationAttempt\": \"2018-01-01 00:00:00.000\"," +
" \"lastSuccessfulCommunication\": \"2018-01-02 00:00:00.000\"," +
" \"isMoneyTransferSupported\": true" +
" }" +
" ]," +
" \"bankGroup\": {" +
" \"id\": 1," +
" \"name\": \"FinAPI Test Bank Group\"" +
" }," +
" \"lastCommunicationAttempt\": \"2018-01-01 00:00:00.000\"," +
" \"lastSuccessfulCommunication\": \"2018-01-02 00:00:00.000\"" +
'}')
Expand Down Expand Up @@ -120,6 +129,19 @@ public void test() {

assertThat(bankInterface.loginHint())
.isEqualTo(Optional.of("Bitte geben Sie nur die ersten fünf Stellen Ihrer PIN ein."));

assertThat(bankInterface.health()).isEqualTo(100);
assertThat(bankInterface.lastCommunicationAttempt())
.isEqualTo(Optional.of(new OffsetDateTimeOf("2018-01-01 00:00:00.000").get()));
assertThat(bankInterface.lastSuccessfulCommunication())
.isEqualTo(Optional.of(new OffsetDateTimeOf("2018-01-02 00:00:00.000").get()));

assertThat(bankInterface.isMoneyTransferSupported()).isTrue();
}

assertThat(bank.bankGroup().isPresent()).isTrue();
final BankGroup bankGroup = bank.bankGroup().get();
assertThat(bankGroup.id()).isEqualTo(1L);
assertThat(bankGroup.name()).isEqualTo("FinAPI Test Bank Group");
}
}
Loading