Skip to content

Commit bd16973

Browse files
Simplified contributing example, clarified personalization default
1 parent c3108dd commit bd16973

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,15 @@ See the [examples folder](https://github.com/sendgrid/sendgrid-java/tree/master/
9494
Check out the documentation for [Web API v3 endpoints](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html).
9595

9696
```bash
97+
./gradlew build
9798
cd examples
9899
touch Example.java
99100
```
100101

101102
Add the example you want to test to Example.java, including the headers at the top of the file.
102103

103104
``` bash
104-
javac -classpath ./dependencies/jackson-annotations-2.7.0.jar:./dependencies/jackson-databind-2.7.3.jar:./dependencies/jackson-core-2.7.3.jar:../build/libs/sendgrid-3.0.0-jar.jar:. Example.java && java -classpath ./dependencies/jackson-annotations-2.7.0.jar:./dependencies/jackson-databind-2.7.3.jar:./dependencies/jackson-core-2.7.3.jar:../build/libs/sendgrid-3.0.0-jar.jar:. Example
105+
javac -classpath ../repo/com/sendgrid/3.0.0/sendgrid-3.0.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/3.0.0/sendgrid-3.0.0-jar.jar:. Example
105106
```
106107

107108
<a name="understanding_the_codebase"></a>

examples/helpers/mail/Example.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ public static Mail buildHelloEmail() throws IOException {
213213
String subject = "Hello World from the SendGrid Java Library";
214214
Email to = new Email("[email protected]");
215215
Content content = new Content("text/plain", "some text here");
216+
// Note that when you use this constructor an initial personalization object
217+
// is created for you. It can be accessed via
218+
// mail.personalization.get(0) as it is a List object
216219
Mail mail = new Mail(from, subject, to, content);
217220
Email email = new Email("[email protected]");
218221
mail.personalization.get(0).addTo(email);
@@ -229,11 +232,11 @@ public static void baselineExample() throws IOException {
229232
try {
230233
request.method = Method.POST;
231234
request.endpoint = "mail/send";
232-
request.requestBody = helloWorld.build();
235+
request.body = helloWorld.build();
233236
Response response = sg.api(request);
234237
System.out.println(response.statusCode);
235-
System.out.println(response.responseBody);
236-
System.out.println(response.responseHeaders);
238+
System.out.println(response.body);
239+
System.out.println(response.headers);
237240
} catch (IOException ex) {
238241
throw ex;
239242
}
@@ -248,11 +251,11 @@ public static void kitchenSinkExample() throws IOException {
248251
try {
249252
request.method = Method.POST;
250253
request.endpoint = "mail/send";
251-
request.requestBody = kitchenSink.build();
254+
request.body = kitchenSink.build();
252255
Response response = sg.api(request);
253256
System.out.println(response.statusCode);
254-
System.out.println(response.responseBody);
255-
System.out.println(response.responseHeaders);
257+
System.out.println(response.body);
258+
System.out.println(response.headers);
256259
} catch (IOException ex) {
257260
throw ex;
258261
}

0 commit comments

Comments
 (0)