diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41440c5..5cccdc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Trulioo SDK for Java Changelog
+## Version 1.0.4
+
+Support application/pdf in documentDownload
+
## Version 1.0.3
Changed type of Model/AppendedField's Data from string to Object in order to allow WatchListDetails, returned as Map, parsable.
diff --git a/README.md b/README.md
index 7b0fd72..76197fb 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Trulioo SDK for Java #
-## Version 1.0.3
+## Version 1.0.4
### Introduction
@@ -51,7 +51,7 @@ Add this dependency to your project's POM:
com.trulioo
normalizedapi
- 1.0.3
+ 1.0.4
compile
```
@@ -61,7 +61,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
-compile "com.trulioo:normalizedapi:1.0.3"
+compile "com.trulioo:normalizedapi:1.0.4"
```
### Others
@@ -74,7 +74,7 @@ mvn clean package
Then manually install the following JARs:
-* `target/normalizedapi-1.0.3.jar`
+* `target/normalizedapi-1.0.4.jar`
* `target/lib/*.jar`
## Getting Started
diff --git a/build.gradle b/build.gradle
index 6aa7d6a..9202a2c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ apply plugin: 'eclipse'
apply plugin: 'java'
group = 'com.trulioo'
-version = 'v1.0.3.0'
+version = 'v1.0.4.0'
buildscript {
repositories {
diff --git a/build.sbt b/build.sbt
index d5bdc02..108fffb 100644
--- a/build.sbt
+++ b/build.sbt
@@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
settings(
organization := "com.trulioo",
name := "normalizedapi",
- version := "1.0.3",
+ version := "1.0.4",
scalaVersion := "2.11.4",
scalacOptions ++= Seq("-feature"),
javacOptions in compile ++= Seq("-Xlint:deprecation"),
diff --git a/pom.xml b/pom.xml
index 750b86e..25b745c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
normalizedapi
jar
Trulioo Normalized API
- 1.0.3
+ 1.0.4
https://api.globaldatacompany.com/docs
Trulioo provides a collection of API methods to help you build business processes powered by the
GlobalGateway Normalized API.
diff --git a/src/main/java/com/trulioo/normalizedapi/ApiClient.java b/src/main/java/com/trulioo/normalizedapi/ApiClient.java
index 6159446..b9c16a6 100644
--- a/src/main/java/com/trulioo/normalizedapi/ApiClient.java
+++ b/src/main/java/com/trulioo/normalizedapi/ApiClient.java
@@ -749,6 +749,15 @@ public boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
}
+
+ /**
+ * Check if the given MIME is application/pdf
+ * @param mime MIME (Multipurpose Internet Mail Extensions)
+ * @return True if the given MIME is application/pdf
+ */
+ public boolean isPDF(String mime) {
+ return mime != null && (mime.matches("(?i)(^)application\\/pdf($)"));
+ }
/**
* Select the Accept header's value from the given accepts array:
@@ -822,6 +831,12 @@ public T deserialize(Response response, Type returnType) throws ApiException
if (response == null || returnType == null) {
return null;
}
+
+ String contentType = response.headers().get("Content-Type");
+ if (contentType == null) {
+ // ensuring a default content type
+ contentType = "application/json";
+ }
if ("byte[]".equals(returnType.toString())) {
// Handle binary response (byte array).
@@ -830,7 +845,7 @@ public T deserialize(Response response, Type returnType) throws ApiException
} catch (IOException e) {
throw new ApiException(e);
}
- } else if (returnType.equals(File.class)) {
+ } else if (returnType.equals(File.class) || isPDF(contentType)) {
// Handle file downloading.
return (T) downloadFileFromResponse(response);
}
@@ -849,11 +864,6 @@ public T deserialize(Response response, Type returnType) throws ApiException
return null;
}
- String contentType = response.headers().get("Content-Type");
- if (contentType == null) {
- // ensuring a default content type
- contentType = "application/json";
- }
if (isJsonMime(contentType)) {
return json.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
diff --git a/src/main/java/com/trulioo/normalizedapi/api/VerificationsApi.java b/src/main/java/com/trulioo/normalizedapi/api/VerificationsApi.java
index ab916c8..5f08ea8 100644
--- a/src/main/java/com/trulioo/normalizedapi/api/VerificationsApi.java
+++ b/src/main/java/com/trulioo/normalizedapi/api/VerificationsApi.java
@@ -94,7 +94,7 @@ public okhttp3.Call documentDownloadCall(String transactionRecordId, String fiel
localVarHeaderParams.put("Content-Type", localVarContentType);
if(progressListener != null) {
- apiClient.getHttpClient().networkInterceptors().add(new okhttp3.Interceptor() {
+ apiClient.getHttpClient().newBuilder().addNetworkInterceptor(new okhttp3.Interceptor() {
@Override
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
okhttp3.Response originalResponse = chain.proceed(chain.request());