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

invokeAPI() --> ApiException() if non HTTP 200 #59

Merged
merged 3 commits into from
Mar 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/com/docusign/esign/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ApiClient {
private String basePath = "https://www.docusign.net/restapi";
private boolean debugging = false;
private int connectionTimeout = 0;
private int readTimeout = 0;

private Client httpClient;
private ObjectMapper mapper;
Expand Down Expand Up @@ -320,6 +321,24 @@ public ApiClient setConnectTimeout(int connectionTimeout) {
return this;
}

/**
* Read timeout (in milliseconds).
*/
public int getReadTimeout() {
return readTimeout;
}

/**
* Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
* {@link Integer#MAX_VALUE}.
*/
public ApiClient setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
httpClient.setReadTimeout(readTimeout);
return this;
}

/**
* Get the date format used to parse/format date parameters.
*/
Expand Down Expand Up @@ -746,6 +765,10 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Objec

ClientResponse response = getAPIResponse(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames);

if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
throw new ApiException("Error while requesting server, received HTTP code: " + response.getStatusInfo().getStatusCode() + " / with response Body: " + response.getEntity(String.class));
}

statusCode = response.getStatusInfo().getStatusCode();
responseHeaders = response.getHeaders();

Expand Down