Skip to content

Commit bde22f2

Browse files
author
Kevin Hellemun
committed
Merge branch 'release/0.12.4'
2 parents d058b03 + 7f42744 commit bde22f2

File tree

161 files changed

+5944
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+5944
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ context-save-restore-test.conf
7272
/tmp
7373
config.properties
7474
bunq-test.conf
75+
.idea/codeStyles/

CHANGELOG.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Change Log
2+
3+
## [0.12.4](https://github.com/bunq/sdk_java/tree/0.12.4) (2017-12-21)
4+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.3...0.12.4)
5+
6+
**Implemented enhancements:**
7+
8+
- Introduce fromJson method [\#51](https://github.com/bunq/sdk_java/issues/51)
9+
- Make sure received signatures headers are correctly cased [\#43](https://github.com/bunq/sdk_java/issues/43)
10+
- Remove guava  [\#41](https://github.com/bunq/sdk_java/issues/41)
11+
- Return base class from createFromJsonString [\#40](https://github.com/bunq/sdk_java/issues/40)
12+
- CHANGELOG.md is empty [\#38](https://github.com/bunq/sdk_java/issues/38)
13+
- Improve decoder to recognise child object [\#35](https://github.com/bunq/sdk_java/issues/35)
14+
15+
**Fixed bugs:**
16+
17+
- Remove guava  [\#41](https://github.com/bunq/sdk_java/issues/41)
18+
19+
**Merged pull requests:**
20+
21+
- Added method to ensure that reponse headers are correclty cased befor… [\#53](https://github.com/bunq/sdk_java/pull/53) ([OGKevin](https://github.com/OGKevin))
22+
- Feature/improve decoder bunq/sdk java\#35 [\#52](https://github.com/bunq/sdk_java/pull/52) ([OGKevin](https://github.com/OGKevin))
23+
- Removed guava as dependency. \(bunq/sdk\_java\#41\) [\#44](https://github.com/bunq/sdk_java/pull/44) ([OGKevin](https://github.com/OGKevin))
24+
- Generated CHANGELOG.md :clap:. \(bunq/sdk\_java\#38\) [\#39](https://github.com/bunq/sdk_java/pull/39) ([OGKevin](https://github.com/OGKevin))
25+
- Removed guava as dependency. \\(bunq/sdk\\_java\\#41\\) [\#44](https://github.com/bunq/sdk_java/pull/44) ([OGKevin](https://github.com/OGKevin))
26+
27+
## [0.12.3](https://github.com/bunq/sdk_java/tree/0.12.3) (2017-11-15)
28+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.2...0.12.3)
29+
30+
**Implemented enhancements:**
31+
32+
- Callback models for holding callback data [\#33](https://github.com/bunq/sdk_java/issues/33)
33+
- Feature/callback models bunq/sdk java\#33 [\#36](https://github.com/bunq/sdk_java/pull/36) ([OGKevin](https://github.com/OGKevin))
34+
35+
**Fixed bugs:**
36+
37+
- ScheduledPayment causes decode error due to Typo [\#37](https://github.com/bunq/sdk_java/issues/37)
38+
39+
## [0.12.2](https://github.com/bunq/sdk_java/tree/0.12.2) (2017-11-08)
40+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.0...0.12.2)
41+
42+
**Implemented enhancements:**
43+
44+
- Add missing fields for cvc endpoint [\#30](https://github.com/bunq/sdk_java/issues/30)
45+
- Missing CARD GENERATED CVC2 endpoint [\#26](https://github.com/bunq/sdk_java/issues/26)
46+
- More flexibility for sessionContext handling [\#23](https://github.com/bunq/sdk_java/issues/23)
47+
- Added cvc\_endpoint. \#26 [\#27](https://github.com/bunq/sdk_java/pull/27) ([OGKevin](https://github.com/OGKevin))
48+
- Added isExpired\(\) method \#23. [\#24](https://github.com/bunq/sdk_java/pull/24) ([OGKevin](https://github.com/OGKevin))
49+
50+
**Fixed bugs:**
51+
52+
- DraftPayment object field causes converter error [\#29](https://github.com/bunq/sdk_java/issues/29)
53+
54+
**Merged pull requests:**
55+
56+
- Feature/fix draft payment object \#29 [\#32](https://github.com/bunq/sdk_java/pull/32) ([OGKevin](https://github.com/OGKevin))
57+
- Feature/add missing cvc fields \#30 [\#31](https://github.com/bunq/sdk_java/pull/31) ([OGKevin](https://github.com/OGKevin))
58+
59+
## [0.12.0](https://github.com/bunq/sdk_java/tree/0.12.0) (2017-10-11)
60+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.11.0...0.12.0)
61+
62+
**Implemented enhancements:**
63+
64+
- Update read me with installation instructions [\#21](https://github.com/bunq/sdk_java/issues/21)
65+
- Better error handling [\#17](https://github.com/bunq/sdk_java/issues/17)
66+
- Response is missing response headers and pagination [\#4](https://github.com/bunq/sdk_java/issues/4)
67+
- Feature/exception handler [\#18](https://github.com/bunq/sdk_java/pull/18) ([OGKevin](https://github.com/OGKevin))
68+
- Marked all files in generated dir as generated code. [\#16](https://github.com/bunq/sdk_java/pull/16) ([OGKevin](https://github.com/OGKevin))
69+
70+
**Closed issues:**
71+
72+
- Improve Model Namespaces [\#19](https://github.com/bunq/sdk_java/issues/19)
73+
74+
**Merged pull requests:**
75+
76+
- cleanup after 19-improve-namespaces [\#22](https://github.com/bunq/sdk_java/pull/22) ([dnl-blkv](https://github.com/dnl-blkv))
77+
- Fix namespaces; cleanup tests; kill formatting of generated files \[\#19\] [\#20](https://github.com/bunq/sdk_java/pull/20) ([dnl-blkv](https://github.com/dnl-blkv))
78+
79+
## [0.11.0](https://github.com/bunq/sdk_java/tree/0.11.0) (2017-09-06)
80+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.10.0...0.11.0)
81+
82+
**Implemented enhancements:**
83+
84+
- Ignore generated code for reviews [\#14](https://github.com/bunq/sdk_java/issues/14)
85+
- Added git attributes. [\#15](https://github.com/bunq/sdk_java/pull/15) ([OGKevin](https://github.com/OGKevin))
86+
87+
**Merged pull requests:**
88+
89+
- Add pagination; cleanup; add missing endpoints and fields \[\#4\] [\#13](https://github.com/bunq/sdk_java/pull/13) ([dnl-blkv](https://github.com/dnl-blkv))
90+
91+
## [0.10.0](https://github.com/bunq/sdk_java/tree/0.10.0) (2017-08-23)
92+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.9.1...0.10.0)
93+
94+
**Implemented enhancements:**
95+
96+
- Add Proxy Support [\#11](https://github.com/bunq/sdk_java/issues/11)
97+
- Allow saving context to JSON and restoring from it [\#9](https://github.com/bunq/sdk_java/issues/9)
98+
- Add proxy support and missing .gitignore entry \[\#11\] [\#12](https://github.com/bunq/sdk_java/pull/12) ([dnl-blkv](https://github.com/dnl-blkv))
99+
- add methods to save ApiContext to JSON and restore it from JSON \[\#9\] [\#10](https://github.com/bunq/sdk_java/pull/10) ([dnl-blkv](https://github.com/dnl-blkv))
100+
- \#4 Introduce BunqResponse [\#5](https://github.com/bunq/sdk_java/pull/5) ([dnl-blkv](https://github.com/dnl-blkv))
101+
102+
**Fixed bugs:**
103+
104+
- SDK build fails on jitpack [\#6](https://github.com/bunq/sdk_java/issues/6)
105+
- Fix Jitpack build, add misssing fields, fix field types in generated \[\#6\] [\#8](https://github.com/bunq/sdk_java/pull/8) ([dnl-blkv](https://github.com/dnl-blkv))
106+
107+
## [0.9.1](https://github.com/bunq/sdk_java/tree/0.9.1) (2017-08-08)
108+
**Implemented enhancements:**
109+
110+
- Added tests readme [\#3](https://github.com/bunq/sdk_java/pull/3) ([OGKevin](https://github.com/OGKevin))
111+
- Add first series of unit-tests [\#1](https://github.com/bunq/sdk_java/pull/1) ([OGKevin](https://github.com/OGKevin))
112+
113+
114+
115+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.bunq.sdk'
2-
version '0.12.3'
2+
version '0.12.4'
33

44
apply plugin: 'java'
55
apply plugin: 'maven'
@@ -16,8 +16,6 @@ dependencies {
1616
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
1717
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
1818
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
19-
// https://mvnrepository.com/artifact/com.google.guava/guava
20-
compile group: 'com.google.guava', name: 'guava', version: '22.0'
2119
// https://mvnrepository.com/artifact/org.apache.commons/commons-io
2220
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
2321
// https://mvnrepository.com/artifact/com.squareup.okio/okio

src/main/java/com/bunq/sdk/context/ApiContext.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.HashMap;
2020
import java.util.List;
2121
import java.util.Map;
22-
import javax.annotation.Nullable;
2322
import org.apache.commons.io.FileUtils;
2423

2524
/**
@@ -284,8 +283,7 @@ public URI getBaseUri() {
284283
* @return The session token, installation token if the session isn't created yet, or null if no
285284
* installation is created either.
286285
*/
287-
public @Nullable
288-
String getSessionToken() {
286+
public String getSessionToken() {
289287
if (sessionContext != null) {
290288
return sessionContext.getToken();
291289
} else if (installationContext != null) {

src/main/java/com/bunq/sdk/http/ApiClient.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.http.impl.client.CloseableHttpClient;
4545
import org.apache.http.impl.client.HttpClientBuilder;
4646
import org.apache.http.impl.client.HttpClients;
47+
import org.apache.http.message.BasicHeader;
4748
import org.apache.http.ssl.SSLContextBuilder;
4849
import org.apache.http.util.EntityUtils;
4950

@@ -93,7 +94,7 @@ public class ApiClient {
9394
/**
9495
* Prefix for bunq's own headers.
9596
*/
96-
private static final String USER_AGENT_BUNQ = "bunq-sdk-java/0.12.3";
97+
private static final String USER_AGENT_BUNQ = "bunq-sdk-java/0.12.4";
9798
private static final String LANGUAGE_EN_US = "en_US";
9899
private static final String REGION_NL_NL = "nl_NL";
99100
private static final String GEOLOCATION_ZERO = "0 0 0 0 000";
@@ -225,19 +226,13 @@ private String getVersion() {
225226

226227
private BunqResponseRaw createBunqResponseRaw(CloseableHttpResponse response)
227228
throws IOException {
228-
byte[] responseBodyBytes = getBodyBytes(response);
229-
230-
return new BunqResponseRaw(responseBodyBytes, getHeadersMap(response));
231-
}
232-
233-
private byte[] getBodyBytes(CloseableHttpResponse response) throws IOException {
234229
Integer responseCode = response.getStatusLine().getStatusCode();
235230
byte[] responseBodyBytes = EntityUtils.toByteArray(response.getEntity());
236231

237232
assertResponseSuccess(responseCode, responseBodyBytes);
238233
validateResponseSignature(responseCode, responseBodyBytes, response);
239234

240-
return responseBodyBytes;
235+
return new BunqResponseRaw(responseBodyBytes, getHeadersMap(response));
241236
}
242237

243238
private static void assertResponseSuccess(int responseCode, byte[] responseBodyBytes) {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.bunq.sdk.json;
2+
3+
import com.bunq.sdk.exception.BunqException;
4+
import com.bunq.sdk.model.core.AnchorObjectInterface;
5+
import com.bunq.sdk.model.core.BunqModel;
6+
import com.google.gson.JsonDeserializationContext;
7+
import com.google.gson.JsonDeserializer;
8+
import com.google.gson.JsonElement;
9+
import com.google.gson.JsonParseException;
10+
import com.google.gson.Gson;
11+
12+
import java.lang.reflect.Field;
13+
import java.lang.reflect.Type;
14+
15+
public class AnchorObjectAdapter implements JsonDeserializer<AnchorObjectInterface> {
16+
@Override
17+
public AnchorObjectInterface deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
18+
throws JsonParseException {
19+
AnchorObjectInterface model = new Gson().fromJson(json, typeOfT);
20+
21+
if (model.isAllFieldNull()) {
22+
Field[] allFields = model.getClass().getDeclaredFields();
23+
24+
for(Field field : allFields) {
25+
if (!BunqModel.class.isAssignableFrom(field.getType())) {
26+
continue;
27+
}
28+
29+
BunqModel content = new Gson().fromJson(json, (Type) field.getType());
30+
field.setAccessible(true);
31+
32+
try {
33+
if (content.isAllFieldNull()) {
34+
field.set(model, null);
35+
} else {
36+
field.set(model, content);
37+
}
38+
} catch (IllegalAccessException e) {
39+
throw new BunqException(e.getMessage());
40+
}
41+
42+
field.setAccessible(false);
43+
}
44+
}
45+
46+
return model;
47+
}
48+
}

src/main/java/com/bunq/sdk/json/BunqGsonBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.bunq.sdk.context.InstallationContext;
44
import com.bunq.sdk.http.Pagination;
5+
import com.bunq.sdk.model.core.AnchorObjectInterface;
56
import com.bunq.sdk.model.core.Installation;
67
import com.bunq.sdk.model.core.MonetaryAccountReference;
78
import com.bunq.sdk.model.core.SessionServer;
@@ -33,7 +34,8 @@ public static GsonBuilder buildDefault() {
3334
new MonetaryAccountReferenceTypeAdapter()
3435
)
3536
.registerTypeAdapter(InstallationContext.class, new InstallationContextAdapter())
36-
.registerTypeAdapter(Pagination.class, new PaginationAdapter());
37+
.registerTypeAdapter(Pagination.class, new PaginationAdapter())
38+
.registerTypeHierarchyAdapter(AnchorObjectInterface.class, new AnchorObjectAdapter());
3739
}
3840

3941
}

src/main/java/com/bunq/sdk/json/GeolocationTypeAdapter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.google.gson.JsonSerializer;
88
import java.lang.reflect.Type;
99
import java.math.BigDecimal;
10-
import javax.annotation.Nullable;
1110

1211
/**
1312
* Custom (de)serialization of Geolocation for GSON, required because Geolocation uses BiDecimal's,
@@ -33,7 +32,6 @@ public JsonElement serialize(Geolocation geolocation, Type typeOfSrc,
3332
return jsonObject;
3433
}
3534

36-
@Nullable
3735
private String getBigDecimalStringOrNull(BigDecimal bigDecimal) {
3836
if (bigDecimal == null) {
3937
return null;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.bunq.sdk.model.core;
2+
3+
public interface AnchorObjectInterface {
4+
/**
5+
*/
6+
boolean isAllFieldNull();
7+
8+
/**
9+
*/
10+
BunqModel getReferencedObject();
11+
}

src/main/java/com/bunq/sdk/model/core/BunqModel.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.google.gson.JsonArray;
99
import com.google.gson.JsonElement;
1010
import com.google.gson.JsonObject;
11+
import com.google.gson.stream.JsonReader;
1112
import java.util.ArrayList;
1213
import java.util.List;
1314

@@ -34,6 +35,15 @@ abstract public class BunqModel {
3435
protected BunqModel() {
3536
}
3637

38+
/**
39+
*/
40+
public static <T> T fromJsonReader(Class<T> tClass, JsonReader reader) {
41+
return gson.fromJson(
42+
reader,
43+
tClass
44+
);
45+
}
46+
3747
/**
3848
* De-serializes an object from a JSON format specific to Installation and SessionServer.
3949
*/
@@ -147,4 +157,8 @@ public String toString() {
147157
return gson.toJson(this);
148158
}
149159

160+
/**
161+
*/
162+
abstract public boolean isAllFieldNull();
163+
150164
}

0 commit comments

Comments
 (0)