Skip to content

Commit 87675ee

Browse files
Merge pull request #22 from maximn/client_another_ctor
Allow setting both `apache http client` and `test` parameters
2 parents 99c1639 + d186c7f commit 87675ee

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/main/java/com/sendgrid/Client.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,17 @@ public class Client {
5353
* Constructor for using the default CloseableHttpClient.
5454
*/
5555
public Client() {
56-
this.httpClient = HttpClients.createDefault();
57-
this.test = false;
56+
this(false);
5857
}
5958

6059
/**
61-
* Constructor for passing in an httpClient for mocking.
60+
* Constructor for passing in an httpClient.
6261
*
6362
* @param httpClient
6463
* an Apache CloseableHttpClient
6564
*/
6665
public Client(CloseableHttpClient httpClient) {
67-
this.httpClient = httpClient;
68-
this.test = false;
66+
this(httpClient, false);
6967
}
7068

7169
/**
@@ -75,10 +73,23 @@ public Client(CloseableHttpClient httpClient) {
7573
* is a Bool
7674
*/
7775
public Client(Boolean test) {
78-
this.httpClient = HttpClients.createDefault();
76+
this(HttpClients.createDefault(), test);
77+
}
78+
79+
/**
80+
* Constructor for passing in a an httpClient and test parameter to allow for http calls
81+
*
82+
* @param httpClient
83+
* an Apache CloseableHttpClient
84+
* @param test
85+
* is a Bool
86+
*/
87+
public Client(CloseableHttpClient httpClient, Boolean test) {
88+
this.httpClient = httpClient;
7989
this.test = test;
8090
}
8191

92+
8293
/**
8394
* Add query parameters to a URL.
8495
*

0 commit comments

Comments
 (0)