Skip to content
Open
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
5 changes: 2 additions & 3 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Fio Bank Java Client

BSD License
BSD 3-Clause License

Copyright (c) 2016, Martin Caslavsky
Copyright (c) 2020, Jiri Kapoun

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ A Java SDK for accessing the [REST API](http://www.fio.cz/bank-services/internet

## Usage

The *Fio Bank Java Client* is available in Maven Central Repository, to use it from Maven add to `pom.xml`:
The *Fio Bank Java Client* is available in [JitPack](https://jitpack.io/) Maven repository, to use it from Maven add to `pom.xml`:

```xml
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
```

```xml
<dependency>
<groupId>cz.geek</groupId>
<groupId>com.github.kapoun</groupId>
<artifactId>fio-java</artifactId>
<version>0.1.0</version>
<version>fio-java-0.2.0</version>
</dependency>
```

Expand All @@ -28,7 +35,7 @@ FioAccountStatement statement = fio.getStatement(2016, 1);

Get account statement within **the given period**:
```java
FioAccountStatement statement = fio.getStatement(new LocalDate(2016, 1, 1), new LocalDate(2016, 1, 31));
FioAccountStatement statement = fio.getStatement(LocalDate.of(2016, 1, 1), LocalDate.of(2016, 1, 31));
```

Get account statement from the **last download**:
Expand All @@ -45,7 +52,7 @@ fio.getStatement(2016, 1, ExportFormat.pdf, outputStream);

Export account statement within **the given period**:
```java
fio.getStatement(new LocalDate(2016, 1, 1), new LocalDate(2016, 1, 31), ExportFormat.pdf, outputStream);
fio.getStatement(LocalDate.of(2016, 1, 1), LocalDate.of(2016, 1, 31), ExportFormat.pdf, outputStream);
```

Export account statement from the **last download**:
Expand All @@ -57,7 +64,7 @@ fio.getStatement(ExportFormat.pdf, outputStream);

Set last downloaded statement **by date**:
```java
fio.setLast(new LocalDate(2016, 1, 1));
fio.setLast(LocalDate.of(2016, 1, 1));
```

Set last downloaded statement **by transaction id**:
Expand Down
30 changes: 21 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>cz.hrubysoftware</groupId>
<artifactId>fio-java</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.2.1</version>
<name>${project.artifactId}</name>
<description>Fio Bank Java Client</description>

Expand All @@ -29,14 +29,23 @@
<developer>
<name>Martin Caslavsky</name>
</developer>
<developer>
<name>Novotass</name>
</developer>
<developer>
<name>Lukas Hruby</name>
</developer>
<developer>
<name>Jiri Kapoun</name>
</developer>
</developers>

<properties>
<targetJdk>1.7</targetJdk>
<targetJdk>1.8</targetJdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<httpclient.version>4.3.3</httpclient.version>
<spring.version>3.2.13.RELEASE</spring.version>
<spring.version>5.1.5.RELEASE</spring.version>
<jadler.version>1.1.1</jadler.version>
<json-unit.version>1.5.3</json-unit.version>
</properties>
Expand Down Expand Up @@ -149,7 +158,7 @@
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
<failOnWarning>false</failOnWarning>
<ignoreNonCompile>true</ignoreNonCompile>
<ignoredUnusedDeclaredDependencies>
<ignoredUsedUndeclaredDependency>org.apache.httpcomponents:httpcore</ignoredUsedUndeclaredDependency>
Expand All @@ -169,6 +178,14 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down Expand Up @@ -221,11 +238,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cz/geek/fio/FioAccountInfo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cz.geek.fio;

import org.joda.time.LocalDate;
import java.time.LocalDate;

import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/cz/geek/fio/FioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
Expand All @@ -32,7 +31,7 @@ public class FioClient {
private static final String LAST_DATE = ROOT + "set-last-date/{token}/{date}/";
private static final String LAST_ID = ROOT + "set-last-id/{token}/{id}/";

private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

private final String token;
private final String protocol;
Expand Down Expand Up @@ -105,7 +104,7 @@ public FioAccountStatement getStatement(final LocalDate start, final LocalDate e
notNull(end);
return restTemplate.execute(STATEMENT_PERIODS, GET, null,
statementExtractor(jaxb2Converter, conversionService),
protocol, hostport, token, DATE_FORMATTER.print(start), DATE_FORMATTER.print(end), ExportFormat.xml);
protocol, hostport, token, DATE_FORMATTER.format(start), DATE_FORMATTER.format(end), ExportFormat.xml);
}

/**
Expand All @@ -121,7 +120,7 @@ public void exportStatement(final LocalDate start, final LocalDate end, final Ex
notNull(end);
notNull(format);
restTemplate.execute(STATEMENT_PERIODS, GET, null, new OutputStreamResponseExtractor(target),
protocol, hostport, token, DATE_FORMATTER.print(start), DATE_FORMATTER.print(end), format);
protocol, hostport, token, DATE_FORMATTER.format(start), DATE_FORMATTER.format(end), format);
}

/**
Expand Down Expand Up @@ -203,7 +202,7 @@ public void setLast(final String id) {
public void setLast(final LocalDate date) {
notNull(date);
restTemplate.execute(LAST_DATE, GET, null, null,
protocol, hostport, token, DATE_FORMATTER.print(date));
protocol, hostport, token, DATE_FORMATTER.format(date));
}

}
4 changes: 2 additions & 2 deletions src/main/java/cz/geek/fio/FioConversionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cz.geek.fio.model.Info;
import cz.geek.fio.model.Transaction;
import cz.geek.fio.model.TransactionList;
import org.joda.time.LocalDate;
import java.time.LocalDate;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;

Expand Down Expand Up @@ -127,7 +127,7 @@ public List<FioTransaction> convert(final TransactionList source) {
}

private static LocalDate toLocalDate(final XMLGregorianCalendar date) {
return date != null ? new LocalDate(date.getYear(), date.getMonth(), date.getDay()) : null;
return date != null ? LocalDate.of(date.getYear(), date.getMonth(), date.getDay()) : null;
}

}
6 changes: 3 additions & 3 deletions src/main/java/cz/geek/fio/FioErrorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void handleError(final ClientHttpResponse response) throws IOException {
}
}

private byte[] getResponseBody(final ClientHttpResponse response) {
protected byte[] getResponseBody(final ClientHttpResponse response) {
try {
final InputStream responseBody = response.getBody();
if (responseBody != null) {
Expand All @@ -36,10 +36,10 @@ private byte[] getResponseBody(final ClientHttpResponse response) {
return new byte[0];
}

private Charset getCharset(final ClientHttpResponse response) {
protected Charset getCharset(final ClientHttpResponse response) {
final HttpHeaders headers = response.getHeaders();
final MediaType contentType = headers.getContentType();
return contentType != null ? contentType.getCharSet() : Charset.forName("ISO-8859-1");
return contentType != null ? contentType.getCharset() : Charset.forName("ISO-8859-1");
}

}
2 changes: 1 addition & 1 deletion src/main/java/cz/geek/fio/FioTransaction.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cz.geek.fio;

import lombok.Data;
import org.joda.time.LocalDate;
import java.time.LocalDate;

import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/cz/geek/fio/FioClientIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cz.geek.fio;

import org.joda.time.LocalDate;
import java.time.LocalDate;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void shouldExportTransactionsByDate() throws Exception {
.withContentType("text/xml")
.withStatus(200);

fio.exportStatement(new LocalDate(2016, 1, 1), new LocalDate(2016, 1, 2), ExportFormat.xml, new ByteArrayOutputStream());
fio.exportStatement(LocalDate.of(2016, 1, 1), LocalDate.of(2016, 1, 2), ExportFormat.xml, new ByteArrayOutputStream());
}

@Test
Expand All @@ -74,7 +74,7 @@ public void shouldGetTransactionsByDate() throws Exception {
.withContentType("text/xml")
.withStatus(200);

FioAccountStatement fioAS = fio.getStatement(new LocalDate(2016, 1, 1), new LocalDate(2016, 1, 2));
FioAccountStatement fioAS = fio.getStatement(LocalDate.of(2016, 1, 1), LocalDate.of(2016, 1, 2));
}

@Test
Expand Down Expand Up @@ -122,7 +122,7 @@ public void shouldSetLastDate() throws Exception {
.respond()
.withStatus(200);

fio.setLast(new LocalDate(2016, 1, 2));
fio.setLast(LocalDate.of(2016, 1, 2));
}

@AfterMethod
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/cz/geek/fio/FioExtractorTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cz.geek.fio;

import org.joda.time.LocalDate;
import java.time.LocalDate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.client.AbstractClientHttpResponse;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -29,7 +29,7 @@ public void shouldName() throws Exception {
assertThat(statement.getTransactions(), hasSize(2));
final FioTransaction transaction = statement.getTransactions().iterator().next();
assertThat(transaction.getTransactionId(), is("1147301403"));
assertThat(transaction.getDate(), is(new LocalDate(2012, 6, 30)));
assertThat(transaction.getDate(), is(LocalDate.of(2012, 6, 30)));
}

static class FakeClientHttpResponse extends AbstractClientHttpResponse {
Expand Down