Skip to content

Commit 68d82d9

Browse files
Merge pull request #247 from sendgrid/javadoc
Added Javadocs.
2 parents 0bb8107 + c983fe4 commit 68d82d9

17 files changed

+967
-38
lines changed

src/main/java/com/sendgrid/SendGrid.java

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,66 @@
55
import java.util.Map;
66

77
/**
8-
* Class SendGrid allows for quick and easy access to the SendGrid API.
9-
*/
8+
* Class SendGrid allows for quick and easy access to the SendGrid API.
9+
*/
1010
public class SendGrid {
11+
/** The current library version. */
1112
private static final String VERSION = "3.0.0";
13+
14+
/** The user agent string to return to SendGrid. */
1215
private static final String USER_AGENT = "sendgrid/" + VERSION + ";java";
1316

17+
/** The user's API key. */
1418
private String apiKey;
19+
20+
/** The SendGrid host to which to connect. */
1521
private String host;
22+
23+
/** The API version. */
1624
private String version;
25+
26+
/** The HTTP client. */
1727
private Client client;
28+
29+
/** The request headers container. */
1830
private Map<String,String> requestHeaders;
1931

2032
/**
21-
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
22-
*/
33+
* Construct a new SendGrid API wrapper.
34+
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
35+
* @return a SendGrid object.
36+
*/
2337
public SendGrid(String apiKey) {
2438
this.client = new Client();
2539
initializeSendGrid(apiKey);
2640
}
2741

2842
/**
29-
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
30-
* @param test is true if you are unit testing
31-
*/
43+
* Construct a new SendGrid API wrapper.
44+
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
45+
* @param test is true if you are unit testing
46+
* @return a SendGrid object.
47+
*/
3248
public SendGrid(String apiKey, Boolean test) {
3349
this.client = new Client(test);
3450
initializeSendGrid(apiKey);
3551
}
3652

3753
/**
54+
* Construct a new SendGrid API wrapper.
3855
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
3956
* @param client the Client to use (allows to customize its configuration)
57+
* @return a SendGrid object.
4058
*/
4159
public SendGrid(String apiKey, Client client) {
4260
this.client = client;
4361
initializeSendGrid(apiKey);
4462
}
4563

64+
/**
65+
* Initialize the client.
66+
* @param apiKey the user's API key.
67+
*/
4668
public void initializeSendGrid(String apiKey) {
4769
this.apiKey = apiKey;
4870
this.host = "api.sendgrid.com";
@@ -53,50 +75,91 @@ public void initializeSendGrid(String apiKey) {
5375
this.requestHeaders.put("Accept", "application/json");
5476
}
5577

78+
/**
79+
* Retrieve the current library version.
80+
* @return the current version.
81+
*/
5682
public String getLibraryVersion() {
5783
return this.VERSION;
5884
}
5985

86+
/**
87+
* Get the API version.
88+
* @return the current API versioin (v3 by default).
89+
*/
6090
public String getVersion() {
6191
return this.version;
6292
}
6393

94+
/**
95+
* Set the API version.
96+
* @param version the new version.
97+
*/
6498
public void setVersion(String version) {
6599
this.version = version;
66100
}
67101

102+
/**
103+
* Obtain the request headers.
104+
* @return the request headers.
105+
*/
68106
public Map<String,String> getRequestHeaders() {
69107
return this.requestHeaders;
70108
}
71109

110+
/**
111+
* Add a new request header.
112+
* @param key the header key.
113+
* @param value the header value.
114+
* @return the new set of request headers.
115+
*/
72116
public Map<String,String> addRequestHeader(String key, String value) {
73117
this.requestHeaders.put(key, value);
74118
return getRequestHeaders();
75119
}
76120

121+
/**
122+
* Remove a request header.
123+
* @param key the header key to remove.
124+
* @return the new set of request headers.
125+
*/
77126
public Map<String,String> removeRequestHeader(String key) {
78127
this.requestHeaders.remove(key);
79128
return getRequestHeaders();
80129
}
81130

131+
/**
132+
* Get the SendGrid host (api.sendgrid.com by default).
133+
* @return the SendGrid host.
134+
*/
82135
public String getHost() {
83136
return this.host;
84137
}
85138

139+
/**
140+
* Set the SendGrid host.
141+
* @host the new SendGrid host.
142+
*/
86143
public void setHost(String host) {
87144
this.host = host;
88145
}
89146

90147
/**
91-
* Class makeCall makes the call to the SendGrid API, override this method for testing.
92-
*/
148+
* Class makeCall makes the call to the SendGrid API, override this method for testing.
149+
* @param request the request to make.
150+
* @return the response object.
151+
* @throws IOException in case of a network error.
152+
*/
93153
public Response makeCall(Request request) throws IOException {
94154
return client.api(request);
95155
}
96156

97157
/**
98-
* Class api sets up the request to the SendGrid API, this is main interface.
99-
*/
158+
* Class api sets up the request to the SendGrid API, this is main interface.
159+
* @param request the request object.
160+
* @return the response object.
161+
* @throws IOException in case of a network error.
162+
*/
100163
public Response api(Request request) throws IOException {
101164
Request req = new Request();
102165
req.setMethod(request.getMethod());

0 commit comments

Comments
 (0)