From 801347cc69bf92c23c14a756c9360caa3cc816d3 Mon Sep 17 00:00:00 2001 From: Maxim Novak Date: Tue, 12 Sep 2017 19:17:00 +0300 Subject: [PATCH] Allow setting both `apache http client` and `test` parameters --- src/main/java/com/sendgrid/Client.java | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sendgrid/Client.java b/src/main/java/com/sendgrid/Client.java index 789855c..7360ab2 100644 --- a/src/main/java/com/sendgrid/Client.java +++ b/src/main/java/com/sendgrid/Client.java @@ -53,19 +53,17 @@ public class Client { * Constructor for using the default CloseableHttpClient. */ public Client() { - this.httpClient = HttpClients.createDefault(); - this.test = false; + this(false); } /** - * Constructor for passing in an httpClient for mocking. + * Constructor for passing in an httpClient. * * @param httpClient * an Apache CloseableHttpClient */ public Client(CloseableHttpClient httpClient) { - this.httpClient = httpClient; - this.test = false; + this(httpClient, false); } /** @@ -75,10 +73,23 @@ public Client(CloseableHttpClient httpClient) { * is a Bool */ public Client(Boolean test) { - this.httpClient = HttpClients.createDefault(); + this(HttpClients.createDefault(), test); + } + + /** + * Constructor for passing in a an httpClient and test parameter to allow for http calls + * + * @param httpClient + * an Apache CloseableHttpClient + * @param test + * is a Bool + */ + public Client(CloseableHttpClient httpClient, Boolean test) { + this.httpClient = httpClient; this.test = test; } + /** * Add query parameters to a URL. *