Skip to content

Commit 8cc89ae

Browse files
committed
Cleaned up code. Removed blank lines, formatted whitespace to be consistent across all files, made private variables final as necessary, etc.
1 parent b224e96 commit 8cc89ae

Some content is hidden

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

55 files changed

+3126
-3179
lines changed

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

Lines changed: 360 additions & 359 deletions
Large diffs are not rendered by default.

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

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,42 @@
55
*/
66
public enum ApiEnvironmentType {
77

8-
PRODUCTION(
9-
"api.bunq.com",
10-
"v1",
11-
"sha256/nI/T/sDfioCBHB5mVppDPyLi2HXYanwk2arpZuHLOu0="
12-
),
13-
SANDBOX(
14-
"public-api.sandbox.bunq.com",
15-
"v1",
16-
"sha256/SEJfjAW74vHQmGe/lb9NwBjzAw5y7rpJH3UWpGE5q8A="
17-
);
18-
19-
/**
20-
* Base URI of each given environment.
21-
*/
22-
private final String baseUri;
23-
private final String apiVersion;
24-
private final String pinnedKey;
25-
26-
ApiEnvironmentType(String baseUri, String apiVersion, String pinnedKey) {
27-
this.baseUri = baseUri;
28-
this.apiVersion = apiVersion;
29-
this.pinnedKey = pinnedKey;
30-
}
31-
32-
/**
33-
* @return Base URI of the environment.
34-
*/
35-
public String getBaseUri() {
36-
return this.baseUri;
37-
}
38-
39-
public String getApiVersion() {
40-
return this.apiVersion;
41-
}
42-
43-
public String getPinnedKey() {
44-
return pinnedKey;
45-
}
46-
8+
PRODUCTION(
9+
"api.bunq.com",
10+
"v1",
11+
"sha256/nI/T/sDfioCBHB5mVppDPyLi2HXYanwk2arpZuHLOu0="
12+
),
13+
SANDBOX(
14+
"public-api.sandbox.bunq.com",
15+
"v1",
16+
"sha256/SEJfjAW74vHQmGe/lb9NwBjzAw5y7rpJH3UWpGE5q8A="
17+
);
18+
19+
/**
20+
* Base URI of each given environment.
21+
*/
22+
private final String baseUri;
23+
private final String apiVersion;
24+
private final String pinnedKey;
25+
26+
ApiEnvironmentType(String baseUri, String apiVersion, String pinnedKey) {
27+
this.baseUri = baseUri;
28+
this.apiVersion = apiVersion;
29+
this.pinnedKey = pinnedKey;
30+
}
31+
32+
/**
33+
* @return Base URI of the environment.
34+
*/
35+
public String getBaseUri() {
36+
return this.baseUri;
37+
}
38+
39+
public String getApiVersion() {
40+
return this.apiVersion;
41+
}
42+
43+
public String getPinnedKey() {
44+
return pinnedKey;
45+
}
4746
}

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@
44

55
public final class BunqContext {
66

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);
19-
}
20-
21-
public static ApiContext getApiContext() {
22-
if (BunqContext.apiContext == null) {
23-
throw new BunqException(ERROR_API_CONTEXT_HAS_NOT_BEEN_SET);
7+
/**
8+
* Error constants.
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);
2419
}
2520

26-
return BunqContext.apiContext;
27-
}
21+
public static ApiContext getApiContext() {
22+
if (BunqContext.apiContext == null) {
23+
throw new BunqException(ERROR_API_CONTEXT_HAS_NOT_BEEN_SET);
24+
}
2825

29-
public static UserContext getUserContext() {
30-
if (BunqContext.userContext == null) {
31-
throw new BunqException(ERROR_USER_CONTEXT_HAS_NOT_BEEN_SET);
26+
return BunqContext.apiContext;
3227
}
3328

34-
return BunqContext.userContext;
35-
}
29+
public static UserContext getUserContext() {
30+
if (BunqContext.userContext == null) {
31+
throw new BunqException(ERROR_USER_CONTEXT_HAS_NOT_BEEN_SET);
32+
}
3633

37-
public static void updateApiContext(ApiContext apiContext) {
38-
if (BunqContext.apiContext == null) {
39-
throw new BunqException(ERROR_API_CONTEXT_HAS_NOT_BEEN_SET);
34+
return BunqContext.userContext;
4035
}
4136

42-
BunqContext.apiContext = apiContext;
43-
}
37+
public static void updateApiContext(ApiContext apiContext) {
38+
if (BunqContext.apiContext == null) {
39+
throw new BunqException(ERROR_API_CONTEXT_HAS_NOT_BEEN_SET);
40+
}
41+
42+
BunqContext.apiContext = apiContext;
43+
}
4444
}

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

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

33
import com.bunq.sdk.model.core.Installation;
44
import com.bunq.sdk.security.SecurityUtils;
5+
56
import java.security.KeyPair;
67
import java.security.PublicKey;
78

@@ -10,38 +11,37 @@
1011
*/
1112
public class InstallationContext implements java.io.Serializable {
1213

13-
private String token;
14-
private KeyPair keyPairClient;
15-
private PublicKey publicKeyServer;
16-
17-
InstallationContext(Installation installation, KeyPair keyPairClient) {
18-
this(installation.getSessionToken().getToken(), keyPairClient,
19-
SecurityUtils.createPublicKeyFromFormattedString(installation.getPublicKeyServer())
20-
);
21-
}
22-
23-
/**
24-
* @param token Installation token returned as a response to the POST /installation
25-
* @param keyPairClient Client key pair generated by SDK (Private + Public)
26-
* @param publicKeyServer Server public key returned as a response to the POST /installation
27-
*/
28-
public InstallationContext(String token, KeyPair keyPairClient,
29-
PublicKey publicKeyServer) {
30-
this.token = token;
31-
this.keyPairClient = keyPairClient;
32-
this.publicKeyServer = publicKeyServer;
33-
}
34-
35-
public String getToken() {
36-
return token;
37-
}
38-
39-
public KeyPair getKeyPairClient() {
40-
return keyPairClient;
41-
}
42-
43-
public PublicKey getPublicKeyServer() {
44-
return publicKeyServer;
45-
}
46-
14+
private final String token;
15+
private final KeyPair keyPairClient;
16+
private final PublicKey publicKeyServer;
17+
18+
InstallationContext(Installation installation, KeyPair keyPairClient) {
19+
this(installation.getSessionToken().getToken(), keyPairClient,
20+
SecurityUtils.createPublicKeyFromFormattedString(installation.getPublicKeyServer())
21+
);
22+
}
23+
24+
/**
25+
* @param token Installation token returned as a response to the POST /installation
26+
* @param keyPairClient Client key pair generated by SDK (Private + Public)
27+
* @param publicKeyServer Server public key returned as a response to the POST /installation
28+
*/
29+
public InstallationContext(String token, KeyPair keyPairClient,
30+
PublicKey publicKeyServer) {
31+
this.token = token;
32+
this.keyPairClient = keyPairClient;
33+
this.publicKeyServer = publicKeyServer;
34+
}
35+
36+
public String getToken() {
37+
return token;
38+
}
39+
40+
public KeyPair getKeyPairClient() {
41+
return keyPairClient;
42+
}
43+
44+
public PublicKey getPublicKeyServer() {
45+
return publicKeyServer;
46+
}
4747
}

0 commit comments

Comments
 (0)