Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<groupId>com.hellosign</groupId>
<artifactId>hellosign-java-sdk</artifactId>
<packaging>jar</packaging>
<version>4.0.8</version>
<version>4.0.9</version>
<name>HelloSign Java SDK</name>
<url>https://github.com/HelloFax/hellosign-java-sdk</url>
<properties>
<user.name>Chris Paul (chris@hellosign.com)</user.name>
<user.name>HelloSign API Support (apisupport@hellosign.com)</user.name>
<slf4jVersion>1.7.22</slf4jVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<downloadSources>true</downloadSources>
Expand Down
40 changes: 21 additions & 19 deletions src/main/java/com/hellosign/sdk/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* The MIT License (MIT)
*
*
* Copyright (C) 2017 hellosign.com
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -33,9 +33,9 @@

/**
* The MIT License (MIT)
*
*
* Copyright (C) 2016 hellosign.com
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -73,7 +73,7 @@

/**
* Abstracts HTTP requests.
*
*
* @author cpaul
*/
public class HttpClient {
Expand Down Expand Up @@ -125,7 +125,7 @@ public HttpClient withPostFields(Map<String, Serializable> fields) {

/**
* Returns the response to the last HTTP request as a string.
*
*
* @return String or null if the request has not been created
*/
public String getLastResponse() {
Expand All @@ -137,7 +137,7 @@ public String getLastResponse() {

/**
* Returns the HTTP status code for the last request.
*
*
* @return Integer or null if the request has not been created
*/
public Integer getLastResponseCode() {
Expand All @@ -149,7 +149,7 @@ public Integer getLastResponseCode() {

/**
* Returns the last HTTP request body as a file.
*
*
* @param f File that should contain the response
* @return long bytes written
* @throws HelloSignException thrown if there is a problem writing to the
Expand All @@ -162,7 +162,7 @@ public long getLastResponseAsFile(File f) throws HelloSignException {
/**
* Inspects the JSONObject response for errors and throws an exception if
* found.
*
*
* @param json JSONObject response
* @param code HTTP response code
* @throws HelloSignException thrown if an error is reported from the API
Expand Down Expand Up @@ -193,7 +193,7 @@ private void reset() {

/**
* Executes the request and returns the response as a JSONObject.
*
*
* @return JSONObject response
* @throws HelloSignException thrown if there is a problem executing the
* request
Expand All @@ -204,18 +204,20 @@ public JSONObject asJson() throws HelloSignException {
logger.debug("Response body: " + response);
try {
json = new JSONObject(response);
validate(json);
} catch (HelloSignException e) {
throw e;
} catch (JSONException e) {
throw new HelloSignException(e);
} finally {
reset();
}
validate(json);
return json;
}

/**
* Executes the request and returns the response as a File.
*
*
* @param fileName String name of destination file
* @return File response
* @throws HelloSignException thrown if there is a problem executing the
Expand All @@ -242,7 +244,7 @@ public File asFile(String fileName) throws HelloSignException {

/**
* Helper method to create a temporary file.
*
*
* @param filename String
* @return File temporary file handle
* @throws HelloSignException thrown if the file cannot be created
Expand All @@ -264,7 +266,7 @@ private File createTemporaryFile(String filename) throws HelloSignException {

/**
* Executes the request and returns the HTTP response code.
*
*
* @return int HTTP response code
* @throws HelloSignException thrown if no request has been performed
*/
Expand All @@ -282,7 +284,7 @@ public int asHttpCode() throws HelloSignException {

/**
* Initializes a GET request to the given URL.
*
*
* @param url String url
* @return HttpClient
* @throws HelloSignException thrown if the url is invalid
Expand All @@ -298,7 +300,7 @@ public HttpClient get(String url) throws HelloSignException {

/**
* Initializes a POST request to the given URL.
*
*
* @param url String url
* @return HttpClient
* @throws HelloSignException thrown if the url is invalid
Expand All @@ -314,7 +316,7 @@ public HttpClient post(String url) throws HelloSignException {

/**
* Initializes a DELETE request to the given URL.
*
*
* @param url String url
* @return HttpClient
* @throws HelloSignException thrown if the url is invalid
Expand All @@ -327,7 +329,7 @@ public HttpClient delete(String url) throws HelloSignException {

/**
* Makes a PUT request to the given URL
*
*
* @param url String url
* @return HttpClient
* @throws HelloSignException thrown if the url is invalid
Expand All @@ -340,7 +342,7 @@ public HttpClient put(String url) throws HelloSignException {

/**
* Makes an OPTIONS request to the given URL
*
*
* @param url String URL
* @return HttpClient
* @throws HelloSignException thrown if the URL is invalid
Expand Down