Skip to content

Commit 48f5cbc

Browse files
Version Bump v3.0.2: swagger/oai updates
1 parent f2360f1 commit 48f5cbc

File tree

15 files changed

+774
-62
lines changed

15 files changed

+774
-62
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.0.2] - 2016-07-05
5+
### Updated
6+
- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai)
7+
48
## [3.0.1] - 2016-06-28
59
### Fixed
610
- Accept header via [Get Satisfaction](https://community.sendgrid.com/sendgrid/topics/sendgrid-v3-webapi-issue-with-accept-header-response-406-not-acceptable)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
**BREAKING CHANGE as of 2016.06.14**
88

9-
Version `3.0.0` is a breaking change for the entire library.
9+
Version `3.X.X` is a breaking change for the entire library.
1010

11-
Version 3.0.0 brings you full support for all Web API v3 endpoints. We
11+
Version 3.X.X brings you full support for all Web API v3 endpoints. We
1212
have the following resources to get you started quickly:
1313

1414
- [SendGrid
@@ -17,6 +17,7 @@ have the following resources to get you started quickly:
1717
Documentation](https://github.com/sendgrid/sendgrid-java/tree/master/USAGE.md)
1818
- [Example
1919
Code](https://github.com/sendgrid/sendgrid-java/tree/master/examples)
20+
- [Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html)
2021

2122
Thank you for your continued support!
2223

@@ -47,7 +48,7 @@ Add the following to your build.gradle file in the root of your project.
4748
...
4849
dependencies {
4950
...
50-
compile 'com.sendgrid:sendgrid-java:3.0.1'
51+
compile 'com.sendgrid:sendgrid-java:3.0.2'
5152
}
5253
5354
repositories {
@@ -72,7 +73,7 @@ mvn install
7273

7374
You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.
7475

75-
[sendgrid-java.jar](http://repo1.maven.org/maven2/com/sendgrid/sendgrid-java/3.0.1/sendgrid-java-3.0.1-jar.jar)
76+
[sendgrid-java.jar](http://repo1.maven.org/maven2/com/sendgrid/sendgrid-java/3.0.2/sendgrid-java-3.0.2-jar.jar)
7677

7778
```java
7879
import com.sendgrid.*;

USAGE.md

Lines changed: 291 additions & 22 deletions
Large diffs are not rendered by default.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apply plugin: 'maven'
1717
apply plugin: 'signing'
1818

1919
group = 'com.sendgrid'
20-
version = '3.0.1'
20+
version = '3.0.2'
2121
ext.packaging = 'jar'
2222

2323
allprojects {

examples/alerts/alerts.java

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import com.fasterxml.jackson.databind.JsonNode;
2+
import com.fasterxml.jackson.databind.ObjectMapper;
3+
4+
import com.sendgrid.*;
5+
6+
import java.io.IOException;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
//////////////////////////////////////////////////////////////////
11+
// Create a new Alert
12+
// POST /alerts
13+
14+
15+
public class Example {
16+
public static void main(String[] args) throws IOException {
17+
try {
18+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
19+
Request request = new Request();
20+
request.method = Method.POST;
21+
request.endpoint = "alerts";
22+
request.body = "{\"type\":\"stats_notification\",\"frequency\":\"daily\",\"email_to\":\"[email protected]\"}";
23+
Response response = sg.api(request);
24+
System.out.println(response.statusCode);
25+
System.out.println(response.body);
26+
System.out.println(response.headers);
27+
} catch (IOException ex) {
28+
throw ex;
29+
}
30+
}
31+
}
32+
33+
//////////////////////////////////////////////////////////////////
34+
// Retrieve all alerts
35+
// GET /alerts
36+
37+
38+
public class Example {
39+
public static void main(String[] args) throws IOException {
40+
try {
41+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
42+
Request request = new Request();
43+
request.method = Method.GET;
44+
request.endpoint = "alerts";
45+
Response response = sg.api(request);
46+
System.out.println(response.statusCode);
47+
System.out.println(response.body);
48+
System.out.println(response.headers);
49+
} catch (IOException ex) {
50+
throw ex;
51+
}
52+
}
53+
}
54+
55+
//////////////////////////////////////////////////////////////////
56+
// Update an alert
57+
// PATCH /alerts/{alert_id}
58+
59+
60+
public class Example {
61+
public static void main(String[] args) throws IOException {
62+
try {
63+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
64+
Request request = new Request();
65+
request.method = Method.PATCH;
66+
request.endpoint = "alerts/{alert_id}";
67+
request.body = "{\"email_to\":\"[email protected]\"}";
68+
Response response = sg.api(request);
69+
System.out.println(response.statusCode);
70+
System.out.println(response.body);
71+
System.out.println(response.headers);
72+
} catch (IOException ex) {
73+
throw ex;
74+
}
75+
}
76+
}
77+
78+
//////////////////////////////////////////////////////////////////
79+
// Retrieve a specific alert
80+
// GET /alerts/{alert_id}
81+
82+
83+
public class Example {
84+
public static void main(String[] args) throws IOException {
85+
try {
86+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
87+
Request request = new Request();
88+
request.method = Method.GET;
89+
request.endpoint = "alerts/{alert_id}";
90+
Response response = sg.api(request);
91+
System.out.println(response.statusCode);
92+
System.out.println(response.body);
93+
System.out.println(response.headers);
94+
} catch (IOException ex) {
95+
throw ex;
96+
}
97+
}
98+
}
99+
100+
//////////////////////////////////////////////////////////////////
101+
// Delete an alert
102+
// DELETE /alerts/{alert_id}
103+
104+
105+
public class Example {
106+
public static void main(String[] args) throws IOException {
107+
try {
108+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
109+
Request request = new Request();
110+
request.method = Method.DELETE;
111+
request.endpoint = "alerts/{alert_id}";
112+
Response response = sg.api(request);
113+
System.out.println(response.statusCode);
114+
System.out.println(response.body);
115+
System.out.println(response.headers);
116+
} catch (IOException ex) {
117+
throw ex;
118+
}
119+
}
120+
}
121+

examples/apikeys/apikeys.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void main(String[] args) throws IOException {
1919
Request request = new Request();
2020
request.method = Method.POST;
2121
request.endpoint = "api_keys";
22-
request.body = "{\"scopes\":[\"mail.send\",\"alerts.create\",\"alerts.read\"],\"name\":\"My API Key\"}";
22+
request.body = "{\"sample\":\"data\",\"scopes\":[\"mail.send\",\"alerts.create\",\"alerts.read\"],\"name\":\"My API Key\"}";
2323
Response response = sg.api(request);
2424
System.out.println(response.statusCode);
2525
System.out.println(response.body);
@@ -42,6 +42,9 @@ public static void main(String[] args) throws IOException {
4242
Request request = new Request();
4343
request.method = Method.GET;
4444
request.endpoint = "api_keys";
45+
Map<String,String> queryParams = new HashMap<String, String>();
46+
queryParams.put("limit", "1");
47+
request.queryParams = queryParams;
4548
Response response = sg.api(request);
4649
System.out.println(response.statusCode);
4750
System.out.println(response.body);

examples/asm/asm.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,29 @@ public static void main(String[] args) throws IOException {
167167
}
168168
}
169169

170+
//////////////////////////////////////////////////////////////////
171+
// Search for suppressions within a group
172+
// POST /asm/groups/{group_id}/suppressions/search
173+
174+
175+
public class Example {
176+
public static void main(String[] args) throws IOException {
177+
try {
178+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
179+
Request request = new Request();
180+
request.method = Method.POST;
181+
request.endpoint = "asm/groups/{group_id}/suppressions/search";
182+
request.body = "{\"recipient_emails\":[\"[email protected]\",\"[email protected]\",\"[email protected]\"]}";
183+
Response response = sg.api(request);
184+
System.out.println(response.statusCode);
185+
System.out.println(response.body);
186+
System.out.println(response.headers);
187+
} catch (IOException ex) {
188+
throw ex;
189+
}
190+
}
191+
}
192+
170193
//////////////////////////////////////////////////////////////////
171194
// Delete a suppression from a suppression group
172195
// DELETE /asm/groups/{group_id}/suppressions/{email}

examples/campaigns/campaigns.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static void main(String[] args) throws IOException {
4343
request.method = Method.GET;
4444
request.endpoint = "campaigns";
4545
Map<String,String> queryParams = new HashMap<String, String>();
46-
queryParams.put("limit", "0");
47-
queryParams.put("offset", "0");
46+
queryParams.put("limit", "1");
47+
queryParams.put("offset", "1");
4848
request.queryParams = queryParams;
4949
Response response = sg.api(request);
5050
System.out.println(response.statusCode);

examples/contactdb/contactdb.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static void main(String[] args) throws IOException {
178178
request.endpoint = "contactdb/lists/{list_id}";
179179
request.body = "{\"name\":\"newlistname\"}";
180180
Map<String,String> queryParams = new HashMap<String, String>();
181-
queryParams.put("list_id", "0");
181+
queryParams.put("list_id", "1");
182182
request.queryParams = queryParams;
183183
Response response = sg.api(request);
184184
System.out.println(response.statusCode);
@@ -203,7 +203,7 @@ public static void main(String[] args) throws IOException {
203203
request.method = Method.GET;
204204
request.endpoint = "contactdb/lists/{list_id}";
205205
Map<String,String> queryParams = new HashMap<String, String>();
206-
queryParams.put("list_id", "0");
206+
queryParams.put("list_id", "1");
207207
request.queryParams = queryParams;
208208
Response response = sg.api(request);
209209
System.out.println(response.statusCode);
@@ -278,7 +278,7 @@ public static void main(String[] args) throws IOException {
278278
Map<String,String> queryParams = new HashMap<String, String>();
279279
queryParams.put("page", "1");
280280
queryParams.put("page_size", "1");
281-
queryParams.put("list_id", "0");
281+
queryParams.put("list_id", "1");
282282
request.queryParams = queryParams;
283283
Response response = sg.api(request);
284284
System.out.println(response.statusCode);
@@ -325,8 +325,8 @@ public static void main(String[] args) throws IOException {
325325
request.method = Method.DELETE;
326326
request.endpoint = "contactdb/lists/{list_id}/recipients/{recipient_id}";
327327
Map<String,String> queryParams = new HashMap<String, String>();
328-
queryParams.put("recipient_id", "0");
329-
queryParams.put("list_id", "0");
328+
queryParams.put("recipient_id", "1");
329+
queryParams.put("list_id", "1");
330330
request.queryParams = queryParams;
331331
Response response = sg.api(request);
332332
System.out.println(response.statusCode);
@@ -490,6 +490,7 @@ public static void main(String[] args) throws IOException {
490490
request.method = Method.GET;
491491
request.endpoint = "contactdb/recipients/search";
492492
Map<String,String> queryParams = new HashMap<String, String>();
493+
queryParams.put("%7Bfield_name%7D", "test_string");
493494
queryParams.put("{field_name}", "test_string");
494495
request.queryParams = queryParams;
495496
Response response = sg.api(request);
@@ -674,7 +675,7 @@ public static void main(String[] args) throws IOException {
674675
request.method = Method.GET;
675676
request.endpoint = "contactdb/segments/{segment_id}";
676677
Map<String,String> queryParams = new HashMap<String, String>();
677-
queryParams.put("segment_id", "0");
678+
queryParams.put("segment_id", "1");
678679
request.queryParams = queryParams;
679680
Response response = sg.api(request);
680681
System.out.println(response.statusCode);

examples/mail/mail.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public static void main(String[] args) throws IOException {
5454
//////////////////////////////////////////////////////////////////
5555
// v3 Mail Send
5656
// POST /mail/send
57+
5758
// This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-java/blob/master/src/main/java/com/sendgrid/helpers/README.md).
5859

5960
public class Example {
@@ -63,7 +64,7 @@ public static void main(String[] args) throws IOException {
6364
Request request = new Request();
6465
request.method = Method.POST;
6566
request.endpoint = "mail/send";
66-
request.body = "{\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\"[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"from\":{\"email\":\"[email protected]\",\"name\":\"Sam Smith\"},\"attachments\":[{\"name\":\"file1\",\"filename\":\"file1.jpg\",\"content\":\"[BASE64 encoded content block here]\",\"disposition\":\"inline\",\"content_id\":\"ii_139db99fdb5c3704\",\"type\":\"jpg\"}],\"personalizations\":[{\"to\":[{\"email\":\"[email protected]\",\"name\":\"John Doe\"}],\"cc\":[{\"email\":\"[email protected]\",\"name\":\"Jane Doe\"}],\"bcc\":[{\"email\":\"[email protected]\",\"name\":\"Sam Doe\"}],\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\"[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"headers\":{\"X-Accept-Language\":\"en\",\"X-Mailer\":\"MyApp\"},\"send_at\":1409348513,\"substitutions\":{\"sub\":{\"%name%\":[\"John\",\"Jane\",\"Sam\"]}},\"subject\":\"Hello, World!\"}],\"subject\":\"Hello, World!\",\"ip_pool_name\":\"[YOUR POOL NAME GOES HERE]\",\"content\":[{\"type\":\"text/html\",\"value\":\"<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>\"}],\"headers\":{},\"asm\":{\"groups_to_display\":[1,2,3],\"group_id\":1},\"batch_id\":\"[YOUR BATCH ID GOES HERE]\",\"tracking_settings\":{\"subscription_tracking\":{\"text\":\"If you would like to unsubscribe and stop receiveing these emails <% click here %>.\",\"enable\":true,\"html\":\"If you would like to unsubscribe and stop receiving these emails <% clickhere %>.\",\"substitution_tag\":\"<%click here%>\"},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"%opentrack\"},\"click_tracking\":{\"enable\":true,\"enable_text\":true},\"ganalytics\":{\"utm_campaign\":\"[NAME OF YOUR REFERRER SOURCE]\",\"enable\":true,\"utm_name\":\"[NAME OF YOUR CAMPAIGN]\",\"utm_term\":\"[IDENTIFY PAID KEYWORDS HERE]\",\"utm_content\":\"[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]\",\"utm_medium\":\"[NAME OF YOUR MARKETING MEDIUM e.g. email]\"}},\"mail_settings\":{\"footer\":{\"text\":\"Thanks,/n The SendGrid Team\",\"enable\":true,\"html\":\"<p>Thanks</br>The SendGrid Team</p>\"},\"spam_check\":{\"threshold\":3,\"post_to_url\":\"http://example.com/compliance\",\"enable\":true},\"bypass_list_management\":{\"enable\":true},\"sandbox_mode\":{\"enable\":false},\"bcc\":{\"enable\":true,\"email\":\"[email protected]\"}},\"reply_to\":{\"email\":\"[email protected]\",\"name\":\"Sam Smith\"},\"sections\":{\"section\":{\":sectionName2\":\"section 2 text\",\":sectionName1\":\"section 1 text\"}},\"template_id\":\"[YOUR TEMPLATE ID GOES HERE]\",\"categories\":[\"category1\",\"category2\"],\"send_at\":1409348513}";
67+
request.body = "{\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\"[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"from\":{\"email\":\"[email protected]\",\"name\":\"Sam Smith\"},\"attachments\":[{\"name\":\"file1\",\"filename\":\"file1.jpg\",\"content\":\"[BASE64 encoded content block here]\",\"disposition\":\"inline\",\"content_id\":\"ii_139db99fdb5c3704\",\"type\":\"jpg\"}],\"personalizations\":[{\"to\":[{\"email\":\"[email protected]\",\"name\":\"John Doe\"}],\"cc\":[{\"email\":\"[email protected]\",\"name\":\"Jane Doe\"}],\"bcc\":[{\"email\":\"[email protected]\",\"name\":\"Sam Doe\"}],\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\"[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"headers\":{\"X-Accept-Language\":\"en\",\"X-Mailer\":\"MyApp\"},\"send_at\":1409348513,\"substitutions\":{\"type\":\"object\",\"id\":\"substitutions\"},\"subject\":\"Hello, World!\"}],\"subject\":\"Hello, World!\",\"ip_pool_name\":\"[YOUR POOL NAME GOES HERE]\",\"content\":[{\"type\":\"text/html\",\"value\":\"<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>\"}],\"headers\":{},\"asm\":{\"groups_to_display\":[1,2,3],\"group_id\":1},\"batch_id\":\"[YOUR BATCH ID GOES HERE]\",\"tracking_settings\":{\"subscription_tracking\":{\"text\":\"If you would like to unsubscribe and stop receiveing these emails <% click here %>.\",\"enable\":true,\"html\":\"If you would like to unsubscribe and stop receiving these emails <% clickhere %>.\",\"substitution_tag\":\"<%click here%>\"},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"%opentrack\"},\"click_tracking\":{\"enable\":true,\"enable_text\":true},\"ganalytics\":{\"utm_campaign\":\"[NAME OF YOUR REFERRER SOURCE]\",\"enable\":true,\"utm_name\":\"[NAME OF YOUR CAMPAIGN]\",\"utm_term\":\"[IDENTIFY PAID KEYWORDS HERE]\",\"utm_content\":\"[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]\",\"utm_medium\":\"[NAME OF YOUR MARKETING MEDIUM e.g. email]\"}},\"mail_settings\":{\"footer\":{\"text\":\"Thanks,/n The SendGrid Team\",\"enable\":true,\"html\":\"<p>Thanks</br>The SendGrid Team</p>\"},\"spam_check\":{\"threshold\":3,\"post_to_url\":\"http://example.com/compliance\",\"enable\":true},\"bypass_list_management\":{\"enable\":true},\"sandbox_mode\":{\"enable\":false},\"bcc\":{\"enable\":true,\"email\":\"[email protected]\"}},\"reply_to\":{\"email\":\"[email protected]\",\"name\":\"Sam Smith\"},\"sections\":{\"section\":{\":sectionName2\":\"section 2 text\",\":sectionName1\":\"section 1 text\"}},\"template_id\":\"[YOUR TEMPLATE ID GOES HERE]\",\"categories\":[\"category1\",\"category2\"],\"send_at\":1409348513}";
6768
Response response = sg.api(request);
6869
System.out.println(response.statusCode);
6970
System.out.println(response.body);

0 commit comments

Comments
 (0)