Skip to content

Commit

Permalink
Version Bump v3.0.2: swagger/oai updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed Jul 5, 2016
1 parent f2360f1 commit 48f5cbc
Show file tree
Hide file tree
Showing 15 changed files with 774 additions and 62 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## [3.0.2] - 2016-07-05
### Updated
- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai)

## [3.0.1] - 2016-06-28
### Fixed
- Accept header via [Get Satisfaction](https://community.sendgrid.com/sendgrid/topics/sendgrid-v3-webapi-issue-with-accept-header-response-406-not-acceptable)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

**BREAKING CHANGE as of 2016.06.14**

Version `3.0.0` is a breaking change for the entire library.
Version `3.X.X` is a breaking change for the entire library.

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

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

Thank you for your continued support!

Expand Down Expand Up @@ -47,7 +48,7 @@ Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
compile 'com.sendgrid:sendgrid-java:3.0.1'
compile 'com.sendgrid:sendgrid-java:3.0.2'
}
repositories {
Expand All @@ -72,7 +73,7 @@ mvn install

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

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

```java
import com.sendgrid.*;
Expand Down
313 changes: 291 additions & 22 deletions USAGE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'

group = 'com.sendgrid'
version = '3.0.1'
version = '3.0.2'
ext.packaging = 'jar'

allprojects {
Expand Down
121 changes: 121 additions & 0 deletions examples/alerts/alerts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.sendgrid.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

//////////////////////////////////////////////////////////////////
// Create a new Alert
// POST /alerts


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.POST;
request.endpoint = "alerts";
request.body = "{\"type\":\"stats_notification\",\"frequency\":\"daily\",\"email_to\":\"[email protected]\"}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

//////////////////////////////////////////////////////////////////
// Retrieve all alerts
// GET /alerts


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.GET;
request.endpoint = "alerts";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

//////////////////////////////////////////////////////////////////
// Update an alert
// PATCH /alerts/{alert_id}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.PATCH;
request.endpoint = "alerts/{alert_id}";
request.body = "{\"email_to\":\"[email protected]\"}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

//////////////////////////////////////////////////////////////////
// Retrieve a specific alert
// GET /alerts/{alert_id}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.GET;
request.endpoint = "alerts/{alert_id}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

//////////////////////////////////////////////////////////////////
// Delete an alert
// DELETE /alerts/{alert_id}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.DELETE;
request.endpoint = "alerts/{alert_id}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

5 changes: 4 additions & 1 deletion examples/apikeys/apikeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void main(String[] args) throws IOException {
Request request = new Request();
request.method = Method.POST;
request.endpoint = "api_keys";
request.body = "{\"scopes\":[\"mail.send\",\"alerts.create\",\"alerts.read\"],\"name\":\"My API Key\"}";
request.body = "{\"sample\":\"data\",\"scopes\":[\"mail.send\",\"alerts.create\",\"alerts.read\"],\"name\":\"My API Key\"}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
Expand All @@ -42,6 +42,9 @@ public static void main(String[] args) throws IOException {
Request request = new Request();
request.method = Method.GET;
request.endpoint = "api_keys";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("limit", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
Expand Down
23 changes: 23 additions & 0 deletions examples/asm/asm.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ public static void main(String[] args) throws IOException {
}
}

//////////////////////////////////////////////////////////////////
// Search for suppressions within a group
// POST /asm/groups/{group_id}/suppressions/search


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.method = Method.POST;
request.endpoint = "asm/groups/{group_id}/suppressions/search";
request.body = "{\"recipient_emails\":[\"[email protected]\",\"[email protected]\",\"[email protected]\"]}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
System.out.println(response.headers);
} catch (IOException ex) {
throw ex;
}
}
}

//////////////////////////////////////////////////////////////////
// Delete a suppression from a suppression group
// DELETE /asm/groups/{group_id}/suppressions/{email}
Expand Down
4 changes: 2 additions & 2 deletions examples/campaigns/campaigns.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static void main(String[] args) throws IOException {
request.method = Method.GET;
request.endpoint = "campaigns";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("limit", "0");
queryParams.put("offset", "0");
queryParams.put("limit", "1");
queryParams.put("offset", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down
13 changes: 7 additions & 6 deletions examples/contactdb/contactdb.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static void main(String[] args) throws IOException {
request.endpoint = "contactdb/lists/{list_id}";
request.body = "{\"name\":\"newlistname\"}";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("list_id", "0");
queryParams.put("list_id", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand All @@ -203,7 +203,7 @@ public static void main(String[] args) throws IOException {
request.method = Method.GET;
request.endpoint = "contactdb/lists/{list_id}";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("list_id", "0");
queryParams.put("list_id", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down Expand Up @@ -278,7 +278,7 @@ public static void main(String[] args) throws IOException {
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("page", "1");
queryParams.put("page_size", "1");
queryParams.put("list_id", "0");
queryParams.put("list_id", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down Expand Up @@ -325,8 +325,8 @@ public static void main(String[] args) throws IOException {
request.method = Method.DELETE;
request.endpoint = "contactdb/lists/{list_id}/recipients/{recipient_id}";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("recipient_id", "0");
queryParams.put("list_id", "0");
queryParams.put("recipient_id", "1");
queryParams.put("list_id", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down Expand Up @@ -490,6 +490,7 @@ public static void main(String[] args) throws IOException {
request.method = Method.GET;
request.endpoint = "contactdb/recipients/search";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("%7Bfield_name%7D", "test_string");
queryParams.put("{field_name}", "test_string");
request.queryParams = queryParams;
Response response = sg.api(request);
Expand Down Expand Up @@ -674,7 +675,7 @@ public static void main(String[] args) throws IOException {
request.method = Method.GET;
request.endpoint = "contactdb/segments/{segment_id}";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("segment_id", "0");
queryParams.put("segment_id", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down
3 changes: 2 additions & 1 deletion examples/mail/mail.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static void main(String[] args) throws IOException {
//////////////////////////////////////////////////////////////////
// v3 Mail Send
// POST /mail/send

// 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).

public class Example {
Expand All @@ -63,7 +64,7 @@ public static void main(String[] args) throws IOException {
Request request = new Request();
request.method = Method.POST;
request.endpoint = "mail/send";
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}";
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}";
Response response = sg.api(request);
System.out.println(response.statusCode);
System.out.println(response.body);
Expand Down
6 changes: 3 additions & 3 deletions examples/subusers/subusers.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static void main(String[] args) throws IOException {
request.endpoint = "subusers";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("username", "test_string");
queryParams.put("limit", "0");
queryParams.put("offset", "0");
queryParams.put("limit", "1");
queryParams.put("offset", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down Expand Up @@ -346,7 +346,7 @@ public static void main(String[] args) throws IOException {
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("date", "test_string");
queryParams.put("sort_by_direction", "asc");
queryParams.put("limit", "0");
queryParams.put("limit", "1");
queryParams.put("sort_by_metric", "test_string");
queryParams.put("offset", "1");
request.queryParams = queryParams;
Expand Down
4 changes: 2 additions & 2 deletions examples/suppression/suppression.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public static void main(String[] args) throws IOException {
request.method = Method.GET;
request.endpoint = "suppression/bounces";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("start_time", "0");
queryParams.put("end_time", "0");
queryParams.put("start_time", "1");
queryParams.put("end_time", "1");
request.queryParams = queryParams;
Response response = sg.api(request);
System.out.println(response.statusCode);
Expand Down
Loading

0 comments on commit 48f5cbc

Please sign in to comment.