33import java .io .IOException ;
44import java .util .HashMap ;
55import java .util .Map ;
6- import java .util .concurrent .Executors ;
76import java .util .concurrent .ExecutorService ;
7+ import java .util .concurrent .Executors ;
88
99/**
10- * Class Twilio SendGrid allows for quick and easy access to the Twilio SendGrid API.
11- */
10+ * The Twilio SendGrid class allows for quick and easy access to the Twilio SendGrid API.
11+ */
1212public class SendGrid implements SendGridAPI {
1313
1414 private static final String VERSION = "3.0.0" ;
@@ -43,6 +43,7 @@ public class SendGrid implements SendGridAPI {
4343
4444 /**
4545 * Construct a new Twilio SendGrid API wrapper.
46+ *
4647 * @param apiKey is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keys
4748 */
4849 public SendGrid (String apiKey ) {
@@ -52,6 +53,7 @@ public SendGrid(String apiKey) {
5253
5354 /**
5455 * Construct a new Twilio SendGrid API wrapper.
56+ *
5557 * @param apiKey is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keys
5658 * @param test is true if you are unit testing
5759 */
@@ -62,6 +64,7 @@ public SendGrid(String apiKey, Boolean test) {
6264
6365 /**
6466 * Construct a new Twilio SendGrid API wrapper.
67+ *
6568 * @param apiKey is your Twilio SendGrid API Key: https://app.sendgrid.com/settings/api_keys
6669 * @param client the Client to use (allows to customize its configuration)
6770 */
@@ -72,6 +75,7 @@ public SendGrid(String apiKey, Client client) {
7275
7376 /**
7477 * Initialize the client.
78+ *
7579 * @param apiKey the user's API key.
7680 */
7781 public void initializeSendGrid (String apiKey ) {
@@ -89,14 +93,16 @@ public void initializeSendGrid(String apiKey) {
8993
9094 /**
9195 * Retrieve the current library version.
96+ *
9297 * @return the current version.
9398 */
9499 public String getLibraryVersion () {
95- return this . VERSION ;
100+ return VERSION ;
96101 }
97102
98103 /**
99104 * Get the API version.
105+ *
100106 * @return the current API versioin (v3 by default).
101107 */
102108 public String getVersion () {
@@ -105,6 +111,7 @@ public String getVersion() {
105111
106112 /**
107113 * Set the API version.
114+ *
108115 * @param version the new version.
109116 */
110117 public void setVersion (String version ) {
@@ -113,6 +120,7 @@ public void setVersion(String version) {
113120
114121 /**
115122 * Obtain the request headers.
123+ *
116124 * @return the request headers.
117125 */
118126 public Map <String , String > getRequestHeaders () {
@@ -121,6 +129,7 @@ public Map<String, String> getRequestHeaders() {
121129
122130 /**
123131 * Add a new request header.
132+ *
124133 * @param key the header key.
125134 * @param value the header value.
126135 * @return the new set of request headers.
@@ -132,6 +141,7 @@ public Map<String, String> addRequestHeader(String key, String value) {
132141
133142 /**
134143 * Remove a request header.
144+ *
135145 * @param key the header key to remove.
136146 * @return the new set of request headers.
137147 */
@@ -142,6 +152,7 @@ public Map<String, String> removeRequestHeader(String key) {
142152
143153 /**
144154 * Get the Twilio SendGrid host (api.sendgrid.com by default).
155+ *
145156 * @return the Twilio SendGrid host.
146157 */
147158 public String getHost () {
@@ -150,15 +161,16 @@ public String getHost() {
150161
151162 /**
152163 * Set the Twilio SendGrid host.
164+ *
153165 * @param host the new Twilio SendGrid host.
154166 */
155167 public void setHost (String host ) {
156168 this .host = host ;
157169 }
158170
159171 /**
160- * Get the maximum number of retries on a rate limit response.
161- * The default is 5.
172+ * Get the maximum number of retries on a rate limit response. The default is 5.
173+ *
162174 * @return the number of retries on a rate limit.
163175 */
164176 public int getRateLimitRetry () {
@@ -167,25 +179,26 @@ public int getRateLimitRetry() {
167179
168180 /**
169181 * Set the maximum number of retries on a rate limit response.
182+ *
170183 * @param rateLimitRetry the maximum retry count.
171184 */
172185 public void setRateLimitRetry (int rateLimitRetry ) {
173186 this .rateLimitRetry = rateLimitRetry ;
174187 }
175188
176189 /**
177- * Get the duration of time (in milliseconds) to sleep between
178- * consecutive rate limit retries . The Twilio SendGrid API enforces
179- * the rate limit to the second. The default value is 1.1 seconds.
190+ * Get the duration of time (in milliseconds) to sleep between consecutive rate limit retries. The
191+ * Twilio SendGrid API enforces the rate limit to the second . The default value is 1.1 seconds.
192+ *
180193 * @return the sleep duration.
181194 */
182195 public int getRateLimitSleep () {
183196 return this .rateLimitSleep ;
184197 }
185198
186199 /**
187- * Set the duration of time (in milliseconds) to sleep between
188- * consecutive rate limit retries.
200+ * Set the duration of time (in milliseconds) to sleep between consecutive rate limit retries.
201+ *
189202 * @param rateLimitSleep the sleep duration.
190203 */
191204 public void setRateLimitSleep (int rateLimitSleep ) {
@@ -194,6 +207,7 @@ public void setRateLimitSleep(int rateLimitSleep) {
194207
195208 /**
196209 * Impersonate subuser for subsequent requests
210+ *
197211 * @param subuser the subuser to be impersonated
198212 */
199213 public void addImpersonateSubuser (String subuser ) {
@@ -211,14 +225,16 @@ public void removeImpersonateSubuser() {
211225
212226 /**
213227 * Get the impersonated subuser or null if empty
228+ *
214229 * @return the impersonated subuser
215230 */
216231 public String getImpersonateSubuser () {
217- return this .subuser ;
232+ return this .subuser ;
218233 }
219234
220235 /**
221236 * Makes the call to the Twilio SendGrid API, override this method for testing.
237+ *
222238 * @param request the request to make.
223239 * @return the response object.
224240 * @throws IOException in case of a network error.
@@ -229,6 +245,7 @@ public Response makeCall(Request request) throws IOException {
229245
230246 /**
231247 * Class api sets up the request to the Twilio SendGrid API, this is main interface.
248+ *
232249 * @param request the request object.
233250 * @return the response object.
234251 * @throws IOException in case of a network error.
@@ -250,9 +267,9 @@ public Response api(Request request) throws IOException {
250267 }
251268
252269 /**
253- * Attempt an API call. This method executes the API call asynchronously
254- * on an internal thread pool. If the call is rate limited, the thread
255- * will retry up to the maximum configured time.
270+ * Attempt an API call. This method executes the API call asynchronously on an internal thread
271+ * pool. If the call is rate limited, the thread will retry up to the maximum configured time.
272+ *
256273 * @param request the API request.
257274 */
258275 public void attempt (Request request ) {
@@ -267,10 +284,10 @@ public void response(Response r) {
267284 }
268285
269286 /**
270- * Attempt an API call. This method executes the API call asynchronously
271- * on an internal thread pool. If the call is rate limited, the thread
272- * will retry up to the maximum configured time. The supplied callback
273- * will be called in the event of an error, or a successful response.
287+ * Attempt an API call. This method executes the API call asynchronously on an internal thread
288+ * pool. If the call is rate limited, the thread will retry up to the maximum configured time. The
289+ * supplied callback will be called in the event of an error, or a successful response.
290+ *
274291 * @param request the API request.
275292 * @param callback the callback.
276293 */
0 commit comments