Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Commit c6708ed

Browse files
Merge pull request #73 from radhack/issue-66
Issue 66
2 parents 7d5d996 + ce0daa8 commit c6708ed

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<groupId>com.hellosign</groupId>
66
<artifactId>hellosign-java-sdk</artifactId>
77
<packaging>jar</packaging>
8-
<version>4.0.8</version>
8+
<version>4.0.9</version>
99
<name>HelloSign Java SDK</name>
1010
<url>https://github.com/HelloFax/hellosign-java-sdk</url>
1111
<properties>
12-
<user.name>Chris Paul (chris@hellosign.com)</user.name>
12+
<user.name>HelloSign API Support (apisupport@hellosign.com)</user.name>
1313
<slf4jVersion>1.7.22</slf4jVersion>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<downloadSources>true</downloadSources>

src/main/java/com/hellosign/sdk/http/HttpClient.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

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

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

7474
/**
7575
* Abstracts HTTP requests.
76-
*
76+
*
7777
* @author cpaul
7878
*/
7979
public class HttpClient {
@@ -125,7 +125,7 @@ public HttpClient withPostFields(Map<String, Serializable> fields) {
125125

126126
/**
127127
* Returns the response to the last HTTP request as a string.
128-
*
128+
*
129129
* @return String or null if the request has not been created
130130
*/
131131
public String getLastResponse() {
@@ -137,7 +137,7 @@ public String getLastResponse() {
137137

138138
/**
139139
* Returns the HTTP status code for the last request.
140-
*
140+
*
141141
* @return Integer or null if the request has not been created
142142
*/
143143
public Integer getLastResponseCode() {
@@ -149,7 +149,7 @@ public Integer getLastResponseCode() {
149149

150150
/**
151151
* Returns the last HTTP request body as a file.
152-
*
152+
*
153153
* @param f File that should contain the response
154154
* @return long bytes written
155155
* @throws HelloSignException thrown if there is a problem writing to the
@@ -162,7 +162,7 @@ public long getLastResponseAsFile(File f) throws HelloSignException {
162162
/**
163163
* Inspects the JSONObject response for errors and throws an exception if
164164
* found.
165-
*
165+
*
166166
* @param json JSONObject response
167167
* @param code HTTP response code
168168
* @throws HelloSignException thrown if an error is reported from the API
@@ -193,7 +193,7 @@ private void reset() {
193193

194194
/**
195195
* Executes the request and returns the response as a JSONObject.
196-
*
196+
*
197197
* @return JSONObject response
198198
* @throws HelloSignException thrown if there is a problem executing the
199199
* request
@@ -204,18 +204,20 @@ public JSONObject asJson() throws HelloSignException {
204204
logger.debug("Response body: " + response);
205205
try {
206206
json = new JSONObject(response);
207+
validate(json);
208+
} catch (HelloSignException e) {
209+
throw e;
207210
} catch (JSONException e) {
208211
throw new HelloSignException(e);
209212
} finally {
210213
reset();
211214
}
212-
validate(json);
213215
return json;
214216
}
215217

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

243245
/**
244246
* Helper method to create a temporary file.
245-
*
247+
*
246248
* @param filename String
247249
* @return File temporary file handle
248250
* @throws HelloSignException thrown if the file cannot be created
@@ -264,7 +266,7 @@ private File createTemporaryFile(String filename) throws HelloSignException {
264266

265267
/**
266268
* Executes the request and returns the HTTP response code.
267-
*
269+
*
268270
* @return int HTTP response code
269271
* @throws HelloSignException thrown if no request has been performed
270272
*/
@@ -282,7 +284,7 @@ public int asHttpCode() throws HelloSignException {
282284

283285
/**
284286
* Initializes a GET request to the given URL.
285-
*
287+
*
286288
* @param url String url
287289
* @return HttpClient
288290
* @throws HelloSignException thrown if the url is invalid
@@ -298,7 +300,7 @@ public HttpClient get(String url) throws HelloSignException {
298300

299301
/**
300302
* Initializes a POST request to the given URL.
301-
*
303+
*
302304
* @param url String url
303305
* @return HttpClient
304306
* @throws HelloSignException thrown if the url is invalid
@@ -314,7 +316,7 @@ public HttpClient post(String url) throws HelloSignException {
314316

315317
/**
316318
* Initializes a DELETE request to the given URL.
317-
*
319+
*
318320
* @param url String url
319321
* @return HttpClient
320322
* @throws HelloSignException thrown if the url is invalid
@@ -327,7 +329,7 @@ public HttpClient delete(String url) throws HelloSignException {
327329

328330
/**
329331
* Makes a PUT request to the given URL
330-
*
332+
*
331333
* @param url String url
332334
* @return HttpClient
333335
* @throws HelloSignException thrown if the url is invalid
@@ -340,7 +342,7 @@ public HttpClient put(String url) throws HelloSignException {
340342

341343
/**
342344
* Makes an OPTIONS request to the given URL
343-
*
345+
*
344346
* @param url String URL
345347
* @return HttpClient
346348
* @throws HelloSignException thrown if the URL is invalid

0 commit comments

Comments
 (0)