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

Commit

Permalink
#240: Update the library up to the version 1.92.0 of the API
Browse files Browse the repository at this point in the history
  • Loading branch information
proshin-roman committed Dec 26, 2019
1 parent aa7d2c5 commit 2702a8d
Show file tree
Hide file tree
Showing 77 changed files with 5,852 additions and 1,820 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>org.proshin</groupId>
<artifactId>finapi-java-client</artifactId>
<version>0.1.74-SNAPSHOT</version>
<version>0.1.92-SNAPSHOT</version>
<packaging>jar</packaging>

<name>finAPI Java client</name>
Expand Down Expand Up @@ -66,7 +66,7 @@
<role>architect</role>
<role>developer</role>
</roles>
<timezone>Europe/Moscow</timezone>
<timezone>Europe/Berlin</timezone>
</developer>
</developers>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.proshin.finapi.bank.out;
package org.proshin.finapi;

public enum BankingInterface {

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/proshin/finapi/account/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.proshin.finapi.account.out.Status;
import org.proshin.finapi.bankconnection.BankConnection;

// @todo #240 Find and mark as deprecated all fields that became deprecated due to PSD2-related changes
public interface Account {

Long id();
Expand Down Expand Up @@ -53,18 +54,36 @@ public interface Account {

Optional<BigDecimal> availableFunds();

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
Optional<OffsetDateTime> lastSuccessfulUpdate();

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
Optional<OffsetDateTime> lastUpdateAttempt();

boolean isNew();

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
Status status();

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
Iterable<Order> supportedOrders();

Iterable<ClearingAccount> clearingAccounts();

Iterable<AccountInterface> interfaces();

void edit(FpEditParameters parameters);

void delete(Long id);
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/org/proshin/finapi/account/AccountInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2019 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.account;

import java.time.OffsetDateTime;
import java.util.Optional;
import org.proshin.finapi.BankingInterface;
import org.proshin.finapi.account.out.Capability;
import org.proshin.finapi.account.out.Status;

public interface AccountInterface {

BankingInterface bankingInterface();

Status status();

Iterable<Capability> capabilities();

Optional<OffsetDateTime> lastSuccessfulUpdate();

Optional<OffsetDateTime> lastUpdateAttempt();
}
2 changes: 1 addition & 1 deletion src/main/java/org/proshin/finapi/account/DirectDebit.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public interface DirectDebit {

SepaRequestingResponse request(final DirectDebitParameters parameters);
SepaRequestingResponse request(DirectDebitParameters parameters);

SepaExecutingResponse execute(Long account, String bankingTan);
}
10 changes: 9 additions & 1 deletion src/main/java/org/proshin/finapi/account/FpAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Optional<String> currency() {

@Override
public Type type() {
return new Type.TypeOf(this.origin.getInt("accountTypeId")).get();
return Type.valueOf(this.origin.getString("accountType"));
}

@Override
Expand Down Expand Up @@ -156,6 +156,14 @@ public Iterable<ClearingAccount> clearingAccounts() {
);
}

@Override
public Iterable<AccountInterface> interfaces() {
return new IterableJsonArray<>(
this.origin.getJSONArray("interfaces"),
(array, index) -> new FpAccountInterface(array.getJSONObject(index))
);
}

@Override
public void edit(final FpEditParameters parameters) {
this.endpoint.patch(this.url + this.id(), this.token, parameters);
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/org/proshin/finapi/account/FpAccountInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2019 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.account;

import java.time.OffsetDateTime;
import java.util.Optional;
import org.json.JSONObject;
import org.proshin.finapi.BankingInterface;
import org.proshin.finapi.account.out.Capability;
import org.proshin.finapi.account.out.Status;
import org.proshin.finapi.primitives.IterableJsonArray;
import org.proshin.finapi.primitives.optional.OptionalOffsetDateTimeOf;

public class FpAccountInterface implements AccountInterface {

private final JSONObject origin;

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

@Override
public BankingInterface bankingInterface() {
return BankingInterface.valueOf(this.origin.getString("interface"));
}

@Override
public Status status() {
return Status.valueOf(this.origin.getString("status"));
}

@Override
public Iterable<Capability> capabilities() {
return new IterableJsonArray<>(
this.origin.getJSONArray("capabilities"),
(json, index) -> Capability.valueOf(json.getString(index))
);
}

@Override
public Optional<OffsetDateTime> lastSuccessfulUpdate() {
return new OptionalOffsetDateTimeOf(this.origin, "lastSuccessfulUpdate").get();
}

@Override
public Optional<OffsetDateTime> lastUpdateAttempt() {
return new OptionalOffsetDateTimeOf(this.origin, "lastUpdateAttempt").get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public interface MoneyTransfer {

SepaRequestingResponse request(final MoneyTransferParameters parameters);
SepaRequestingResponse request(MoneyTransferParameters parameters);

SepaExecutingResponse execute(Long account, String bankingTan);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.LocalDate;
import org.json.JSONObject;
import org.proshin.finapi.Jsonable;
import org.proshin.finapi.primitives.MultiStepAuthentication;
import org.proshin.finapi.primitives.StringOf;

public final class DirectDebitParameters implements Jsonable {
Expand All @@ -43,11 +44,20 @@ public DirectDebitParameters withBankingPin(final String bankingPin) {
return this;
}

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
public DirectDebitParameters withStoringPin() {
this.origin.put("storePin", true);
return this;
}

public DirectDebitParameters withStoringSecrets() {
this.origin.put("storeSecrets", true);
return this;
}

public DirectDebitParameters withTwoStepProcedure(final String id) {
this.origin.put("twoStepProcedureId", id);
return this;
Expand Down Expand Up @@ -80,6 +90,16 @@ public DirectDebitParameters withDebtors(final Debtor... debtors) {
return this;
}

public DirectDebitParameters withHidingTransactionDetailsInWebForm() {
this.origin.put("hideTransactionDetailsInWebForm", true);
return this;
}

public DirectDebitParameters withMultiStepAuthentication(final MultiStepAuthentication multiStepAuthentication) {
this.origin.put("multiStepAuthentication", multiStepAuthentication.asJson());
return this;
}

@Override
public JSONObject asJson() {
return this.origin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public FpQueryCriteria withTypes(final Type... types) {
this.pairs.add(
new UrlEncodedPair(
new CommaSeparatedPair<>(
"accountTypeIds",
"accountTypes",
Arrays.stream(types)
.map(Type::asCode)
.map(Type::name)
.collect(Collectors.toList())
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.cactoos.iterator.IteratorOf;
import org.json.JSONObject;
import org.proshin.finapi.Jsonable;
import org.proshin.finapi.primitives.MultiStepAuthentication;
import org.proshin.finapi.primitives.StringOf;

public final class MoneyTransferParameters implements Jsonable {
Expand All @@ -45,11 +46,20 @@ public MoneyTransferParameters withBankingPin(final String bankingPin) {
return this;
}

/**
* @deprecated since v0.1.92 due to PSD2-related changes
*/
@Deprecated
public MoneyTransferParameters withStoringPin() {
this.origin.put("storePin", true);
return this;
}

public MoneyTransferParameters withStoringSecrets() {
this.origin.put("storeSecrets", true);
return this;
}

public MoneyTransferParameters withTwoStepProcedure(final String id) {
this.origin.put("twoStepProcedureId", id);
return this;
Expand Down Expand Up @@ -84,6 +94,16 @@ public MoneyTransferParameters withRecipients(final Recipient... recipients) {
return this;
}

public MoneyTransferParameters withHidingTransactionDetailsInWebForm() {
this.origin.put("hideTransactionDetailsInWebForm", true);
return this;
}

public MoneyTransferParameters withMultiStepAuthentication(final MultiStepAuthentication multiStepAuthentication) {
this.origin.put("multiStepAuthentication", multiStepAuthentication.asJson());
return this;
}

@Override
public JSONObject asJson() {
return this.origin;
Expand Down Expand Up @@ -121,6 +141,11 @@ public Recipient withClearingAccount(final String id) {
return this;
}

public Recipient withEndToEndId(final String endToEndId) {
this.origin.put("endToEndId", endToEndId);
return this;
}

public Recipient withAmount(final BigDecimal amount) {
this.origin.put("amount", amount);
return this;
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/org/proshin/finapi/account/out/Capability.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2019 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.account.out;

public enum Capability {
DATA_DOWNLOAD,
IBAN_ONLY_SEPA_MONEY_TRANSFER,
IBAN_ONLY_SEPA_DIRECT_DEBIT,
SEPA_MONEY_TRANSFER,
SEPA_COLLECTIVE_MONEY_TRANSFER,
SEPA_BASIC_DIRECT_DEBIT,
SEPA_BASIC_COLLECTIVE_DIRECT_DEBIT,
SEPA_B2B_DIRECT_DEBIT,
SEPA_B2B_COLLECTIVE_DIRECT_DEBIT
}
Loading

0 comments on commit 2702a8d

Please sign in to comment.