Skip to content

Commit c043e45

Browse files
author
Kevin Hellemun
committed
Merge branch 'release/0.13.0'
2 parents bde22f2 + 4192d25 commit c043e45

File tree

179 files changed

+9372
-2884
lines changed

Some content is hidden

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

179 files changed

+9372
-2884
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
## What happens:
88
1.
99

10-
## Logs
11-
- Logs
10+
## Traceback
11+
[//]: # (If there is a traceback please share it in a quote! You can do this by pasting the traceback text, highlighting it and pressing the quote button.)
1212

13-
## Extra info:
14-
- Tested on
13+
## SDK version and environment
14+
- Tested on [0.12.4](https://github.com/bunq/sdk_java/releases/tag/0.12.4)
15+
- [ ] Sandbox
16+
- [ ] Production
17+
18+
## Response id
19+
[//]: # (If this error has something to do with a request that fails, please provide the response id of the request.)
20+
- Response id:
1521

22+
## Extra info:
23+
[//]: # (Please provide any other relevant information here)

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[//]: # (Thanks for opening this pull request! Before you proceed please make sure that you have an issue that explains what this pull request will do.
2+
Make sure that all your commits link to this issue e.g. "My commit. \(bunq/sdk_java#<issue nr>\)".
3+
If this pull request is changing files that are located in "com.bunq.sdk.model.generated" then this pull request will be closed as these files must/can only be changed on bunq's side.)
4+
5+
## This PR closes/fixes the following issues:
6+
[//]: # (If for some reason your pull request does not require a test case you can just mark this box as checked and explain why it does not require a test case.)
7+
- Closes bunq/sdk_java#
8+
- [ ] Tested

.zappr.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
autobranch:
2+
pattern: 'bunq/sdk_java#{number}-{title}'
3+
length: 100
4+
commit:
5+
message:
6+
patterns:
7+
- '([A-Za-z0-9 ]+)\. (\(bunq\/sdk_java#[0-9]+\))'
8+
specification:
9+
title:
10+
minimum-length:
11+
enabled: true
12+
length: 8
13+
body:
14+
minimum-length:
15+
enabled: true
16+
length: 8
17+
contains-url: true
18+
contains-issue-number: true
19+
template:
20+
differs-from-body: true
21+
pull-request:
22+
labels:
23+
additional: true
24+
required:
25+
- Can be merged

CHANGELOG.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
# Change Log
22

3+
## [0.13.0](https://github.com/bunq/sdk_java/tree/0.13.0) [(2017-12-21)](https://github.com/bunq/sdk_java/tree/0.13.0)
4+
5+
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.4...0.13.0)
6+
7+
**Implemented enhancements:**
8+
9+
- Add zappr integration for better quality control  [\#58](https://github.com/bunq/sdk_java/issues/58)
10+
- Add more information to templates [\#56](https://github.com/bunq/sdk_java/issues/56)
11+
- Add response id to error messages from failed requests  [\#55](https://github.com/bunq/sdk_java/issues/55)
12+
13+
**Fixed bugs:**
14+
15+
- Token request ideal is missing id attribute in response. [\#65](https://github.com/bunq/sdk_java/issues/65)
16+
- getCounterpartyAlias\(\) returns null on payments [\#49](https://github.com/bunq/sdk_java/issues/49)
17+
- Field ID is missing from MasterCardAction [\#48](https://github.com/bunq/sdk_java/issues/48)
18+
- TokenQrRequestIdeal returns the wrong type [\#47](https://github.com/bunq/sdk_java/issues/47)
19+
- Cannot list draft payments for monetary account [\#46](https://github.com/bunq/sdk_java/issues/46)
20+
21+
**Closed issues:**
22+
23+
- bunq update 7 [\#75](https://github.com/bunq/sdk_java/issues/75)
24+
- Serialization Error [\#71](https://github.com/bunq/sdk_java/issues/71)
25+
- Clean dependencies [\#25](https://github.com/bunq/sdk_java/issues/25)
26+
27+
**Merged pull requests:**
28+
29+
- Bunq update 7 [\#76](https://github.com/bunq/sdk_java/pull/76) ([OGKevin](https://github.com/OGKevin))
30+
- Regenerate code for release [\#74](https://github.com/bunq/sdk_java/pull/74) ([OGKevin](https://github.com/OGKevin))
31+
- Replaced httpclient with Okhttp. \(bunq/sdk\_java\#25\) [\#73](https://github.com/bunq/sdk_java/pull/73) ([OGKevin](https://github.com/OGKevin))
32+
- Regenerated code to add corerct object types. \(bunq/sdk\_java\#47\) [\#70](https://github.com/bunq/sdk_java/pull/70) ([OGKevin](https://github.com/OGKevin))
33+
- Fixed MonetaryAccountReferenceTypeAdapter to output proper value. \(bunq/sdk\_java\#49\) [\#68](https://github.com/bunq/sdk_java/pull/68) ([OGKevin](https://github.com/OGKevin))
34+
- Added missing field id for TokenQrRequestIdeal. \(bunq/sdk\_java\#65\) [\#67](https://github.com/bunq/sdk_java/pull/67) ([OGKevin](https://github.com/OGKevin))
35+
- Cannot list payments due to geolocation. \(Bunq/sdk\_java\#46 \) [\#64](https://github.com/bunq/sdk_java/pull/64) ([OGKevin](https://github.com/OGKevin))
36+
- Get counterparty alias returns null on payments. \(Bunq/sdk\_java\#49 \) [\#63](https://github.com/bunq/sdk_java/pull/63) ([OGKevin](https://github.com/OGKevin))
37+
- Added missing id field from mastercard action. \(bunq/sdk\_java\#48\) [\#62](https://github.com/bunq/sdk_java/pull/62) ([OGKevin](https://github.com/OGKevin))
38+
- \(bunq/sdk\_java\#55\) add response id to request error [\#61](https://github.com/bunq/sdk_java/pull/61) ([OGKevin](https://github.com/OGKevin))
39+
- Configure Zappr [\#59](https://github.com/bunq/sdk_java/pull/59) ([OGKevin](https://github.com/OGKevin))
40+
- Improve issue and pr template. \(bunq/sdk\_java\#56\) [\#57](https://github.com/bunq/sdk_java/pull/57) ([OGKevin](https://github.com/OGKevin))
41+
342
## [0.12.4](https://github.com/bunq/sdk_java/tree/0.12.4) (2017-12-21)
443
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.3...0.12.4)
544

@@ -11,18 +50,18 @@
1150
- Return base class from createFromJsonString [\#40](https://github.com/bunq/sdk_java/issues/40)
1251
- CHANGELOG.md is empty [\#38](https://github.com/bunq/sdk_java/issues/38)
1352
- Improve decoder to recognise child object [\#35](https://github.com/bunq/sdk_java/issues/35)
53+
- Removed guava as dependency. \(bunq/sdk\_java\#41\) [\#44](https://github.com/bunq/sdk_java/pull/44) ([OGKevin](https://github.com/OGKevin))
54+
- Generated CHANGELOG.md :clap:. \(bunq/sdk\_java\#38\) [\#39](https://github.com/bunq/sdk_java/pull/39) ([OGKevin](https://github.com/OGKevin))
1455

1556
**Fixed bugs:**
1657

1758
- Remove guava  [\#41](https://github.com/bunq/sdk_java/issues/41)
59+
- Removed guava as dependency. \\(bunq/sdk\\_java\\#41\\) [\#44](https://github.com/bunq/sdk_java/pull/44) ([OGKevin](https://github.com/OGKevin))
1860

1961
**Merged pull requests:**
2062

2163
- 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))
2264
- 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))
2665

2766
## [0.12.3](https://github.com/bunq/sdk_java/tree/0.12.3) (2017-11-15)
2867
[Full Changelog](https://github.com/bunq/sdk_java/compare/0.12.2...0.12.3)

build.gradle

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

44
apply plugin: 'java'
55
apply plugin: 'maven'
@@ -14,12 +14,11 @@ dependencies {
1414
testCompile group: 'junit', name: 'junit', version: '4.12'
1515
// https://mvnrepository.com/artifact/com.google.code.gson/gson
1616
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
17-
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
18-
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
17+
compile 'com.squareup.okhttp3:okhttp:3.9.1'
1918
// https://mvnrepository.com/artifact/org.apache.commons/commons-io
2019
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
2120
// https://mvnrepository.com/artifact/com.squareup.okio/okio
2221
compile group: 'com.squareup.okio', name: 'okio', version: '1.13.0'
2322
}
2423

25-
apply plugin: 'idea'
24+
apply plugin: 'idea'

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.bunq.sdk.exception.BunqException;
44
import com.bunq.sdk.json.BunqGsonBuilder;
5+
import com.bunq.sdk.model.core.DeviceServerInternal;
56
import com.bunq.sdk.model.core.Installation;
67
import com.bunq.sdk.model.core.SessionServer;
78
import com.bunq.sdk.model.generated.endpoint.DeviceServer;
@@ -12,7 +13,6 @@
1213
import com.google.gson.annotations.SerializedName;
1314
import java.io.File;
1415
import java.io.IOException;
15-
import java.net.URI;
1616
import java.security.KeyPair;
1717
import java.util.ArrayList;
1818
import java.util.Date;
@@ -178,19 +178,7 @@ private void initializeInstallation() {
178178
}
179179

180180
private void initializeDeviceRegistration(String deviceDescription, List<String> permittedIps) {
181-
Map<String, Object> deviceServerRequestBody = generateDeviceServerRequestBodyBytes(
182-
deviceDescription, permittedIps);
183-
DeviceServer.create(this, deviceServerRequestBody);
184-
}
185-
186-
private Map<String, Object> generateDeviceServerRequestBodyBytes(String description,
187-
List<String> permittedIps) {
188-
HashMap<String, Object> deviceServerRequestBody = new HashMap<>();
189-
deviceServerRequestBody.put(DeviceServer.FIELD_DESCRIPTION, description);
190-
deviceServerRequestBody.put(DeviceServer.FIELD_SECRET, apiKey);
191-
deviceServerRequestBody.put(DeviceServer.FIELD_PERMITTED_IPS, permittedIps);
192-
193-
return deviceServerRequestBody;
181+
DeviceServerInternal.create(this, deviceDescription, this.apiKey, permittedIps);
194182
}
195183

196184
/**
@@ -221,7 +209,7 @@ public void closeSession() {
221209
}
222210

223211
private void deleteSession() {
224-
Session.delete(this, SESSION_ID_DUMMY);
212+
Session.delete(SESSION_ID_DUMMY);
225213
}
226214

227215
/**
@@ -275,10 +263,14 @@ public String toJson() {
275263
/**
276264
* @return The base URI of the current environment.
277265
*/
278-
public URI getBaseUri() {
266+
public String getBaseUri() {
279267
return environmentType.getBaseUri();
280268
}
281269

270+
public String getApiVersion() {
271+
return environmentType.getApiVersion();
272+
}
273+
282274
/**
283275
* @return The session token, installation token if the session isn't created yet, or null if no
284276
* installation is created either.
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
package com.bunq.sdk.context;
22

3-
import com.bunq.sdk.exception.UncaughtExceptionError;
4-
import java.net.URI;
5-
import java.net.URISyntaxException;
6-
73
/**
84
* Enum for the API environment types and their URIs.
95
*/
106
public enum ApiEnvironmentType {
117

12-
PRODUCTION("https://api.bunq.com/v1/"),
13-
SANDBOX("https://sandbox.public.api.bunq.com/v1/");
8+
PRODUCTION("api.bunq.com", "v1"),
9+
SANDBOX("sandbox.public.api.bunq.com", "v1");
1410

1511
/**
1612
* Base URI of each given environment.
1713
*/
1814
private String baseUri;
15+
private String apiVersion;
1916

20-
ApiEnvironmentType(String baseUri) {
17+
ApiEnvironmentType(String baseUri, String apiVersion) {
2118
this.baseUri = baseUri;
19+
this.apiVersion = apiVersion;
2220
}
2321

2422
/**
2523
* @return Base URI of the environment.
2624
*/
27-
URI getBaseUri() {
28-
try {
29-
return new URI(this.baseUri);
30-
} catch (URISyntaxException exception) {
31-
throw new UncaughtExceptionError(exception);
32-
}
25+
String getBaseUri() {
26+
return this.baseUri;
27+
}
28+
29+
String getApiVersion() {
30+
return this.apiVersion;
3331
}
3432

3533
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.bunq.sdk.context;
2+
3+
import com.bunq.sdk.exception.BunqException;
4+
5+
public final class BunqContext {
6+
7+
/**
8+
* Error constatns.
9+
*/
10+
private static final String ERROR_API_CONTEXT_HAS_NOT_BEEN_SET = "Api context has not been set";
11+
private static final String ERROR_USER_CONTEXT_HAS_NOT_BEEN_SET = "UserContext has not been set";
12+
13+
private static ApiContext apiContext;
14+
private static UserContext userContext;
15+
16+
public static void loadApiContext(ApiContext apiContext) {
17+
BunqContext.apiContext = apiContext;
18+
BunqContext.userContext = new UserContext(apiContext.getSessionContext().getUserId());
19+
BunqContext.userContext.initMainMonetaryAccount();
20+
}
21+
22+
public static ApiContext getApiContext() {
23+
if (apiContext == null) {
24+
throw new BunqException(ERROR_API_CONTEXT_HAS_NOT_BEEN_SET);
25+
}
26+
27+
return apiContext;
28+
}
29+
30+
public static UserContext getUserContext() {
31+
if (userContext == null) {
32+
throw new BunqException(ERROR_USER_CONTEXT_HAS_NOT_BEEN_SET);
33+
}
34+
35+
return userContext;
36+
}
37+
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.bunq.sdk.context;
22

3+
import com.bunq.sdk.exception.BunqException;
4+
import com.bunq.sdk.model.core.BunqModel;
35
import com.bunq.sdk.model.core.SessionServer;
46
import com.bunq.sdk.model.generated.endpoint.UserCompany;
57
import com.bunq.sdk.model.generated.endpoint.UserPerson;
@@ -12,6 +14,11 @@
1214
*/
1315
class SessionContext implements java.io.Serializable {
1416

17+
/**
18+
* Error constants.
19+
*/
20+
private static final String ERROR_UNEXPECTED_USER_TYPE = "Unexpected user type.";
21+
1522
/**
1623
* Default assumed value for session timeout.
1724
*/
@@ -36,12 +43,27 @@ class SessionContext implements java.io.Serializable {
3643
@SerializedName("expiry_time")
3744
private Date expiryTime;
3845

46+
@Expose
47+
@SerializedName("user_id")
48+
private Integer userId;
49+
3950
/**
4051
* @param sessionServer Object containing the session info.
4152
*/
4253
SessionContext(SessionServer sessionServer) {
4354
this.token = sessionServer.getSessionToken().getToken();
4455
this.expiryTime = calculateExpiryTime(sessionServer);
56+
this.userId = getUserId(sessionServer.getReferencedObject());
57+
}
58+
59+
private Integer getUserId(BunqModel user) {
60+
if (user instanceof UserPerson) {
61+
return ((UserPerson) user).getId();
62+
} else if (user instanceof UserCompany) {
63+
return ((UserCompany) user).getId();
64+
} else {
65+
throw new BunqException(ERROR_UNEXPECTED_USER_TYPE);
66+
}
4567
}
4668

4769
private static Date calculateExpiryTime(SessionServer sessionServer) {
@@ -76,4 +98,8 @@ Date getExpiryTime() {
7698
return expiryTime;
7799
}
78100

101+
public Integer getUserId() {
102+
return userId;
103+
}
104+
79105
}

0 commit comments

Comments
 (0)