Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced httpclient with Okhttp. (bunq/sdk_java#25) #73

Merged
merged 10 commits into from
Feb 15, 2018
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
// https://mvnrepository.com/artifact/org.apache.commons/commons-io
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
// https://mvnrepository.com/artifact/com.squareup.okio/okio
compile group: 'com.squareup.okio', name: 'okio', version: '1.13.0'
}

apply plugin: 'idea'
apply plugin: 'idea'
7 changes: 5 additions & 2 deletions src/main/java/com/bunq/sdk/context/ApiContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.google.gson.annotations.SerializedName;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -275,10 +274,14 @@ public String toJson() {
/**
* @return The base URI of the current environment.
*/
public URI getBaseUri() {
public String getBaseUri() {
return environmentType.getBaseUri();
}

public String getApiVersoin() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

return environmentType.getApiVersion();
}

/**
* @return The session token, installation token if the session isn't created yet, or null if no
* installation is created either.
Expand Down
24 changes: 11 additions & 13 deletions src/main/java/com/bunq/sdk/context/ApiEnvironmentType.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
package com.bunq.sdk.context;

import com.bunq.sdk.exception.UncaughtExceptionError;
import java.net.URI;
import java.net.URISyntaxException;

/**
* Enum for the API environment types and their URIs.
*/
public enum ApiEnvironmentType {

PRODUCTION("https://api.bunq.com/v1/"),
SANDBOX("https://sandbox.public.api.bunq.com/v1/");
PRODUCTION("api.bunq.com", "v1"),
SANDBOX("sandbox.public.api.bunq.com", "v1");

/**
* Base URI of each given environment.
*/
private String baseUri;
private String apiVersion;

ApiEnvironmentType(String baseUri) {
ApiEnvironmentType(String baseUri, String apiVersion) {
this.baseUri = baseUri;
this.apiVersion = apiVersion;
}

/**
* @return Base URI of the environment.
*/
URI getBaseUri() {
try {
return new URI(this.baseUri);
} catch (URISyntaxException exception) {
throw new UncaughtExceptionError(exception);
}
String getBaseUri() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended to be default access instead of private public or protected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, so that it can only be accessed publicly via ApiContext.

return this.baseUri;
}

String getApiVersion() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

return this.apiVersion;
}

}
Loading