From daa4ae49fe3915538288de24e1c8ae3a8f069fb5 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Sun, 17 Sep 2017 09:17:24 -0700
Subject: [PATCH 001/345] Mail Helper Refactor Proposal
---
proposals/mail-helper-refactor.md | 466 ++++++++++++++++++++++++++++++
1 file changed, 466 insertions(+)
create mode 100644 proposals/mail-helper-refactor.md
diff --git a/proposals/mail-helper-refactor.md b/proposals/mail-helper-refactor.md
new file mode 100644
index 00000000..7e152bf5
--- /dev/null
+++ b/proposals/mail-helper-refactor.md
@@ -0,0 +1,466 @@
+# Send a Single Email to a Single Recipient
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+This is the minimum code needed to send an email.
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ To to = new To("test@example.com", "Example User");
+ Subject subject = Subject("Sending with SendGrid is Fun");
+ PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
+ HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
+ SendGridMessage email = new SendGridMessage(from,
+ to,
+ subject,
+ plainTextContent,
+ htmlContent);
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
+
+# Send a Single Email to Multiple Recipients
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+import java.util.ArrayList;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ ArrayList tos = new ArrayList();
+ tos.add(new To("test1@example.com", "Example User1"));
+ tos.add(new To("test2@example.com", "Example User2"));
+ tos.add(new To("test3@example.com", "Example User3"));
+ Subject subject = Subject("Sending with SendGrid is Fun");
+ PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
+ HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
+ SendGridMessage email = new SendGridMessage(from,
+ tos,
+ subject,
+ plainTextContent,
+ htmlContent);
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
+
+# Send Multiple Emails to Multiple Recipients
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+import java.util.ArrayList;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ ArrayList tos = new ArrayList();
+ ArrayList sub = new ArrayList();
+ sub.add("-name-", "Alain");
+ sub.add("-github-", "http://github.com/ninsuo");
+ tos.add(new To("test1@example.com", "Example User1"), sub);
+ sub.clear();
+ sub.add("-name-", "Elmer");
+ sub.add("-github-", "http://github.com/thinkingserious");
+ tos.add(new To("test2@example.com", "Example User2"), sub);
+ sub.clear();
+ sub.add("-name-", "Casey");
+ sub.add("-github-", "http://github.com/caseyw");
+ tos.add(new To("test3@example.com", "Example User3"), sub);
+ // Alternatively, you can pass in a collection of subjects OR add a subject to the `To` object
+ Subject subject = Subject("Hi -name-!");
+ Substitution globalSubstitution = new Substitution("-time-", "");
+ PlainTextContent plainTextContent = new PlainTextContent("Hello -name-, your github is -github-, email sent at -time-");
+ HtmlContent htmlContent = new HtmlContent("Hello -name-, your github is here email sent at -time-");
+ SendGridMessage email = new SendGridMessage(from,
+ subject, // or subjects,
+ tos,
+ plainTextContent,
+ htmlContent,
+ globalSubstition); // or globalSubstitutions
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
+
+# Kitchen Sink - an example with all settings used
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+import java.util.ArrayList;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ To to = new To("test@example.com", "Example User");
+ Subject subject = Subject("Sending with SendGrid is Fun");
+ PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
+ HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
+ SendGridMessage email = new SendGridMessage(from,
+ to, // or tos
+ subject, // or subjects
+ plainTextContent,
+ htmlContent);
+
+ // For a detailed description of each of these settings, please see the [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html).
+ email.addTo("test1@example.com", "Example User1")
+ ArrayList tos = new ArrayList();
+ tos.add("test2@example.com", "Example User2");
+ tos.add("test3@example.com", "Example User3");
+ email.addTos(tos);
+
+ email.addCc("test4@example.com", "Example User4")
+ ArrayList ccs = new ArrayList();
+ ccs.add("test5@example.com", "Example User5");
+ ccs.add("test6@example.com", "Example User6");
+ email.addCcs(ccs);
+
+ email.addBcc("test7@example.com", "Example User7")
+ ArrayList bccs = new ArrayList();
+ bccs.add("test8@example.com", "Example User8");
+ bccs.add("test9@example.com", "Example User9");
+ email.addBccs(bccs);
+
+ email.addHeader("X-Test1", "Test1");
+ email.addHeader("X-Test2", "Test2");
+ ArrayList headers = new ArrayList();
+ headers.add("X-Test3", "Test3");
+ headers.add("X-Test4", "Test4");
+ email.addHeaders(headers)
+
+ email.addSubstitution("%name1%", "Example Name 1");
+ email.addSubstitution("%city1%", "Denver");
+ ArrayList substitutions = new ArrayList();
+ substitutions.add("%name2%", "Example Name 2");
+ substitutions.add("%city2%", "Orange" );
+ email.addSubstitutions(substitutions);
+
+ email.addCustomArg("marketing1", "false");
+ email.addCustomArg("transactional1", "true");
+ ArrayList customArgs = new ArrayList();
+ customArgs.add("marketing2", "true");
+ customArgs.add("transactional2", "false");
+ email.addCustomArgs(customArgs);
+
+ email.setSendAt(1461775051);
+
+ // If you need to add more [Personalizations](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html), here is an example of adding another Personalization by passing in a personalization index
+
+
+ email.addTo("test10@example.com", "Example User 10", 1);
+ ArrayList tos1 = new ArrayList();
+ tos1.add("test11@example.com", "Example User11");
+ tos1.add("test12@example.com", "Example User12");
+ email.addTos(tos1, 1);
+
+ email.addCc("test13@example.com", "Example User 13", 1);
+ ArrayList ccs1 = new ArrayList();
+ ccs1.add("test14@example.com", "Example User14");
+ ccs1.add("test15@example.com", "Example User15");
+ email.addCcs(ccs1, 1);
+
+ email.addBcc("test16@example.com", "Example User 16", 1);
+ ArrayList bccs1 = new ArrayList();
+ bccs1.add("test17@example.com", "Example User17");
+ bccs1.add("test18@example.com", "Example User18");
+ email.addBccs(bccs1, 1);
+
+ email.addHeader("X-Test5", "Test5", 1);
+ email.addHeader("X-Test6", "Test6", 1);
+ ArrayList headers1 = new ArrayList();
+ headers1.add("X-Test7", "Test7");
+ headers1.add("X-Test8", "Test8");
+ email.addHeaders(headers1, 1);
+
+ email.addSubstitution("%name3%", "Example Name 3", 1);
+ email.addSubstitution("%city3%", "Redwood City", 1);
+ ArrayList substitutions1 = new ArrayList();
+ substitutions1.add("%name4%", "Example Name 4");
+ substitutions1.add("%city4%", "London");
+ var substitutions1 = new Dictionary()
+ email.addSubstitutions(substitutions1, 1);
+
+ email.addCustomArg("marketing3", "true", 1);
+ email.addCustomArg("transactional3", "false", 1);
+ ArrayList customArgs1 = new ArrayList();
+ customArgs1.add("marketing4", "false");
+ customArgs1.add("transactional4", "true");
+ email.addCustomArgs(customArgs1, 1);
+
+ email.setSendAt(1461775052, 1);
+
+ // The values below this comment are global to entire message
+
+ email.setFrom("test@example.com", "Example User 0");
+
+ email.setSubject("this subject overrides the Global Subject");
+
+ email.setGlobalSubject("Sending with SendGrid is Fun");
+
+ email.addContent(MimeType.TEXT, "and easy to do anywhere, even with C#");
+ email.addContent(MimeType.HTML, "and easy to do anywhere, even with C#");
+ ArrayList contents = new ArrayList();
+ contents.add("text/calendar", "Party Time!!");
+ contents.add("text/calendar2", "Party Time2!!");
+ email.addContents(contents);
+
+ email.addAttachment("balance_001.pdf",
+ "base64 encoded string",
+ "application/pdf",
+ "attachment",
+ "Balance Sheet");
+ ArrayList attachments = new ArrayList();
+ attachments.add("banner.png",
+ "base64 encoded string",
+ "image/png",
+ "inline",
+ "Banner");
+ attachments.add("banner2.png",
+ "base64 encoded string",
+ "image/png",
+ "inline",
+ "Banner2");
+ email.addAttachments(attachments);
+
+ email.setTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932");
+
+ email.addGlobalHeader("X-Day", "Monday");
+ ArrayList globalHeaders = new ArrayList();
+ globalHeaders.add("X-Month", "January" );
+ globalHeaders.add("X-Year", "2017");
+ email.addGlobalHeaders(globalHeaders);
+
+ email.addSection("%section1", "Substitution for Section 1 Tag");
+ ArrayList sections = new ArrayList();
+ sections.add("%section2%", "Substitution for Section 2 Tag");
+ sections.add("%section3%", "Substitution for Section 3 Tag");
+ email.addSections(sections);
+
+ email.addCategory("customer");
+ ArrayList categories = new ArrayList();
+ categories.add("vip");
+ categories.add("new_account");
+ email.addCategories(categories);
+
+ email.addGlobalCustomArg("campaign", "welcome");
+ ArrayList globalCustomArgs = new ArrayList();
+ globalCustomArgs.add("sequence2", "2");
+ globalCustomArgs.add("sequence3", "3");
+ email.addGlobalCustomArgs(globalCustomArgs);
+
+ ArrayList asmGroups = new ArrayList();
+ asmGroups.add(1);
+ asmGroups.add(4);
+ asmGroups.add(5);
+ email.setAsm(3, asmGroups);
+
+ email.setGlobalSendAt(1461775051);
+
+ email.setIpPoolName("23");
+
+ // This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
+ //email.setBatchId("some_batch_id");
+
+ email.setBccSetting(true, "test@example.com");
+
+ email.setBypassListManagement(true);
+
+ email.setFooterSetting(true, "Some Footer HTML", "Some Footer Text");
+
+ email.setSandBoxMode(true);
+
+ email.setSpamCheck(true, 1, "https://gotchya.example.com");
+
+ email.setClickTracking(true, false);
+
+ email.setOpenTracking(true, "Optional tag to replace with the open image in the body of the message");
+
+ email.setSubscriptionTracking(true,
+ "HTML to insert into the text / html portion of the message",
+ "text to insert into the text/plain portion of the message",
+ "substitution tag");
+
+ email.setGoogleAnalytics(true,
+ "some campaign",
+ "some content",
+ "some medium",
+ "some source",
+ "some term");
+
+ email.setReplyTo("test+reply@example.com", "Reply To Me");
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
+
+# Attachments
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ To to = new To("test@example.com", "Example User");
+ Subject subject = Subject("Sending with SendGrid is Fun");
+ PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
+ HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
+ SendGridMessage email = new SendGridMessage(from,
+ to,
+ subject,
+ plainTextContent,
+ htmlContent);
+ email.addAttachment("balance_001.pdf",
+ "base64 encoded string",
+ "application/pdf",
+ "attachment",
+ "Balance Sheet");
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
+
+# Transactional Templates
+
+The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+
+For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
+
+Template ID (replace with your own):
+
+```text
+13b8f94f-bcae-4ec6-b752-70d6cb59f932
+```
+
+Email Subject:
+
+```text
+<%subject%>
+```
+
+Template Body:
+
+```html
+
+
+
+
+
+Hello -name-,
+
+I'm glad you are trying out the template feature!
+
+<%body%>
+
+I hope you are having a great day in -city- :)
+
+
+
+```
+
+
+```java
+import com.sendgrid.*;
+import com.sendgrid.helpers.mail.*;
+
+public class SendGridExample {
+ public static void main(String[] args) throws SendGridException {
+ From from = new From("test@example.com", "Example User");
+ To to = new To("test@example.com", "Example User");
+ Subject subject = Subject("Sending with SendGrid is Fun");
+ PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
+ HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
+ SendGridMessage email = new SendGridMessage(from,
+ to,
+ subject,
+ plainTextContent,
+ htmlContent);
+ // See `Send Multiple Emails to Multiple Recipients` for additional methods for adding substitutions
+ email.addSubstitution("-name-", "Example User");
+ email.addSubstitution("-city-", "Denver");
+ email.setTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932");
+
+ SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ try {
+ SendGridResponse response = sendgrid.send(email);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (SendGridException ex) {
+ System.err.println(ex);
+ throw ex;
+ }
+ }
+}
+```
From f5e32f67132c939384781735877dbf2f741e288f Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Sun, 17 Sep 2017 09:18:55 -0700
Subject: [PATCH 002/345] Update mail-helper-refactor.md
---
proposals/mail-helper-refactor.md | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/proposals/mail-helper-refactor.md b/proposals/mail-helper-refactor.md
index 7e152bf5..2b35f142 100644
--- a/proposals/mail-helper-refactor.md
+++ b/proposals/mail-helper-refactor.md
@@ -1,6 +1,6 @@
# Send a Single Email to a Single Recipient
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+The following code assumes you are storing the API key in an environment variable (recommended).
This is the minimum code needed to send an email.
@@ -37,7 +37,7 @@ public class SendGridExample {
# Send a Single Email to Multiple Recipients
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+The following code assumes you are storing the API key in an environment variable (recommended).
```java
import com.sendgrid.*;
@@ -76,7 +76,7 @@ public class SendGridExample {
# Send Multiple Emails to Multiple Recipients
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+The following code assumes you are storing the API key in an environment variable (recommended).
```java
@@ -128,7 +128,7 @@ public class SendGridExample {
# Kitchen Sink - an example with all settings used
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+The following code assumes you are storing the API key in an environment variable (recommended).
```java
@@ -352,8 +352,7 @@ public class SendGridExample {
# Attachments
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
-
+The following code assumes you are storing the API key in an environment variable (recommended).
```java
import com.sendgrid.*;
@@ -393,7 +392,7 @@ public class SendGridExample {
# Transactional Templates
-The following code assumes you are storing the API key in an [environment variable (recommended)](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment). If you don't have your key stored in an environment variable, you can assign it directly to `apikey` for testing purposes.
+The following code assumes you are storing the API key in an environment variable (recommended).
For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
From 338cb04c4099bcbe8a8f5b55e106b06f699c332d Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Sun, 17 Sep 2017 09:19:50 -0700
Subject: [PATCH 003/345] Update mail-helper-refactor.md
---
proposals/mail-helper-refactor.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/proposals/mail-helper-refactor.md b/proposals/mail-helper-refactor.md
index 2b35f142..b050491a 100644
--- a/proposals/mail-helper-refactor.md
+++ b/proposals/mail-helper-refactor.md
@@ -12,7 +12,7 @@ public class SendGridExample {
public static void main(String[] args) throws SendGridException {
From from = new From("test@example.com", "Example User");
To to = new To("test@example.com", "Example User");
- Subject subject = Subject("Sending with SendGrid is Fun");
+ Subject subject = new Subject("Sending with SendGrid is Fun");
PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
SendGridMessage email = new SendGridMessage(from,
@@ -51,7 +51,7 @@ public class SendGridExample {
tos.add(new To("test1@example.com", "Example User1"));
tos.add(new To("test2@example.com", "Example User2"));
tos.add(new To("test3@example.com", "Example User3"));
- Subject subject = Subject("Sending with SendGrid is Fun");
+ Subject subject = new Subject("Sending with SendGrid is Fun");
PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
SendGridMessage email = new SendGridMessage(from,
@@ -101,7 +101,7 @@ public class SendGridExample {
sub.add("-github-", "http://github.com/caseyw");
tos.add(new To("test3@example.com", "Example User3"), sub);
// Alternatively, you can pass in a collection of subjects OR add a subject to the `To` object
- Subject subject = Subject("Hi -name-!");
+ Subject subject = new Subject("Hi -name-!");
Substitution globalSubstitution = new Substitution("-time-", "");
PlainTextContent plainTextContent = new PlainTextContent("Hello -name-, your github is -github-, email sent at -time-");
HtmlContent htmlContent = new HtmlContent("Hello -name-, your github is here email sent at -time-");
@@ -140,7 +140,7 @@ public class SendGridExample {
public static void main(String[] args) throws SendGridException {
From from = new From("test@example.com", "Example User");
To to = new To("test@example.com", "Example User");
- Subject subject = Subject("Sending with SendGrid is Fun");
+ Subject subject = new Subject("Sending with SendGrid is Fun");
PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
SendGridMessage email = new SendGridMessage(from,
@@ -362,7 +362,7 @@ public class SendGridExample {
public static void main(String[] args) throws SendGridException {
From from = new From("test@example.com", "Example User");
To to = new To("test@example.com", "Example User");
- Subject subject = Subject("Sending with SendGrid is Fun");
+ Subject subject = new Subject("Sending with SendGrid is Fun");
PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
SendGridMessage email = new SendGridMessage(from,
@@ -437,7 +437,7 @@ public class SendGridExample {
public static void main(String[] args) throws SendGridException {
From from = new From("test@example.com", "Example User");
To to = new To("test@example.com", "Example User");
- Subject subject = Subject("Sending with SendGrid is Fun");
+ Subject subject = new Subject("Sending with SendGrid is Fun");
PlainTextContent plainTextContent = new PlainTextContent("and easy to do anywhere, even with Java");
HtmlContent htmlContent = new HtmlContent("and easy to do anywhere, even with Java");
SendGridMessage email = new SendGridMessage(from,
From 6d5b12654724323a91d53b2e758987a607d2e224 Mon Sep 17 00:00:00 2001
From: Mattia Barbon
Date: Tue, 19 Sep 2017 13:18:05 +0200
Subject: [PATCH 004/345] Alway serialize click-tracking parameters
Othwerwise setting them to a false value produces an invalid request, because
the fields are required.
Fixes #181
---
.../sendgrid/helpers/mail/objects/ClickTrackingSetting.java | 1 -
src/test/java/com/sendgrid/helpers/MailTest.java | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index 839c8fbf..9214eb45 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
public class ClickTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("enable_text") private boolean enableText;
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index e4eedd58..7ad8bfe5 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -170,7 +170,7 @@ public void testKitchenSink() throws IOException {
TrackingSettings trackingSettings = new TrackingSettings();
ClickTrackingSetting clickTrackingSetting = new ClickTrackingSetting();
clickTrackingSetting.setEnable(true);
- clickTrackingSetting.setEnableText(true);
+ clickTrackingSetting.setEnableText(false);
trackingSettings.setClickTrackingSetting(clickTrackingSetting);
OpenTrackingSetting openTrackingSetting = new OpenTrackingSetting();
openTrackingSetting.setEnable(true);
@@ -197,7 +197,7 @@ public void testKitchenSink() throws IOException {
replyTo.setEmail("test@example.com");
mail.setReplyTo(replyTo);
- Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"some text here\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"Footer Text\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":true},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"html to insert into the text/html portion of the message\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
+ Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"some text here\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"Footer Text\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":false},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"html to insert into the text/html portion of the message\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
}
@Test
From 3acee9fa3c25b784ad2f3380ea951fa0bc505bc1 Mon Sep 17 00:00:00 2001
From: Stephen Calabrese
Date: Sun, 1 Oct 2017 15:08:23 -0500
Subject: [PATCH 005/345] The license file is put into the release jar.
---
pom.xml | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 07545420..86ef37d8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,15 @@
scm:git:git@github.com:sendgrid/sendgrid-java.git
HEAD
-
+
+
+
+ ${basedir}
+
+ LICENSE.txt
+
+
+
org.apache.maven.plugins
@@ -119,4 +127,4 @@
test
-
+
\ No newline at end of file
From e61af6c70ac0663dfa4c09cb73c48607d5dbc433 Mon Sep 17 00:00:00 2001
From: Stephen Calabrese
Date: Sun, 1 Oct 2017 15:37:56 -0500
Subject: [PATCH 006/345] Adding SendGridApi interface.
---
src/main/java/com/sendgrid/SendGrid.java | 2 +-
src/main/java/com/sendgrid/SendGridApi.java | 34 +++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 src/main/java/com/sendgrid/SendGridApi.java
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 421b11a9..061316b8 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -7,7 +7,7 @@
/**
* Class SendGrid allows for quick and easy access to the SendGrid API.
*/
-public class SendGrid {
+public class SendGrid implements SendGridApi{
private static final String VERSION = "3.0.0";
private static final String USER_AGENT = "sendgrid/" + VERSION + ";java";
diff --git a/src/main/java/com/sendgrid/SendGridApi.java b/src/main/java/com/sendgrid/SendGridApi.java
new file mode 100644
index 00000000..d6273b36
--- /dev/null
+++ b/src/main/java/com/sendgrid/SendGridApi.java
@@ -0,0 +1,34 @@
+package com.sendgrid;
+
+import java.io.IOException;
+import java.util.Map;
+
+public interface SendGridApi {
+
+ public void initializeSendGrid(String apiKey);
+
+ public String getLibraryVersion();
+
+ public String getVersion();
+
+ public void setVersion(String version);
+
+ public Map getRequestHeaders();
+
+ public Map addRequestHeader(String key, String value);
+
+ public Map removeRequestHeader(String key);
+ public String getHost();
+
+ public void setHost(String host);
+
+ /**
+ * Class makeCall makes the call to the SendGrid API, override this method for testing.
+ */
+ public Response makeCall(Request request) throws IOException;
+
+ /**
+ * Class api sets up the request to the SendGrid API, this is main interface.
+ */
+ public Response api(Request request) throws IOException;
+}
From b8af1fc0f7dfdf494d99b7fc1cd5ffb2bcd61a72 Mon Sep 17 00:00:00 2001
From: Stephen Calabrese
Date: Sun, 1 Oct 2017 17:22:10 -0500
Subject: [PATCH 007/345] Fixing Mail deserialization issue.
---
.../java/com/sendgrid/helpers/mail/Mail.java | 70 +++++++++++++++++++
.../sendgrid/helpers/mail/objects/ASM.java | 25 +++++++
.../helpers/mail/objects/Attachments.java | 49 +++++++++++++
.../helpers/mail/objects/BccSettings.java | 28 ++++++++
.../mail/objects/ClickTrackingSetting.java | 25 +++++++
.../helpers/mail/objects/Content.java | 31 ++++++++
.../sendgrid/helpers/mail/objects/Email.java | 31 ++++++++
.../helpers/mail/objects/FooterSetting.java | 34 +++++++++
.../mail/objects/GoogleAnalyticsSetting.java | 52 ++++++++++++++
.../helpers/mail/objects/MailSettings.java | 49 +++++++++++++
.../mail/objects/OpenTrackingSetting.java | 29 ++++++++
.../helpers/mail/objects/Personalization.java | 65 ++++++++++++++++-
.../helpers/mail/objects/Setting.java | 22 ++++++
.../mail/objects/SpamCheckSetting.java | 31 ++++++++
.../objects/SubscriptionTrackingSetting.java | 40 +++++++++++
.../mail/objects/TrackingSettings.java | 43 ++++++++++++
.../java/com/sendgrid/helpers/MailTest.java | 14 ++++
17 files changed, 637 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index beba5a53..99f08556 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -281,4 +281,74 @@ public String buildPretty() throws IOException {
throw ex;
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((batchId == null) ? 0 : batchId.hashCode());
+ result = prime * result + ((categories == null) ? 0 : categories.hashCode());
+ result = prime * result + ((customArgs == null) ? 0 : customArgs.hashCode());
+ result = prime * result + ((headers == null) ? 0 : headers.hashCode());
+ result = prime * result + ((ipPoolId == null) ? 0 : ipPoolId.hashCode());
+ result = prime * result + ((sections == null) ? 0 : sections.hashCode());
+ result = prime * result + (int) (sendAt ^ (sendAt >>> 32));
+ result = prime * result + ((subject == null) ? 0 : subject.hashCode());
+ result = prime * result + ((templateId == null) ? 0 : templateId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Mail other = (Mail) obj;
+ if (batchId == null) {
+ if (other.batchId != null)
+ return false;
+ } else if (!batchId.equals(other.batchId))
+ return false;
+ if (categories == null) {
+ if (other.categories != null)
+ return false;
+ } else if (!categories.equals(other.categories))
+ return false;
+ if (customArgs == null) {
+ if (other.customArgs != null)
+ return false;
+ } else if (!customArgs.equals(other.customArgs))
+ return false;
+ if (headers == null) {
+ if (other.headers != null)
+ return false;
+ } else if (!headers.equals(other.headers))
+ return false;
+ if (ipPoolId == null) {
+ if (other.ipPoolId != null)
+ return false;
+ } else if (!ipPoolId.equals(other.ipPoolId))
+ return false;
+ if (sections == null) {
+ if (other.sections != null)
+ return false;
+ } else if (!sections.equals(other.sections))
+ return false;
+ if (sendAt != other.sendAt)
+ return false;
+ if (subject == null) {
+ if (other.subject != null)
+ return false;
+ } else if (!subject.equals(other.subject))
+ return false;
+ if (templateId == null) {
+ if (other.templateId != null)
+ return false;
+ } else if (!templateId.equals(other.templateId))
+ return false;
+ return true;
+ }
}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
index 1a65a65d..29952ae1 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
@@ -28,4 +28,29 @@ public int[] getGroupsToDisplay() {
public void setGroupsToDisplay(int[] groupsToDisplay) {
this.groupsToDisplay = Arrays.copyOf(groupsToDisplay, groupsToDisplay.length);
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + groupId;
+ result = prime * result + Arrays.hashCode(groupsToDisplay);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ASM other = (ASM) obj;
+ if (groupId != other.groupId)
+ return false;
+ if (!Arrays.equals(groupsToDisplay, other.groupsToDisplay))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
index 9323b837..6bec689f 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
@@ -137,4 +137,53 @@ public Attachments build() {
return attachments;
}
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((content == null) ? 0 : content.hashCode());
+ result = prime * result + ((contentId == null) ? 0 : contentId.hashCode());
+ result = prime * result + ((disposition == null) ? 0 : disposition.hashCode());
+ result = prime * result + ((filename == null) ? 0 : filename.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Attachments other = (Attachments) obj;
+ if (content == null) {
+ if (other.content != null)
+ return false;
+ } else if (!content.equals(other.content))
+ return false;
+ if (contentId == null) {
+ if (other.contentId != null)
+ return false;
+ } else if (!contentId.equals(other.contentId))
+ return false;
+ if (disposition == null) {
+ if (other.disposition != null)
+ return false;
+ } else if (!disposition.equals(other.disposition))
+ return false;
+ if (filename == null) {
+ if (other.filename != null)
+ return false;
+ } else if (!filename.equals(other.filename))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
index 176387fa..fa9758f2 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
@@ -26,4 +26,32 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((email == null) ? 0 : email.hashCode());
+ result = prime * result + (enable ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BccSettings other = (BccSettings) obj;
+ if (email == null) {
+ if (other.email != null)
+ return false;
+ } else if (!email.equals(other.email))
+ return false;
+ if (enable != other.enable)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index 839c8fbf..2abc58c8 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -26,4 +26,29 @@ public boolean getEnableText() {
public void setEnableText(boolean enableText) {
this.enableText = enableText;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ result = prime * result + (enableText ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ClickTrackingSetting other = (ClickTrackingSetting) obj;
+ if (enable != other.enable)
+ return false;
+ if (enableText != other.enableText)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
index b00f9566..faa9820b 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
@@ -35,4 +35,35 @@ public String getValue() {
public void setValue(String value) {
this.value = value;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Content other = (Content) obj;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
index 43396a85..cbfce557 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
@@ -39,4 +39,35 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((email == null) ? 0 : email.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Email other = (Email) obj;
+ if (email == null) {
+ if (other.email != null)
+ return false;
+ } else if (!email.equals(other.email))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
index 8e542c7f..1b2ece01 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
@@ -36,4 +36,38 @@ public String getHtml() {
public void setHtml(String html) {
this.html = html;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ result = prime * result + ((html == null) ? 0 : html.hashCode());
+ result = prime * result + ((text == null) ? 0 : text.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FooterSetting other = (FooterSetting) obj;
+ if (enable != other.enable)
+ return false;
+ if (html == null) {
+ if (other.html != null)
+ return false;
+ } else if (!html.equals(other.html))
+ return false;
+ if (text == null) {
+ if (other.text != null)
+ return false;
+ } else if (!text.equals(other.text))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
index ce30edbc..594743d6 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
@@ -66,4 +66,56 @@ public String getCampaignMedium() {
public void setCampaignMedium(String campaignMedium) {
this.campaignMedium = campaignMedium;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((campaignContent == null) ? 0 : campaignContent.hashCode());
+ result = prime * result + ((campaignMedium == null) ? 0 : campaignMedium.hashCode());
+ result = prime * result + ((campaignName == null) ? 0 : campaignName.hashCode());
+ result = prime * result + ((campaignSource == null) ? 0 : campaignSource.hashCode());
+ result = prime * result + ((campaignTerm == null) ? 0 : campaignTerm.hashCode());
+ result = prime * result + (enable ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GoogleAnalyticsSetting other = (GoogleAnalyticsSetting) obj;
+ if (campaignContent == null) {
+ if (other.campaignContent != null)
+ return false;
+ } else if (!campaignContent.equals(other.campaignContent))
+ return false;
+ if (campaignMedium == null) {
+ if (other.campaignMedium != null)
+ return false;
+ } else if (!campaignMedium.equals(other.campaignMedium))
+ return false;
+ if (campaignName == null) {
+ if (other.campaignName != null)
+ return false;
+ } else if (!campaignName.equals(other.campaignName))
+ return false;
+ if (campaignSource == null) {
+ if (other.campaignSource != null)
+ return false;
+ } else if (!campaignSource.equals(other.campaignSource))
+ return false;
+ if (campaignTerm == null) {
+ if (other.campaignTerm != null)
+ return false;
+ } else if (!campaignTerm.equals(other.campaignTerm))
+ return false;
+ if (enable != other.enable)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
index 63580458..0590b224 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
@@ -56,4 +56,53 @@ public SpamCheckSetting getSpamCheck() {
public void setSpamCheckSetting(SpamCheckSetting spamCheckSetting) {
this.spamCheckSetting = spamCheckSetting;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bccSettings == null) ? 0 : bccSettings.hashCode());
+ result = prime * result + ((bypassListManagement == null) ? 0 : bypassListManagement.hashCode());
+ result = prime * result + ((footerSetting == null) ? 0 : footerSetting.hashCode());
+ result = prime * result + ((sandBoxMode == null) ? 0 : sandBoxMode.hashCode());
+ result = prime * result + ((spamCheckSetting == null) ? 0 : spamCheckSetting.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MailSettings other = (MailSettings) obj;
+ if (bccSettings == null) {
+ if (other.bccSettings != null)
+ return false;
+ } else if (!bccSettings.equals(other.bccSettings))
+ return false;
+ if (bypassListManagement == null) {
+ if (other.bypassListManagement != null)
+ return false;
+ } else if (!bypassListManagement.equals(other.bypassListManagement))
+ return false;
+ if (footerSetting == null) {
+ if (other.footerSetting != null)
+ return false;
+ } else if (!footerSetting.equals(other.footerSetting))
+ return false;
+ if (sandBoxMode == null) {
+ if (other.sandBoxMode != null)
+ return false;
+ } else if (!sandBoxMode.equals(other.sandBoxMode))
+ return false;
+ if (spamCheckSetting == null) {
+ if (other.spamCheckSetting != null)
+ return false;
+ } else if (!spamCheckSetting.equals(other.spamCheckSetting))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
index aeb7ede1..b5508946 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
@@ -26,4 +26,33 @@ public String getSubstitutionTag() {
public void setSubstitutionTag(String substitutionTag) {
this.substitutionTag = substitutionTag;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ result = prime * result + ((substitutionTag == null) ? 0 : substitutionTag.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ OpenTrackingSetting other = (OpenTrackingSetting) obj;
+ if (enable != other.enable)
+ return false;
+ if (substitutionTag == null) {
+ if (other.substitutionTag != null)
+ return false;
+ } else if (!substitutionTag.equals(other.substitutionTag))
+ return false;
+ return true;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index 734dc9c0..e3646451 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -143,5 +143,68 @@ public long sendAt() {
public void setSendAt(long sendAt) {
this.sendAt = sendAt;
}
-
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bccs == null) ? 0 : bccs.hashCode());
+ result = prime * result + ((ccs == null) ? 0 : ccs.hashCode());
+ result = prime * result + ((customArgs == null) ? 0 : customArgs.hashCode());
+ result = prime * result + ((headers == null) ? 0 : headers.hashCode());
+ result = prime * result + (int) (sendAt ^ (sendAt >>> 32));
+ result = prime * result + ((subject == null) ? 0 : subject.hashCode());
+ result = prime * result + ((substitutions == null) ? 0 : substitutions.hashCode());
+ result = prime * result + ((tos == null) ? 0 : tos.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Personalization other = (Personalization) obj;
+ if (bccs == null) {
+ if (other.bccs != null)
+ return false;
+ } else if (!bccs.equals(other.bccs))
+ return false;
+ if (ccs == null) {
+ if (other.ccs != null)
+ return false;
+ } else if (!ccs.equals(other.ccs))
+ return false;
+ if (customArgs == null) {
+ if (other.customArgs != null)
+ return false;
+ } else if (!customArgs.equals(other.customArgs))
+ return false;
+ if (headers == null) {
+ if (other.headers != null)
+ return false;
+ } else if (!headers.equals(other.headers))
+ return false;
+ if (sendAt != other.sendAt)
+ return false;
+ if (subject == null) {
+ if (other.subject != null)
+ return false;
+ } else if (!subject.equals(other.subject))
+ return false;
+ if (substitutions == null) {
+ if (other.substitutions != null)
+ return false;
+ } else if (!substitutions.equals(other.substitutions))
+ return false;
+ if (tos == null) {
+ if (other.tos != null)
+ return false;
+ } else if (!tos.equals(other.tos))
+ return false;
+ return true;
+ }
}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
index 5818a145..2fab69e8 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
@@ -16,4 +16,26 @@ public boolean getEnable() {
public void setEnable(boolean enable) {
this.enable = enable;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Setting other = (Setting) obj;
+ if (enable != other.enable)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
index 85d1dc10..ba5c0105 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
@@ -36,4 +36,35 @@ public String getPostToUrl() {
public void setPostToUrl(String postToUrl) {
this.postToUrl = postToUrl;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ result = prime * result + ((postToUrl == null) ? 0 : postToUrl.hashCode());
+ result = prime * result + spamThreshold;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SpamCheckSetting other = (SpamCheckSetting) obj;
+ if (enable != other.enable)
+ return false;
+ if (postToUrl == null) {
+ if (other.postToUrl != null)
+ return false;
+ } else if (!postToUrl.equals(other.postToUrl))
+ return false;
+ if (spamThreshold != other.spamThreshold)
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
index ad1121c2..da02d8e9 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
@@ -46,4 +46,44 @@ public String getSubstitutionTag() {
public void setSubstitutionTag(String substitutionTag) {
this.substitutionTag = substitutionTag;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (enable ? 1231 : 1237);
+ result = prime * result + ((html == null) ? 0 : html.hashCode());
+ result = prime * result + ((substitutionTag == null) ? 0 : substitutionTag.hashCode());
+ result = prime * result + ((text == null) ? 0 : text.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SubscriptionTrackingSetting other = (SubscriptionTrackingSetting) obj;
+ if (enable != other.enable)
+ return false;
+ if (html == null) {
+ if (other.html != null)
+ return false;
+ } else if (!html.equals(other.html))
+ return false;
+ if (substitutionTag == null) {
+ if (other.substitutionTag != null)
+ return false;
+ } else if (!substitutionTag.equals(other.substitutionTag))
+ return false;
+ if (text == null) {
+ if (other.text != null)
+ return false;
+ } else if (!text.equals(other.text))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
index 4da565d5..06ff62df 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
@@ -46,4 +46,47 @@ public GoogleAnalyticsSetting getGoogleAnalyticsSetting() {
public void setGoogleAnalyticsSetting(GoogleAnalyticsSetting googleAnalyticsSetting) {
this.googleAnalyticsSetting = googleAnalyticsSetting;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((clickTrackingSetting == null) ? 0 : clickTrackingSetting.hashCode());
+ result = prime * result + ((googleAnalyticsSetting == null) ? 0 : googleAnalyticsSetting.hashCode());
+ result = prime * result + ((openTrackingSetting == null) ? 0 : openTrackingSetting.hashCode());
+ result = prime * result + ((subscriptionTrackingSetting == null) ? 0 : subscriptionTrackingSetting.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TrackingSettings other = (TrackingSettings) obj;
+ if (clickTrackingSetting == null) {
+ if (other.clickTrackingSetting != null)
+ return false;
+ } else if (!clickTrackingSetting.equals(other.clickTrackingSetting))
+ return false;
+ if (googleAnalyticsSetting == null) {
+ if (other.googleAnalyticsSetting != null)
+ return false;
+ } else if (!googleAnalyticsSetting.equals(other.googleAnalyticsSetting))
+ return false;
+ if (openTrackingSetting == null) {
+ if (other.openTrackingSetting != null)
+ return false;
+ } else if (!openTrackingSetting.equals(other.openTrackingSetting))
+ return false;
+ if (subscriptionTrackingSetting == null) {
+ if (other.subscriptionTrackingSetting != null)
+ return false;
+ } else if (!subscriptionTrackingSetting.equals(other.subscriptionTrackingSetting))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index e4eedd58..a8b49fe3 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -208,4 +208,18 @@ public void fromShouldReturnCorrectFrom() {
Assert.assertSame(from, mail.getFrom());
}
+
+ @Test
+ public void mailDeserialization() throws IOException {
+ Email to = new Email("foo@bar.com");
+ Content content = new Content("text/plain", "test");
+ Email from = new Email("no-reply@bar.com");
+ Mail mail = new Mail(from, "subject", to, content);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String json = mapper.writeValueAsString(mail);
+ Mail deserialized = mapper.readValue(json, Mail.class);
+
+ Assert.assertEquals(deserialized, mail);
+ }
}
From 4d0394e4cb7c73f3e9b225e35634a24743baff30 Mon Sep 17 00:00:00 2001
From: Peter Pan
Date: Mon, 2 Oct 2017 17:11:17 +0200
Subject: [PATCH 008/345] CONTIBUTING.md broken link fixed.
---
CONTRIBUTING.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e627ccc1..c310931b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -51,7 +51,7 @@ Before you decide to create a new issue, please try the following:
### Please use our Bug Report Template
-In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-java/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
+In order to make the process easier, we've included a [sample bug report template](https://github.com/P3trur0/sendgrid-java/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
## Improvements to the Codebase
From 473fb56b13191f6215a6f45b9f6be855bc5b43b1 Mon Sep 17 00:00:00 2001
From: Peter Pan
Date: Mon, 2 Oct 2017 17:14:34 +0200
Subject: [PATCH 009/345] contributing.md broken link fixed
---
CONTRIBUTING.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c310931b..990b2fdf 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -51,7 +51,7 @@ Before you decide to create a new issue, please try the following:
### Please use our Bug Report Template
-In order to make the process easier, we've included a [sample bug report template](https://github.com/P3trur0/sendgrid-java/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
+In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-java/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
## Improvements to the Codebase
From 2c0183d7770a841ce417897d5a8241b85af4a7a2 Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Tue, 3 Oct 2017 09:28:28 +0200
Subject: [PATCH 010/345] Changes serialization type for settings to serialize
values only if they are non-empty instead of defaults.
---
.../helpers/mail/objects/BccSettings.java | 2 +-
.../mail/objects/ClickTrackingSetting.java | 2 +-
.../helpers/mail/objects/FooterSetting.java | 2 +-
.../mail/objects/GoogleAnalyticsSetting.java | 2 +-
.../mail/objects/OpenTrackingSetting.java | 2 +-
.../mail/objects/SpamCheckSetting.java | 2 +-
.../objects/SubscriptionTrackingSetting.java | 2 +-
.../objects/SettingsSerializationTest.java | 86 +++++++++++++++++++
8 files changed, 93 insertions(+), 7 deletions(-)
create mode 100644 src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
index 176387fa..79f6cc5c 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class BccSettings {
@JsonProperty("enable") private boolean enable;
@JsonProperty("email") private String email;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index 839c8fbf..5c014d3f 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class ClickTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("enable_text") private boolean enableText;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
index 8e542c7f..c179a606 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class FooterSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("text") private String text;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
index ce30edbc..45485234 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class GoogleAnalyticsSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("utm_source") private String campaignSource;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
index aeb7ede1..ac87f74d 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class OpenTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("substitution_tag") private String substitutionTag;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
index 85d1dc10..a0ae0269 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class SpamCheckSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("threshold") private int spamThreshold;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
index ad1121c2..839609bc 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
@@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-@JsonInclude(Include.NON_DEFAULT)
+@JsonInclude(Include.NON_EMPTY)
public class SubscriptionTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("text") private String text;
diff --git a/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java b/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
new file mode 100644
index 00000000..48fbfcc6
--- /dev/null
+++ b/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
@@ -0,0 +1,86 @@
+package com.sendgrid.helpers.mail.objects;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.sendgrid.BccSettings;
+import com.sendgrid.ClickTrackingSetting;
+import com.sendgrid.FooterSetting;
+import com.sendgrid.GoogleAnalyticsSetting;
+import com.sendgrid.OpenTrackingSetting;
+import com.sendgrid.SpamCheckSetting;
+import com.sendgrid.SubscriptionTrackingSetting;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SettingsSerializationTest {
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void testOpenTrackingSettingSerialization() throws Exception {
+ OpenTrackingSetting setting = new OpenTrackingSetting();
+ setting.setEnable(false);
+
+ String jsonOne = mapper.writeValueAsString(setting);
+ Assert.assertEquals(jsonOne, "{\"enable\":false}");
+ }
+
+ @Test
+ public void testClickTrackingSettingSerialization() throws Exception {
+ ClickTrackingSetting setting = new ClickTrackingSetting();
+ setting.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(setting);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false,\"enable_text\":false}");
+ }
+
+ @Test
+ public void testSubscriptionTrackingSettingSerialization() throws Exception {
+ SubscriptionTrackingSetting setting = new SubscriptionTrackingSetting();
+ setting.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(setting);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ }
+
+ @Test
+ public void testGoogleAnalyticsTrackingSettingSerialization() throws Exception {
+ GoogleAnalyticsSetting setting = new GoogleAnalyticsSetting();
+ setting.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(setting);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ }
+
+ @Test
+ public void testSpamCheckSettingSerialization() throws Exception {
+ SpamCheckSetting setting = new SpamCheckSetting();
+ setting.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(setting);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false,\"threshold\":0}");
+ }
+
+ @Test
+ public void testFooterSettingSerialization() throws Exception {
+ FooterSetting setting = new FooterSetting();
+ setting.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(setting);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ }
+
+ @Test
+ public void testBccSettingsSerialization() throws Exception {
+ BccSettings settings = new BccSettings();
+ settings.setEnable(false);
+
+ String jsonTwo = mapper.writeValueAsString(settings);
+ System.out.println(jsonTwo);
+ Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ }
+}
From 2199f1225806f29aae4c09fec8bd4cf32fe68964 Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Tue, 3 Oct 2017 21:11:07 +0200
Subject: [PATCH 011/345] Adds prism installation script to travis.
---
.travis.yml | 5 +++++
test/prism.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 test/prism.sh
diff --git a/.travis.yml b/.travis.yml
index 48807070..a07cec04 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,6 +10,11 @@ matrix:
jdk: oraclejdk7
- os: linux
jdk: oraclejdk8
+before_script:
+- mkdir -p prism/bin
+- export PATH=$PATH:$PWD/prism/bin/
+- ./test/prism.sh
+
after_script:
- "./gradlew build"
- "./scripts/upload.sh"
diff --git a/test/prism.sh b/test/prism.sh
new file mode 100644
index 00000000..5d9d3002
--- /dev/null
+++ b/test/prism.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+install () {
+
+set -eu
+
+UNAME=$(uname)
+ARCH=$(uname -m)
+if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
+ echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases"
+ exit 1
+fi
+
+if [ "$UNAME" = "Darwin" ] ; then
+ OSX_ARCH=$(uname -m)
+ if [ "${OSX_ARCH}" = "x86_64" ] ; then
+ PLATFORM="darwin_amd64"
+ fi
+elif [ "$UNAME" = "Linux" ] ; then
+ LINUX_ARCH=$(uname -m)
+ if [ "${LINUX_ARCH}" = "i686" ] ; then
+ PLATFORM="linux_386"
+ elif [ "${LINUX_ARCH}" = "x86_64" ] ; then
+ PLATFORM="linux_amd64"
+ fi
+fi
+
+#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
+LATEST="v0.1.5"
+URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM"
+DEST=./prism/bin/prism
+
+if [ -z $LATEST ] ; then
+ echo "Error requesting. Download binary from ${URL}"
+ exit 1
+else
+ curl -L $URL -o $DEST
+ chmod +x $DEST
+fi
+}
+
+install
\ No newline at end of file
From 008b04a280d1bc0c2a9ebde1f6eb5cd5d7339344 Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Wed, 4 Oct 2017 07:36:20 +0200
Subject: [PATCH 012/345] Creates gradle task to download and start prism
locally.
---
build.gradle | 5 ++++
scripts/startPrism.sh | 58 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
create mode 100755 scripts/startPrism.sh
diff --git a/build.gradle b/build.gradle
index 881a496e..1a7feba9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -94,6 +94,11 @@ task renameSendGridVersionJarToSendGridJar {
}
}
+task startPrism(type: Exec) {
+ workingDir 'scripts'
+ commandLine './startPrism.sh'
+}
+
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
diff --git a/scripts/startPrism.sh b/scripts/startPrism.sh
new file mode 100755
index 00000000..7438aa5d
--- /dev/null
+++ b/scripts/startPrism.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+set -eu
+
+install () {
+
+echo "Installing Prism..."
+
+UNAME=$(uname)
+ARCH=$(uname -m)
+if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then
+ echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases"
+ exit 1
+fi
+
+if [ "$UNAME" = "Darwin" ] ; then
+ OSX_ARCH=$(uname -m)
+ if [ "${OSX_ARCH}" = "x86_64" ] ; then
+ PLATFORM="darwin_amd64"
+ fi
+elif [ "$UNAME" = "Linux" ] ; then
+ LINUX_ARCH=$(uname -m)
+ if [ "${LINUX_ARCH}" = "i686" ] ; then
+ PLATFORM="linux_386"
+ elif [ "${LINUX_ARCH}" = "x86_64" ] ; then
+ PLATFORM="linux_amd64"
+ fi
+fi
+
+mkdir -p ../prism/bin
+#LATEST=$(curl -s https://api.github.com/repos/stoplightio/prism/tags | grep -Eo '"name":.*?[^\\]",' | head -n 1 | sed 's/[," ]//g' | cut -d ':' -f 2)
+LATEST="v0.6.21"
+URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM"
+DEST=../prism/bin/prism
+
+if [ -z $LATEST ] ; then
+ echo "Error requesting. Download binary from ${URL}"
+ exit 1
+else
+ curl -L $URL -o $DEST
+ chmod +x $DEST
+fi
+}
+
+run () {
+ echo "Running prism..."
+ cd ../prism/bin
+ prism run --mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
+}
+
+if [ -f ../prism/bin/prism ]; then
+ echo "Prism is already installed."
+ run
+else
+ echo "Prism is not installed."
+ install
+ run
+fi
\ No newline at end of file
From a6036a1131c1826aa1966c4cc395ba43126cb4b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=ADcero=20Pablo?=
Date: Fri, 6 Oct 2017 18:19:32 -0300
Subject: [PATCH 013/345] Update README.md
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 1847b034..99fceeb3 100644
--- a/README.md
+++ b/README.md
@@ -221,5 +221,4 @@ sendgrid-java is guided and supported by the SendGrid [Developer Experience Team
sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
-![SendGrid Logo]
-(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)
+
From ad6a5294e6181b39a2dc0a41de503fabf99da93a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=ADcero=20Pablo?=
Date: Fri, 6 Oct 2017 18:22:49 -0300
Subject: [PATCH 014/345] Update TROUBLESHOOTING.md
---
TROUBLESHOOTING.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md
index 35b2b348..7a4aace1 100644
--- a/TROUBLESHOOTING.md
+++ b/TROUBLESHOOTING.md
@@ -54,7 +54,7 @@ You can just drop the jar file in. It's a fat jar - it has all the dependencies
## Versions
-We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guarenteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-java/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-java/releases) section.
+We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guaranteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-java/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-java/releases) section.
## Environment Variables and Your SendGrid API Key
@@ -96,4 +96,4 @@ repositories {
Since Android SDK 23, HttpClient is no longer supported. Some workarounds can be found [here](http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio).
-We have an issue to remove that dependency [here](https://github.com/sendgrid/java-http-client/issues/2), please upvote to move it up the queue.
\ No newline at end of file
+We have an issue to remove that dependency [here](https://github.com/sendgrid/java-http-client/issues/2), please upvote to move it up the queue.
From 9ed5220f68b39ed4047a862afff6392a993fe8c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=ADcero=20Pablo?=
Date: Fri, 6 Oct 2017 18:41:42 -0300
Subject: [PATCH 015/345] Update USAGE.md
---
USAGE.md | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index 308ca259..96b63ed8 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -246,7 +246,7 @@ For more information about alerts, please see our [User Guide](https://sendgrid.
```
## Retrieve all alerts
-**This endpoint allows you to retieve all of your alerts.**
+**This endpoint allows you to retrieve all of your alerts.**
Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics.
* Usage alerts allow you to set the threshold at which an alert will be sent.
@@ -358,7 +358,7 @@ For more information about alerts, please see our [User Guide](https://sendgrid.
## Create API keys
-**This enpoint allows you to create a new random API Key for the user.**
+**This endpoint allows you to create a new random API Key for the user.**
A JSON request body containing a "name" property is required. If number of maximum keys is reached, HTTP 403 will be returned.
@@ -2339,7 +2339,7 @@ If an IP pool is NOT specified for an email, it will use any IP available, inclu
```
## Retrieve all IP pools.
-**This endpoint allows you to retreive all of your IP pools.**
+**This endpoint allows you to retrieve all of your IP pools.**
IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.
@@ -3321,7 +3321,7 @@ By integrating with New Relic, you can send your SendGrid email statistics to yo
**This endpoint returns a list of all scopes that this user has access to.**
-API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
+API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissions, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
### GET /scopes
@@ -3443,7 +3443,7 @@ Sender Identities are required to be verified before use. If your domain has bee
```
## Delete a Sender Identity
-**This endoint allows you to delete one of your sender identities.**
+**This endpoint allows you to delete one of your sender identities.**
Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.
@@ -3466,7 +3466,7 @@ Sender Identities are required to be verified before use. If your domain has bee
```
## Resend Sender Identity Verification
-**This enpdoint allows you to resend a sender identity verification email.**
+**This endpoint allows you to resend a sender identity verification email.**
Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.
@@ -3869,7 +3869,7 @@ Subuser monitor settings allow you to receive a sample of an outgoing message by
```
## Retrieve the monthly email statistics for a single subuser
-**This endpoint allows you to retrive the monthly email statistics for a specific subuser.**
+**This endpoint allows you to retrieve the monthly email statistics for a specific subuser.**
While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings.
@@ -4526,7 +4526,7 @@ Transactional templates are templates created specifically for transactional ema
**This endpoint allows you to create a new version of a template.**
-Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
+Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across all templates.
For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
@@ -4553,7 +4553,7 @@ For more information about transactional templates, please see our [User Guide](
**This endpoint allows you to edit a version of one of your transactional templates.**
-Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
+Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across all templates.
For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
@@ -4585,7 +4585,7 @@ For more information about transactional templates, please see our [User Guide](
**This endpoint allows you to retrieve a specific version of a template.**
-Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
+Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across all templates.
For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
@@ -4616,7 +4616,7 @@ For more information about transactional templates, please see our [User Guide](
**This endpoint allows you to delete one of your transactional template versions.**
-Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
+Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across all templates.
For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
@@ -5962,7 +5962,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
```
## Retrieve all IP whitelabels
-**This endpoint allows you to retrieve all of the IP whitelabels that have been createdy by this account.**
+**This endpoint allows you to retrieve all of the IP whitelabels that have been created by this account.**
You may include a search key by using the "ip" parameter. This enables you to perform a prefix search for a given IP segment (e.g. "192.").
@@ -6157,7 +6157,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to retrieve the associated link whitelabel for a subuser.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
@@ -6187,7 +6187,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to disassociate a link whitelabel from a subuser.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
@@ -6318,7 +6318,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to associate a link whitelabel with a subuser account.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
From 3a1733f666e5b153b98e999d4bda4671011dfd40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=ADcero=20Pablo?=
Date: Fri, 6 Oct 2017 21:53:03 -0300
Subject: [PATCH 016/345] Update USAGE.md
---
USAGE.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index 96b63ed8..00e66e96 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -6157,7 +6157,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to retrieve the associated link whitelabel for a subuser.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's link whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
@@ -6187,7 +6187,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to disassociate a link whitelabel from a subuser.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's link whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
@@ -6318,7 +6318,7 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
**This endpoint allows you to associate a link whitelabel with a subuser account.**
Link whitelables can be associated with subusers from the parent account. This functionality allows
-subusers to send mail using their parent's like whitelabels. To associate a link whitelabel, the parent account
+subusers to send mail using their parent's link whitelabels. To associate a link whitelabel, the parent account
must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface.
Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net.
From c0eb49d6a972d8709323ac606673f125376d0d93 Mon Sep 17 00:00:00 2001
From: DaLun
Date: Mon, 9 Oct 2017 13:15:34 -0500
Subject: [PATCH 017/345] Update USAGE.md with one period
---
USAGE.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/USAGE.md b/USAGE.md
index 308ca259..1db7997b 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -495,7 +495,7 @@ If the API Key ID does not exist an HTTP 404 will be returned.
```
## Delete API keys
-**This endpoint allows you to revoke an existing API Key**
+**This endpoint allows you to revoke an existing API Key.**
Authentications using this API Key will fail after this request is made, with some small propogation delay.If the API Key ID does not exist an HTTP 404 will be returned.
From 7469b4289cb057b6a7483efb2209afb15fbf9815 Mon Sep 17 00:00:00 2001
From: DaLun
Date: Mon, 9 Oct 2017 13:20:28 -0500
Subject: [PATCH 018/345] fix the disappear logo
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 1847b034..99fceeb3 100644
--- a/README.md
+++ b/README.md
@@ -221,5 +221,4 @@ sendgrid-java is guided and supported by the SendGrid [Developer Experience Team
sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
-![SendGrid Logo]
-(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)
+
From fd05b9430d222caa7110208c6bae8fb50a6dce57 Mon Sep 17 00:00:00 2001
From: Andy Trimble
Date: Mon, 9 Oct 2017 18:05:14 -0600
Subject: [PATCH 019/345] Adding Docker support.
---
docker/Dockerfile | 24 ++++++++++++++++++++++++
docker/README.md | 37 +++++++++++++++++++++++++++++++++++++
docker/USAGE.md | 35 +++++++++++++++++++++++++++++++++++
docker/entrypoint.sh | 31 +++++++++++++++++++++++++++++++
4 files changed, 127 insertions(+)
create mode 100644 docker/Dockerfile
create mode 100644 docker/README.md
create mode 100644 docker/USAGE.md
create mode 100644 docker/entrypoint.sh
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 00000000..943b2b50
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,24 @@
+FROM store/oracle/serverjre:8
+
+ENV OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json"
+
+RUN yum install -y git
+
+WORKDIR /root
+
+# install Prism
+ADD https://raw.githubusercontent.com/stoplightio/prism/master/install.sh install.sh
+RUN chmod +x ./install.sh && \
+ ./install.sh && \
+ rm ./install.sh
+
+# set up default sendgrid env
+WORKDIR /root/sources
+RUN git clone https://github.com/sendgrid/sendgrid-java.git
+WORKDIR /root
+RUN ln -s /root/sources/sendgrid-java/sendgrid
+
+COPY entrypoint.sh entrypoint.sh
+RUN chmod +x entrypoint.sh
+ENTRYPOINT ["./entrypoint.sh"]
+CMD ["--mock"]
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 00000000..7758a41a
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,37 @@
+# Supported tags and respective `Dockerfile` links
+ - `v1.0.0`, `latest` [(Dockerfile)](https://github.com/sendgrid/sendgrid-java/blob/master/docker/Dockerfile)
+
+# Quick reference
+Due to Oracle's JDK license, you must build this Docker image using the official Oracle image located in the Docker Store. You will need a Docker store account. Once you have an account, you must accept the Oracle license [here](https://store.docker.com/images/oracle-serverjre-8). On the command line, type `docker login` and provide your credentials. You may then build the image using this command `docker build -t sendgrid/sendgrid-java -f Dockerfile .`
+
+ - **Where to get help:**
+ [Contact SendGrid Support](https://support.sendgrid.com/hc/en-us)
+
+ - **Where to file issues:**
+ https://github.com/sendgrid/sendgrid-java/issues
+
+ - **Where to get more info:**
+ [USAGE.md](https://github.com/sendgrid/sendgrid-java/blob/master/docker/USAGE.md)
+
+ - **Maintained by:**
+ [SendGrid Inc.](https://sendgrid.com)
+
+# Usage examples
+ - Most recent version: `docker run -it sendgrid/sendgrid-java`.
+ - Your own fork:
+ ```sh-session
+ $ git clone https://github.com/you/cool-sendgrid-java.git
+ $ realpath cool-sendgrid-java
+ /path/to/cool-sendgrid-java
+ $ docker run -it -v /path/to/cool-sendgrid-java:/mnt/sendgrid-java sendgrid/sendgrid-java
+ ```
+
+For more detailed information, see [USAGE.md](https://github.com/sendgrid/sendgrid-java/blob/master/docker/USAGE.md).
+
+# About
+
+sendgrid-java is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
+
+sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
+
+
diff --git a/docker/USAGE.md b/docker/USAGE.md
new file mode 100644
index 00000000..125b90fe
--- /dev/null
+++ b/docker/USAGE.md
@@ -0,0 +1,35 @@
+You can use Docker to easily try out or test sendgrid-java.
+
+
+# Quickstart
+
+1. Install Docker on your machine.
+2. If you have not done so, create a Docker Store account [here](https://store.docker.com/signup?next=%2F)
+3. Navigate [here](https://store.docker.com/images/oracle-serverjre-8) and click the "Proceed to Checkout" link (don't worry, it's free).
+4. On the command line, execute `docker login` and provide your credentials.
+5. Build the Docker image using the command `docker build -t sendgrid/sendgrid-java -f Dockerfile .`
+6. Run `docker run -it sendgrid/sendgrid-java`.
+
+
+# Info
+
+This Docker image contains
+ - `sendgrid-java`
+ - Stoplight's Prism, which lets you try out the API without actually sending email
+
+Run it in interactive mode with `-it`.
+
+You can mount repositories in the `/mnt/sendgrid-java` and `/mnt/java-http-client` directories to use them instead of the default SendGrid libraries. Read on for more info.
+
+
+# Testing
+Testing is easy! Run the container, `cd sendgrid`, and run `./gradlew test`.
+
+
+# About
+
+sendgrid-java is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
+
+sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
+
+
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100644
index 00000000..556d85bd
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+clear
+
+# check for + link mounted libraries:
+if [ -d /mnt/sendgrid-java ]
+then
+ rm /root/sendgrid
+ ln -s /mnt/sendgrid-java/sendgrid
+ echo "Linked mounted sendgrid-java's code to /root/sendgrid"
+fi
+
+SENDGRID_JAVA_VERSION="1.0.0"
+echo "Welcome to sendgrid-java docker v${SENDGRID_JAVA_VERSION}."
+echo
+
+if [ "$1" != "--no-mock" ]
+then
+ echo "Starting Prism in mock mode. Calls made to Prism will not actually send emails."
+ echo "Disable this by running this container with --no-mock."
+ prism run --mock --spec $OAI_SPEC_URL 2> /dev/null &
+else
+ echo "Starting Prism in live (--no-mock) mode. Calls made to Prism will send emails."
+ prism run --spec $OAI_SPEC_URL 2> /dev/null &
+fi
+echo "To use Prism, make API calls to localhost:4010. For example,"
+echo " sg = sendgrid.SendGridAPIClient("
+echo " host='http://localhost:4010/',"
+echo " api_key=os.environ.get('SENDGRID_API_KEY_CAMPAIGNS'))"
+echo "To stop Prism, run \"kill $!\" from the shell."
+
+bash
\ No newline at end of file
From b785ae22c9124d840950defd59cd03f5d704e527 Mon Sep 17 00:00:00 2001
From: scaalabr
Date: Mon, 9 Oct 2017 22:52:29 -0500
Subject: [PATCH 020/345] Addressing comments
---
src/main/java/com/sendgrid/SendGrid.java | 3 +-
src/main/java/com/sendgrid/SendGridApi.java | 40 +++++++++++++++++++--
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 061316b8..96277d3e 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -7,7 +7,8 @@
/**
* Class SendGrid allows for quick and easy access to the SendGrid API.
*/
-public class SendGrid implements SendGridApi{
+public class SendGrid implements SendGridAPI {
+
private static final String VERSION = "3.0.0";
private static final String USER_AGENT = "sendgrid/" + VERSION + ";java";
diff --git a/src/main/java/com/sendgrid/SendGridApi.java b/src/main/java/com/sendgrid/SendGridApi.java
index d6273b36..bfbb230c 100644
--- a/src/main/java/com/sendgrid/SendGridApi.java
+++ b/src/main/java/com/sendgrid/SendGridApi.java
@@ -3,23 +3,59 @@
import java.io.IOException;
import java.util.Map;
-public interface SendGridApi {
+public interface SendGridAPI {
+ /**
+ * Initializes SendGrid
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ */
public void initializeSendGrid(String apiKey);
+ /**
+ * Initializes SendGrid
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ */
public String getLibraryVersion();
+ /**
+ * Gets the version.
+ */
public String getVersion();
+ /**
+ * Sets the version.
+ * @param version the SendGrid version.
+ */
public void setVersion(String version);
+
+ /**
+ * Gets the request headers.
+ */
public Map getRequestHeaders();
+ /**
+ * Adds a request headers.
+ * @param key the key
+ * @param value the value
+ */
public Map addRequestHeader(String key, String value);
+ /**
+ * Removes a request headers.
+ * @param key the key
+ */
public Map removeRequestHeader(String key);
+
+ /**
+ * Gets the host.
+ */
public String getHost();
-
+
+ /**
+ * Sets the host.
+ * @param host the host to set
+ */
public void setHost(String host);
/**
From dc35aba01fb616c771c215fd9b4980ed1f5b8be3 Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Mon, 9 Oct 2017 22:56:32 -0500
Subject: [PATCH 021/345] Rename SendGridApi.java to SendGridAPI.java
---
src/main/java/com/sendgrid/{SendGridApi.java => SendGridAPI.java} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/main/java/com/sendgrid/{SendGridApi.java => SendGridAPI.java} (100%)
diff --git a/src/main/java/com/sendgrid/SendGridApi.java b/src/main/java/com/sendgrid/SendGridAPI.java
similarity index 100%
rename from src/main/java/com/sendgrid/SendGridApi.java
rename to src/main/java/com/sendgrid/SendGridAPI.java
From c983fe4764de3da8d7c2c85d16b9c9bb2d0584e4 Mon Sep 17 00:00:00 2001
From: Andy Trimble
Date: Tue, 10 Oct 2017 01:27:46 -0600
Subject: [PATCH 022/345] Added javadocs.
---
src/main/java/com/sendgrid/SendGrid.java | 85 ++++++-
.../java/com/sendgrid/helpers/mail/Mail.java | 237 +++++++++++++++++-
.../sendgrid/helpers/mail/objects/ASM.java | 33 ++-
.../helpers/mail/objects/Attachments.java | 101 ++++++++
.../helpers/mail/objects/BccSettings.java | 23 +-
.../mail/objects/ClickTrackingSetting.java | 24 +-
.../helpers/mail/objects/Content.java | 35 ++-
.../sendgrid/helpers/mail/objects/Email.java | 35 ++-
.../helpers/mail/objects/FooterSetting.java | 30 ++-
.../mail/objects/GoogleAnalyticsSetting.java | 56 ++++-
.../helpers/mail/objects/MailSettings.java | 55 +++-
.../mail/objects/OpenTrackingSetting.java | 27 +-
.../helpers/mail/objects/Personalization.java | 121 ++++++++-
.../helpers/mail/objects/Setting.java | 13 +-
.../mail/objects/SpamCheckSetting.java | 33 ++-
.../objects/SubscriptionTrackingSetting.java | 50 +++-
.../mail/objects/TrackingSettings.java | 47 +++-
17 files changed, 967 insertions(+), 38 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 421b11a9..6bf14295 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -5,44 +5,66 @@
import java.util.Map;
/**
- * Class SendGrid allows for quick and easy access to the SendGrid API.
- */
+ * Class SendGrid allows for quick and easy access to the SendGrid API.
+ */
public class SendGrid {
+ /** The current library version. */
private static final String VERSION = "3.0.0";
+
+ /** The user agent string to return to SendGrid. */
private static final String USER_AGENT = "sendgrid/" + VERSION + ";java";
+ /** The user's API key. */
private String apiKey;
+
+ /** The SendGrid host to which to connect. */
private String host;
+
+ /** The API version. */
private String version;
+
+ /** The HTTP client. */
private Client client;
+
+ /** The request headers container. */
private Map requestHeaders;
/**
- * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- */
+ * Construct a new SendGrid API wrapper.
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ * @return a SendGrid object.
+ */
public SendGrid(String apiKey) {
this.client = new Client();
initializeSendGrid(apiKey);
}
/**
- * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- * @param test is true if you are unit testing
- */
+ * Construct a new SendGrid API wrapper.
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ * @param test is true if you are unit testing
+ * @return a SendGrid object.
+ */
public SendGrid(String apiKey, Boolean test) {
this.client = new Client(test);
initializeSendGrid(apiKey);
}
/**
+ * Construct a new SendGrid API wrapper.
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
* @param client the Client to use (allows to customize its configuration)
+ * @return a SendGrid object.
*/
public SendGrid(String apiKey, Client client) {
this.client = client;
initializeSendGrid(apiKey);
}
+ /**
+ * Initialize the client.
+ * @param apiKey the user's API key.
+ */
public void initializeSendGrid(String apiKey) {
this.apiKey = apiKey;
this.host = "api.sendgrid.com";
@@ -53,50 +75,91 @@ public void initializeSendGrid(String apiKey) {
this.requestHeaders.put("Accept", "application/json");
}
+ /**
+ * Retrieve the current library version.
+ * @return the current version.
+ */
public String getLibraryVersion() {
return this.VERSION;
}
+ /**
+ * Get the API version.
+ * @return the current API versioin (v3 by default).
+ */
public String getVersion() {
return this.version;
}
+ /**
+ * Set the API version.
+ * @param version the new version.
+ */
public void setVersion(String version) {
this.version = version;
}
+ /**
+ * Obtain the request headers.
+ * @return the request headers.
+ */
public Map getRequestHeaders() {
return this.requestHeaders;
}
+ /**
+ * Add a new request header.
+ * @param key the header key.
+ * @param value the header value.
+ * @return the new set of request headers.
+ */
public Map addRequestHeader(String key, String value) {
this.requestHeaders.put(key, value);
return getRequestHeaders();
}
+ /**
+ * Remove a request header.
+ * @param key the header key to remove.
+ * @return the new set of request headers.
+ */
public Map removeRequestHeader(String key) {
this.requestHeaders.remove(key);
return getRequestHeaders();
}
+ /**
+ * Get the SendGrid host (api.sendgrid.com by default).
+ * @return the SendGrid host.
+ */
public String getHost() {
return this.host;
}
+ /**
+ * Set the SendGrid host.
+ * @host the new SendGrid host.
+ */
public void setHost(String host) {
this.host = host;
}
/**
- * Class makeCall makes the call to the SendGrid API, override this method for testing.
- */
+ * Class makeCall makes the call to the SendGrid API, override this method for testing.
+ * @param request the request to make.
+ * @return the response object.
+ * @throws IOException in case of a network error.
+ */
public Response makeCall(Request request) throws IOException {
return client.api(request);
}
/**
- * Class api sets up the request to the SendGrid API, this is main interface.
- */
+ * Class api sets up the request to the SendGrid API, this is main interface.
+ * @param request the request object.
+ * @return the response object.
+ * @throws IOException in case of a network error.
+ */
public Response api(Request request) throws IOException {
Request req = new Request();
req.setMethod(request.getMethod());
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index beba5a53..edf02a15 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -19,26 +19,92 @@
import java.util.Map;
/**
- * Class Mail builds an object that sends an email through SendGrid.
- */
+ * Class Mail builds an object that sends an email through SendGrid.
+ * Note that this object is not thread safe.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Mail {
+
+ /** The email's from field. */
@JsonProperty("from") public Email from;
+
+ /** The email's subject line. This is the global, or
+ * “message level”, subject of your email. This may
+ * be overridden by personalizations[x].subject.
+ */
@JsonProperty("subject") public String subject;
+
+ /**
+ * The email's personalization. Each object within
+ * personalizations can be thought of as an envelope
+ * - it defines who should receive an individual message
+ * and how that message should be handled.
+ */
@JsonProperty("personalizations") public List personalization;
+
+ /** The email's content. */
@JsonProperty("content") public List content;
+
+ /** The email's attachments. */
@JsonProperty("attachments") public List attachments;
+
+ /** The email's template ID. */
@JsonProperty("template_id") public String templateId;
+
+ /**
+ * The email's sections. An object of key/value pairs that
+ * define block sections of code to be used as substitutions.
+ */
@JsonProperty("sections") public Map sections;
+
+ /** The email's headers. */
@JsonProperty("headers") public Map headers;
+
+ /** The email's categories. */
@JsonProperty("categories") public List categories;
+
+ /**
+ * The email's custom arguments. Values that are specific to
+ * the entire send that will be carried along with the email
+ * and its activity data. Substitutions will not be made on
+ * custom arguments, so any string that is entered into this
+ * parameter will be assumed to be the custom argument that
+ * you would like to be used. This parameter is overridden by
+ * personalizations[x].custom_args if that parameter has been
+ * defined. Total custom args size may not exceed 10,000 bytes.
+ */
@JsonProperty("custom_args") public Map customArgs;
+
+ /**
+ * A unix timestamp allowing you to specify when you want
+ * your email to be delivered. This may be overridden by
+ * the personalizations[x].send_at parameter. Scheduling
+ * more than 72 hours in advance is forbidden.
+ */
@JsonProperty("send_at") public long sendAt;
+
+ /**
+ * This ID represents a batch of emails to be sent at the
+ * same time. Including a batch_id in your request allows
+ * you include this email in that batch, and also enables
+ * you to cancel or pause the delivery of that batch. For
+ * more information, see https://sendgrid.com/docs/API_Reference/Web_API_v3/cancel_schedule_send.
+ */
@JsonProperty("batch_id") public String batchId;
+
+ /** The email's unsubscribe handling object. */
@JsonProperty("asm") public ASM asm;
+
+ /** The email's IP pool name. */
@JsonProperty("ip_pool_name") public String ipPoolId;
+
+ /** The email's mail settings. */
@JsonProperty("mail_settings") public MailSettings mailSettings;
+
+ /** The email's tracking settings. */
@JsonProperty("tracking_settings") public TrackingSettings trackingSettings;
+
+ /** The email's reply to address. */
@JsonProperty("reply_to") public Email replyTo;
private static final ObjectMapper SORTED_MAPPER = new ObjectMapper();
@@ -46,10 +112,18 @@ public class Mail {
SORTED_MAPPER.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
}
+ /** Construct a new Mail object. */
public Mail() {
return;
}
+ /**
+ * Construct a new Mail object.
+ * @param from the email's from address.
+ * @param subject the email's subject line.
+ * @param to the email's recipient.
+ * @param content the email's content.
+ */
public Mail(Email from, String subject, Email to, Content content)
{
this.setFrom(from);
@@ -60,38 +134,71 @@ public Mail(Email from, String subject, Email to, Content content)
this.addContent(content);
}
+ /**
+ * Get the email's from address.
+ * @return the email's from address.
+ */
@JsonProperty("from")
public Email getFrom() {
return this.from;
}
+ /**
+ * Set the email's from address.
+ * @param from the email's from address.
+ */
public void setFrom(Email from) {
this.from = from;
}
+ /**
+ * Get the email's subject line.
+ * @return the email's subject line.
+ */
@JsonProperty("subject")
public String getSubject() {
return subject;
}
+ /**
+ * Set the email's subject line.
+ * @param subject the email's subject line.
+ */
public void setSubject(String subject) {
this.subject = subject;
}
+ /**
+ * Get the email's unsubscribe handling object (ASM).
+ * @return the email's ASM.
+ */
@JsonProperty("asm")
public ASM getASM() {
return asm;
}
+ /**
+ * Set the email's unsubscribe handling object (ASM).
+ * @param asm the email's ASM.
+ */
public void setASM(ASM asm) {
this.asm = asm;
}
+ /**
+ * Get the email's personalizations. Content added to the returned
+ * list will be included when sent.
+ * @return the email's personalizations.
+ */
@JsonProperty("personalizations")
public List getPersonalization() {
return personalization;
}
+ /**
+ * Add a personalizaton to the email.
+ * @param personalization a personalization.
+ */
public void addPersonalization(Personalization personalization) {
if (this.personalization == null) {
this.personalization = new ArrayList();
@@ -101,11 +208,20 @@ public void addPersonalization(Personalization personalization) {
}
}
+ /**
+ * Get the email's content. Content added to the returned list
+ * will be included when sent.
+ * @return the email's content.
+ */
@JsonProperty("content")
public List getContent() {
return content;
}
+ /**
+ * Add content to this email.
+ * @param content content to add to this email.
+ */
public void addContent(Content content) {
Content newContent = new Content();
newContent.setType(content.getType());
@@ -118,11 +234,20 @@ public void addContent(Content content) {
}
}
+ /**
+ * Get the email's attachments. Attachments added to the returned
+ * list will be included when sent.
+ * @return the email's attachments.
+ */
@JsonProperty("attachments")
public List getAttachments() {
return attachments;
}
+ /**
+ * Add attachments to the email.
+ * @param attachments attachments to add.
+ */
public void addAttachments(Attachments attachments) {
Attachments newAttachment = new Attachments();
newAttachment.setContent(attachments.getContent());
@@ -138,20 +263,38 @@ public void addAttachments(Attachments attachments) {
}
}
+ /**
+ * Get the email's template ID.
+ * @return the email's template ID.
+ */
@JsonProperty("template_id")
public String getTemplateId() {
return this.templateId;
}
+ /**
+ * Set the email's template ID.
+ * @param templateId the email's template ID.
+ */
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
+ /**
+ * Get the email's sections. Sections added to the returned list
+ * will be included when sent.
+ * @return the email's sections.
+ */
@JsonProperty("sections")
public Map getSections() {
return sections;
}
+ /**
+ * Add a section to the email.
+ * @param key the section's key.
+ * @param value the section's value.
+ */
public void addSection(String key, String value) {
if (sections == null) {
sections = new HashMap();
@@ -161,12 +304,21 @@ public void addSection(String key, String value) {
}
}
+ /**
+ * Get the email's headers. Headers added to the returned list
+ * will be included when sent.
+ * @return the email's headers.
+ */
@JsonProperty("headers")
public Map getHeaders() {
return headers;
}
-
+ /**
+ * Add a header to the email.
+ * @param key the header's key.
+ * @param value the header's value.
+ */
public void addHeader(String key, String value) {
if (headers == null) {
headers = new HashMap();
@@ -176,11 +328,20 @@ public void addHeader(String key, String value) {
}
}
+ /**
+ * Get the email's categories. Categories added to the returned list
+ * will be included when sent.
+ * @return the email's categories.
+ */
@JsonProperty("categories")
public List getCategories() {
return categories;
}
+ /**
+ * Add a category to the email.
+ * @param category the category.
+ */
public void addCategory(String category) {
if (categories == null) {
categories = new ArrayList();
@@ -190,11 +351,21 @@ public void addCategory(String category) {
}
}
+ /**
+ * Get the email's custom arguments. Custom arguments added to the returned list
+ * will be included when sent.
+ * @return the email's custom arguments.
+ */
@JsonProperty("custom_args")
public Map getCustomArgs() {
return customArgs;
}
+ /**
+ * Add a custom argument to the email.
+ * @param key argument's key.
+ * @param value the argument's value.
+ */
public void addCustomArg(String key, String value) {
if (customArgs == null) {
customArgs = new HashMap();
@@ -204,63 +375,113 @@ public void addCustomArg(String key, String value) {
}
}
+ /**
+ * Get the email's send at time (Unix timestamp).
+ * @return the email's send at time.
+ */
@JsonProperty("send_at")
public long sendAt() {
return sendAt;
}
+ /**
+ * Set the email's send at time (Unix timestamp).
+ * @param sendAt the send at time.
+ */
public void setSendAt(long sendAt) {
this.sendAt = sendAt;
}
+ /**
+ * Get the email's batch ID.
+ * @return the batch ID.
+ */
@JsonProperty("batch_id")
public String getBatchId() {
return batchId;
}
+ /**
+ * Set the email's batch ID.
+ * @param batchId the batch ID.
+ */
public void setBatchId(String batchId) {
this.batchId = batchId;
}
+ /**
+ * Get the email's IP pool ID.
+ * @return the IP pool ID.
+ */
@JsonProperty("ip_pool_name")
public String getIpPoolId() {
return ipPoolId;
}
+ /**
+ * Set the email's IP pool ID.
+ * @param ipPoolId the IP pool ID.
+ */
public void setIpPoolId(String ipPoolId) {
this.ipPoolId = ipPoolId;
}
+ /**
+ * Get the email's settings.
+ * @return the settings.
+ */
@JsonProperty("mail_settings")
public MailSettings getMailSettings() {
return mailSettings;
}
+ /**
+ * Set the email's settings.
+ * @param mailSettings the settings.
+ */
public void setMailSettings(MailSettings mailSettings) {
this.mailSettings = mailSettings;
}
+ /**
+ * Get the email's tracking settings.
+ * @return the tracking settings.
+ */
@JsonProperty("tracking_settings")
public TrackingSettings getTrackingSettings() {
return trackingSettings;
}
+ /**
+ * Set the email's tracking settings.
+ * @param trackingSettings the tracking settings.
+ */
public void setTrackingSettings(TrackingSettings trackingSettings) {
this.trackingSettings = trackingSettings;
}
+ /**
+ * Get the email's reply to address.
+ * @return the reply to address.
+ */
@JsonProperty("reply_to")
public Email getReplyto() {
return replyTo;
}
+ /**
+ * Set the email's reply to address.
+ * @param replyTo the reply to address.
+ */
public void setReplyTo(Email replyTo) {
this.replyTo = replyTo;
}
/**
- * Create a string represenation of the Mail object JSON.
- */
+ * Create a string represenation of the Mail object JSON.
+ * @return a JSON string.
+ * @throws IOException in case of a JSON marshal error.
+ */
public String build() throws IOException {
try {
//ObjectMapper mapper = new ObjectMapper();
@@ -271,8 +492,10 @@ public String build() throws IOException {
}
/**
- * Create a string represenation of the Mail object JSON and pretty print it.
- */
+ * Create a string represenation of the Mail object JSON and pretty print it.
+ * @return a pretty JSON string.
+ * @throws IOException in case of a JSON marshal error.
+ */
public String buildPretty() throws IOException {
try {
ObjectMapper mapper = new ObjectMapper();
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
index 1a65a65d..00763af7 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
@@ -6,26 +6,49 @@
import java.util.Arrays;
+/**
+ * An object allowing you to specify how to handle unsubscribes.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class ASM {
+
+ /** The group ID. */
@JsonProperty("group_id") private int groupId;
+
+ /** The groups to display property. */
@JsonProperty("groups_to_display") private int[] groupsToDisplay;
-
+
+ /**
+ * Get the group ID.
+ * @return the group ID.
+ */
@JsonProperty("group_id")
public int getGroupId() {
return groupId;
}
-
+
+ /**
+ * Set the group ID.
+ * @param groupId the group ID.
+ */
public void setGroupId(int groupId) {
this.groupId = groupId;
}
-
+
+ /**
+ * Get the groups to display.
+ * @return the groups to display.
+ */
@JsonProperty("groups_to_display")
public int[] getGroupsToDisplay() {
return groupsToDisplay;
}
-
+
+ /**
+ * Set the groups to display.
+ * @param groupsToDisplay the groups to display.
+ */
public void setGroupsToDisplay(int[] groupsToDisplay) {
this.groupsToDisplay = Arrays.copyOf(groupsToDisplay, groupsToDisplay.length);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
index 9323b837..059fc835 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
@@ -8,59 +8,133 @@
import java.io.*;
+/**
+ * An attachment object.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Attachments {
+
+ /** The attachment content. */
@JsonProperty("content") private String content;
+
+ /**
+ * The mime type of the content you are attaching. For example,
+ * “text/plain” or “text/html”.
+ */
@JsonProperty("type") private String type;
+
+ /** The attachment file name. */
@JsonProperty("filename") private String filename;
+
+ /** The attachment disposition. */
@JsonProperty("disposition") private String disposition;
+
+ /**
+ * The attachment content ID. This is used when the
+ * disposition is set to “inline” and the attachment
+ * is an image, allowing the file to be displayed within
+ * the body of your email.
+ */
@JsonProperty("content_id") private String contentId;
+ /**
+ * Get the attachment's content.
+ * @return the content.
+ */
@JsonProperty("content")
public String getContent() {
return content;
}
+ /**
+ * Set the attachment's content.
+ * @param content the content.
+ */
public void setContent(String content) {
this.content = content;
}
+ /**
+ * Get the mime type of the content you are attaching. For example,
+ * “text/plain” or “text/html”.
+ * @return the mime type.
+ */
@JsonProperty("type")
public String getType() {
return type;
}
+ /**
+ * Set the mime type of the content.
+ * @param type the mime type.
+ */
public void setType(String type) {
this.type = type;
}
+ /**
+ * Get the filename for this attachment.
+ * @return the file name.
+ */
@JsonProperty("filename")
public String getFilename() {
return filename;
}
+ /**
+ * Set the filename for this attachment.
+ * @param filename the filename.
+ */
public void setFilename(String filename) {
this.filename = filename;
}
+ /**
+ * Get the content-disposition of the attachment specifying
+ * how you would like the attachment to be displayed.
+ * For example, “inline” results in the attached file
+ * being displayed automatically within the message
+ * while “attachment” results in the attached file
+ * requiring some action to be taken before it is
+ * displayed (e.g. opening or downloading the file).
+ * @return the disposition.
+ */
@JsonProperty("disposition")
public String getDisposition() {
return disposition;
}
+ /**
+ * Set the content-disposition of the attachment.
+ * @param disposition the disposition.
+ */
public void setDisposition(String disposition) {
this.disposition = disposition;
}
+ /**
+ * Get the attachment content ID. This is used when the
+ * disposition is set to “inline” and the attachment
+ * is an image, allowing the file to be displayed within
+ * the body of your email.
+ * @return the content ID.
+ */
@JsonProperty("content_id")
public String getContentId() {
return contentId;
}
+ /**
+ * Set the content ID.
+ * @param contentId the content ID.
+ */
public void setContentId(String contentId) {
this.contentId = contentId;
}
+ /**
+ * A helper object to construct usable attachments.
+ */
@JsonIgnoreType
public static class Builder {
@@ -72,6 +146,12 @@ public static class Builder {
private String disposition;
private String contentId;
+ /**
+ * Construct a new attachment builder.
+ * @param fileName the filename to include.
+ * @param content an input stream for the content.
+ * @throws IllegalArgumentException in case either the fileName or the content is null.
+ */
public Builder(String fileName, InputStream content) {
if (fileName == null) {
throw new IllegalArgumentException("File name mustn't be null");
@@ -85,6 +165,12 @@ public Builder(String fileName, InputStream content) {
this.content = encodeToBase64(content);
}
+ /**
+ * Construct a new attachment builder.
+ * @param fileName the filename to include.
+ * @param content an input string for the content.
+ * @throws IllegalArgumentException in case either the fileName or the content is null.
+ */
public Builder(String fileName, String content) {
if (fileName == null) {
throw new IllegalArgumentException("File name mustn't be null");
@@ -112,21 +198,36 @@ private String encodeToBase64(InputStream content) {
}
}
+ /**
+ * Set the type of this attachment builder.
+ * @param type the attachment type.
+ */
public Builder withType(String type) {
this.type = type;
return this;
}
+ /**
+ * Set the disposition of this attachment builder.
+ * @param disposition the disposition.
+ */
public Builder withDisposition(String disposition) {
this.disposition = disposition;
return this;
}
+ /**
+ * Set the content ID of this attachment builder.
+ * @param contentId the content ID.
+ */
public Builder withContentId(String contentId) {
this.contentId = contentId;
return this;
}
+ /**
+ * Construct the attachments object.
+ */
public Attachments build() {
Attachments attachments = new Attachments();
attachments.setContent(content);
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
index 176387fa..37be0866 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
@@ -4,26 +4,47 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * This object allows you to have a blind carbon copy
+ * automatically sent to the specified email address
+ * for every email that is sent.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class BccSettings {
@JsonProperty("enable") private boolean enable;
@JsonProperty("email") private String email;
+ /**
+ * Determines if this setting is enabled.
+ * @return true if BCC is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set whether or not BCC is enabled.
+ * @param enable true if BCC is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the email address that you would like to receive the BCC.
+ * @return the address.
+ */
@JsonProperty("email")
public String getEmail() {
return this.email;
}
+ /**
+ * Set the email address that you would like to receive the BCC.
+ * @param email the address.
+ */
public void setEmail(String email) {
this.email = email;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index 839c8fbf..e901e086 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -4,26 +4,48 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * Settings to determine how you would like to track the
+ * metrics of how your recipients interact with your email.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class ClickTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("enable_text") private boolean enableText;
+ /**
+ * Determines if this setting is enabled.
+ * @return true if click tracking is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set if this setting is enabled.
+ * @param enable true if click tracking is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the enabled text. This indicates if this
+ * setting should be included in the text/plain
+ * portion of your email.
+ * @return the enable text.
+ */
@JsonProperty("enable_text")
public boolean getEnableText() {
return enableText;
}
+ /**
+ * Set the enalbed text.
+ * @param enableText the enable text.
+ */
public void setEnableText(boolean enableText) {
this.enableText = enableText;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
index b00f9566..f6621ac9 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
@@ -4,35 +4,66 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An object in which you may specify the content of your email.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Content {
@JsonProperty("type") private String type;
@JsonProperty("value") private String value;
+ /**
+ * Construct an empty content object.
+ */
public Content() {
- return;
+
}
+ /**
+ * Construct a content object with the specified type and value.
+ * @param type the mime type.
+ * @param value the content.
+ */
public Content(String type, String value) {
this.setType(type);
this.setValue(value);
}
+ /**
+ * Get the mime type of the content you are including
+ * in your email. For example, “text/plain” or “text/html”.
+ * @return the mime type.
+ */
@JsonProperty("type")
public String getType() {
return type;
}
+ /**
+ * Set the mime type of the content you are including
+ * in your email. For example, “text/plain” or “text/html”.
+ * @param type the mime type.
+ */
public void setType(String type) {
this.type = type;
}
+ /**
+ * Get the actual content of the specified mime type
+ * that you are including in your email.
+ * @return the value.
+ */
@JsonProperty("value")
public String getValue() {
return value;
}
+ /**
+ * Set the actual content of the specified mime type
+ * that you are including in your email.
+ * @param value the value.
+ */
public void setValue(String value) {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
index 43396a85..5642e345 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
@@ -4,39 +4,70 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An email address represented as an address name pair.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Email {
@JsonProperty("name") private String name;
@JsonProperty("email") private String email;
+ /**
+ * Construct an empty email.
+ */
public Email() {
- return;
+
}
+ /**
+ * Construct an email with the supplied email and an empty name.
+ * @param email an email address.
+ */
public Email(String email) {
this.setEmail(email);
}
+ /**
+ * Construct an email with the supplied address and name.
+ * @param email an email address.
+ * @param name a name.
+ */
public Email(String email, String name) {
this.setEmail(email);
this.setName(name);
}
+ /**
+ * Get the name.
+ * @return the name.
+ */
@JsonProperty("name")
public String getName() {
return name;
}
+ /**
+ * Set the name.
+ * @param name the name.
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Get the email address.
+ * @return the email address.
+ */
@JsonProperty("email")
public String getEmail() {
return email;
}
+ /**
+ * Set the email address.
+ * @param email the email address.
+ */
public void setEmail(String email) {
this.email = email;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
index 8e542c7f..1428b66b 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
@@ -4,36 +4,64 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An object representing the default footer
+ * that you would like included on every email.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class FooterSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("text") private String text;
@JsonProperty("html") private String html;
+ /**
+ * Get whether or not the footer is enabled.
+ * @return true if the footer is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set whether or not the footer is enabled.
+ * @param enable true if the footer is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the plain text content of the footer.
+ * @return the footer plain text.
+ */
@JsonProperty("text")
public String getText() {
return text;
}
+ /**
+ * Set the plain text content of the footer.
+ * @param text the footer plain text.
+ */
public void setText(String text) {
this.text = text;
}
+ /**
+ * Get the HTML content of the footer.
+ * @return the footer HTML.
+ */
@JsonProperty("html")
public String getHtml() {
return html;
}
+ /**
+ * Set the HTML content of the footer.
+ * @param html the footer HTML.
+ */
public void setHtml(String html) {
this.html = html;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
index ce30edbc..eac91899 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
@@ -4,6 +4,9 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An object configuring the tracking provided by Google Analytics.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class GoogleAnalyticsSetting {
@JsonProperty("enable") private boolean enable;
@@ -13,57 +16,108 @@ public class GoogleAnalyticsSetting {
@JsonProperty("utm_campaign") private String campaignName;
@JsonProperty("utm_medium") private String campaignMedium;
+ /**
+ * Get whether or not this setting is enabled.
+ * @return true if enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set whether or not this setting is enabled.
+ * @param enable true if enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the name of the referrer source.
+ * (e.g. Google, SomeDomain.com, or Marketing Email)
+ * @return the referrer source.
+ */
@JsonProperty("utm_source")
public String getCampaignSource() {
return campaignSource;
}
+ /**
+ * Set the name of the referrer source.
+ * @param campaignSource the referrer source.
+ */
public void setCampaignSource(String campaignSource) {
this.campaignSource = campaignSource;
}
+ /**
+ * Get the term used to identify any paid keywords.
+ * @return the term.
+ */
@JsonProperty("utm_term")
public String getCampaignTerm() {
return campaignTerm;
}
+ /**
+ * Set the term used to identify any paid keywords.
+ * @param campaignTerm the term.
+ */
public void setCampaignTerm(String campaignTerm) {
this.campaignTerm = campaignTerm;
}
+ /**
+ * Get the content Used to differentiate your campaign
+ * from advertisements.
+ * @return the content.
+ */
@JsonProperty("utm_content")
public String getCampaignContent() {
return campaignContent;
}
+ /**
+ * Set the content Used to differentiate your campaign
+ * from advertisements.
+ * @param campaignContent the content.
+ */
public void setCampaignContent(String campaignContent) {
this.campaignContent = campaignContent;
}
+ /**
+ * Get the name of the campaign.
+ * @return the name.
+ */
@JsonProperty("utm_campaign")
public String getCampaignName() {
return campaignName;
}
+ /**
+ * Set the name of the campaign.
+ * @param campaignName the name.
+ */
public void setCampaignName(String campaignName) {
this.campaignName = campaignName;
}
+ /**
+ * Get the name of the marketing medium. (e.g. Email)
+ * @return the medium name.
+ */
@JsonProperty("utm_medium")
public String getCampaignMedium() {
return campaignMedium;
}
+ /**
+ * Set the name of the marketing medium. (e.g. Email)
+ * @param campaignMedium the medium name.
+ */
public void setCampaignMedium(String campaignMedium) {
this.campaignMedium = campaignMedium;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
index 63580458..1210eb08 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
@@ -4,6 +4,11 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An object representing a collection of different mail
+ * settings that you can use to specify how you would
+ * like this email to be handled.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class MailSettings {
@JsonProperty("bcc") private BccSettings bccSettings;
@@ -12,48 +17,96 @@ public class MailSettings {
@JsonProperty("sandbox_mode") private Setting sandBoxMode;
@JsonProperty("spam_check") private SpamCheckSetting spamCheckSetting;
+ /**
+ * Get the BCC settings.
+ * @return the BCC settings.
+ */
@JsonProperty("bcc")
public BccSettings getBccSettings() {
return bccSettings;
}
+ /**
+ * Set the BCC settings.
+ * @param bccSettings the BCC settings.
+ */
public void setBccSettings(BccSettings bccSettings) {
this.bccSettings = bccSettings;
}
+ /**
+ * A setting that allows you to bypass all unsubscribe
+ * groups and suppressions to ensure that the email is
+ * delivered to every single recipient. This should only
+ * be used in emergencies when it is absolutely necessary
+ * that every recipient receives your email.
+ * @return the bypass list setting.
+ */
@JsonProperty("bypass_list_management")
public Setting getBypassListManagement() {
return bypassListManagement;
}
+ /**
+ * Set the bypass setting.
+ * @param bypassListManagement the setting.
+ */
public void setBypassListManagement(Setting bypassListManagement) {
this.bypassListManagement = bypassListManagement;
}
+ /**
+ * Get the the footer settings that you would like included on every email.
+ * @return the setting.
+ */
@JsonProperty("footer")
public FooterSetting getFooterSetting() {
return footerSetting;
}
+ /**
+ * Set the the footer settings that you would like included on every email.
+ * @param footerSetting the setting.
+ */
public void setFooterSetting(FooterSetting footerSetting) {
this.footerSetting = footerSetting;
}
+ /**
+ * Get sandbox mode. This allows you to send a test email to
+ * ensure that your request body is valid and formatted correctly.
+ * @return the sandbox mode setting.
+ */
@JsonProperty("sandbox_mode")
public Setting getSandBoxMode() {
return sandBoxMode;
}
+ /**
+ * Set sandbox mode.
+ * @param sandBoxMode the sandbox mode setting.
+ */
+ @JsonProperty("sandbox_mode")
public void setSandboxMode(Setting sandBoxMode) {
this.sandBoxMode = sandBoxMode;
}
+ /**
+ * Get the spam check setting. This allows you to test the
+ * content of your email for spam.
+ * @return the spam check setting.
+ */
@JsonProperty("spam_check")
public SpamCheckSetting getSpamCheck() {
return spamCheckSetting;
}
+ /**
+ * Set the spam check setting. This allows you to test the
+ * content of your email for spam.
+ * @param spamCheckSetting the spam check setting.
+ */
public void setSpamCheckSetting(SpamCheckSetting spamCheckSetting) {
this.spamCheckSetting = spamCheckSetting;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
index aeb7ede1..deba6d33 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
@@ -4,26 +4,51 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An open tracking settings object. This allows you to track
+ * whether the email was opened or not, but including a single
+ * pixel image in the body of the content. When the pixel is
+ * loaded, we can log that the email was opened.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class OpenTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("substitution_tag") private String substitutionTag;
+ /**
+ * Determines if this setting is enabled.
+ * @return true if open tracking is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set if this setting is enabled.
+ * @param enable true if open tracking is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the substituion tag. This allows you to specify a
+ * substitution tag that you can insert in the body of
+ * your email at a location that you desire. This tag will
+ * be replaced by the open tracking pixel.
+ * @return the substitution tag.
+ */
@JsonProperty("substitution_tag")
public String getSubstitutionTag() {
return substitutionTag;
}
+ /**
+ * Set the substitution tag.
+ * @param substitutionTag the substitution tag.
+ */
public void setSubstitutionTag(String substitutionTag) {
this.substitutionTag = substitutionTag;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index 734dc9c0..b72f2316 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -10,6 +10,12 @@
import java.util.List;
import java.util.Map;
+/**
+ * An object representing a message and its metadata.
+ * A personalization can be thought of as an envelope
+ * - it defines who should receive an individual message
+ * and how that message should be handled.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Personalization {
@JsonProperty("to") private List tos;
@@ -21,6 +27,16 @@ public class Personalization {
@JsonProperty("custom_args") private Map customArgs;
@JsonProperty("send_at") private long sendAt;
+ /**
+ * Get the to list. This is an array of recipients. Each object
+ * within this array may contain the name, but must always
+ * contain the email, of a recipient.
+ *
+ * The maximum number of entries is 1000.
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the to list.
+ */
@JsonProperty("to")
public List getTos() {
if(tos == null)
@@ -28,6 +44,10 @@ public List getTos() {
return tos;
}
+ /**
+ * Add a recipient.
+ * @param email an email address.
+ */
public void addTo(Email email) {
Email newEmail = new Email();
newEmail.setName(email.getName());
@@ -40,6 +60,16 @@ public void addTo(Email email) {
}
}
+ /**
+ * Set the CC list. This is an array of recipients. Each object
+ * within this array may contain the name, but must always
+ * contain the email, of a recipient.
+ *
+ * The maximum number of entries is 1000.
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the CC list.
+ */
@JsonProperty("cc")
public List getCcs() {
if(ccs == null)
@@ -47,6 +77,10 @@ public List getCcs() {
return ccs;
}
+ /**
+ * Add a recipient.
+ * @param email an email address.
+ */
public void addCc(Email email) {
Email newEmail = new Email();
newEmail.setName(email.getName());
@@ -59,6 +93,16 @@ public void addCc(Email email) {
}
}
+ /**
+ * Set the BCC list. This is an array of recipients. Each object
+ * within this array may contain the name, but must always
+ * contain the email, of a recipient.
+ *
+ * The maximum number of entries is 1000.
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the BCC list.
+ */
@JsonProperty("bcc")
public List getBccs() {
if(bccs == null)
@@ -66,6 +110,10 @@ public List getBccs() {
return bccs;
}
+ /**
+ * Add a recipient.
+ * @param email an email address.
+ */
public void addBcc(Email email) {
Email newEmail = new Email();
newEmail.setName(email.getName());
@@ -78,15 +126,34 @@ public void addBcc(Email email) {
}
}
+ /**
+ * Get the subject of the email.
+ * @return the subject.
+ */
@JsonProperty("subject")
public String getSubject() {
return subject;
}
+ /**
+ * Set the subject of the email.
+ * @param subject the subject.
+ */
public void setSubject(String subject) {
this.subject = subject;
}
+ /**
+ * Get the headers. The headers are a collection of JSON
+ * key/value pairs allowing you to specify specific handling
+ * instructions for your email. You may not overwrite the
+ * following headers: x-sg-id, x-sg-eid, received,
+ * dkim-signature, Content-Type, Content-Transfer-Encoding,
+ * To, From, Subject, Reply-To, CC, BCC
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the headers.
+ */
@JsonProperty("headers")
public Map getHeaders() {
if(headers == null)
@@ -94,6 +161,11 @@ public Map getHeaders() {
return headers;
}
+ /**
+ * Add a header.
+ * @param key the header key.
+ * @param value the header value.
+ */
public void addHeader(String key, String value) {
if (headers == null) {
headers = new HashMap();
@@ -103,6 +175,21 @@ public void addHeader(String key, String value) {
}
}
+ /**
+ * Get the substitusions. Substitutions are a collection of
+ * key/value pairs following the pattern
+ * "substitution_tag":"value to substitute". All are assumed
+ * to be strings. These substitutions will apply to the text
+ * and html content of the body of your email, in addition
+ * to the subject and reply-to parameters. The total
+ * collective size of your substitutions may not exceed
+ * 10,000 bytes per personalization object.
+ *
+ * The maximum number of entries is 1000.
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the substitutions.
+ */
@JsonProperty("substitutions")
public Map getSubstitutions() {
if(substitutions == null)
@@ -110,6 +197,11 @@ public Map getSubstitutions() {
return substitutions;
}
+ /**
+ * Add a substitusion.
+ * @param key the key.
+ * @param value the value.
+ */
public void addSubstitution(String key, String value) {
if (substitutions == null) {
substitutions = new HashMap();
@@ -119,6 +211,18 @@ public void addSubstitution(String key, String value) {
}
}
+ /**
+ * Get the custom arguments. Values that are specific to
+ * this personalization that will be carried along with
+ * the email and its activity data. Substitutions will
+ * not be made on custom arguments, so any string that
+ * is entered into this parameter will be assumed to be
+ * the custom argument that you would like to be used. i
+ * May not exceed 10,000 bytes.
+ *
+ * Content added to the returned list will be included when sent.
+ * @return the custom arguments.
+ */
@JsonProperty("custom_args")
public Map getCustomArgs() {
if(customArgs == null)
@@ -126,6 +230,11 @@ public Map getCustomArgs() {
return customArgs;
}
+ /**
+ * Add a custom argument.
+ * @param key the key.
+ * @param value the value.
+ */
public void addCustomArg(String key, String value) {
if (customArgs == null) {
customArgs = new HashMap();
@@ -135,13 +244,23 @@ public void addCustomArg(String key, String value) {
}
}
+ /**
+ * Get the send at time. This is a unix timestamp
+ * allowing you to specify when you want your
+ * email to be delivered. Scheduling more than
+ * 72 hours in advance is forbidden.
+ * @return the send at time.
+ */
@JsonProperty("send_at")
public long sendAt() {
return sendAt;
}
+ /**
+ * Set the send at time.
+ * @param sendAt the send at time (Unix timestamp).
+ */
public void setSendAt(long sendAt) {
this.sendAt = sendAt;
}
-
}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
index 5818a145..20b8d64e 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
@@ -4,16 +4,27 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * A generic setting object.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class Setting {
@JsonProperty("enable") private boolean enable;
+ /**
+ * Get whether or not this setting is enabled.
+ * @return true if the setting is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set whether or not this setting is enabled.
+ * @param enable true if the setting is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
index 85d1dc10..dbd43955 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
@@ -4,36 +4,67 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * A setting object that allows you to test the content of
+ * your email for spam.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class SpamCheckSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("threshold") private int spamThreshold;
@JsonProperty("post_to_url") private String postToUrl;
+ /**
+ * Determines if this setting is enabled.
+ * @return true if spam checking is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set if this setting is enabled.
+ * @param enable true if spam checking is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the the threshold used to determine if your content
+ * qualifies as spam on a scale from 1 to 10, with 10 being
+ * most strict, or most likely to be considered as spam.
+ * @return the threshold.
+ */
@JsonProperty("threshold")
public int getSpamThreshold() {
return spamThreshold;
}
+ /**
+ * Set the spam check threshold.
+ * @param spamThreshold the threshold.
+ */
public void setSpamThreshold(int spamThreshold) {
this.spamThreshold = spamThreshold;
}
+ /**
+ * Get the Inbound Parse URL that you would like a copy of
+ * your email along with the spam report to be sent to.
+ * @return a URL.
+ */
@JsonProperty("post_to_url")
public String getPostToUrl() {
return postToUrl;
}
+ /**
+ * Set the Inbout Parse URL.
+ * @param postToUrl a URL.
+ */
public void setPostToUrl(String postToUrl) {
this.postToUrl = postToUrl;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
index ad1121c2..2ca6616b 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
@@ -4,6 +4,13 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * A subscription tracking setting object. Subscription tracking
+ * allows you to insert a subscription management link at the
+ * bottom of the text and html bodies of your email. If you
+ * would like to specify the location of the link within your
+ * email, you may use the substitution_tag.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class SubscriptionTrackingSetting {
@JsonProperty("enable") private boolean enable;
@@ -11,39 +18,80 @@ public class SubscriptionTrackingSetting {
@JsonProperty("html") private String html;
@JsonProperty("substitution_tag") private String substitutionTag;
+ /**
+ * Determines if this setting is enabled.
+ * @return true if subscription tracking is enabled, false otherwise.
+ */
@JsonProperty("enable")
public boolean getEnable() {
return enable;
}
+ /**
+ * Set if this setting is enabled.
+ * @param enable true if subscription tracking is enabled, false otherwise.
+ */
public void setEnable(boolean enable) {
this.enable = enable;
}
+ /**
+ * Get the plain text to be appended to the email, with the
+ * subscription tracking link. You may control where
+ * the link is by using the tag <% %>
+ * @return the plain text.
+ */
@JsonProperty("text")
public String getText() {
return text;
}
+ /**
+ * Set the plain text.
+ * @param text the plain text.
+ */
public void setText(String text) {
this.text = text;
}
+ /**
+ * Get the HTML to be appended to the email, with the
+ * subscription tracking link. You may control where
+ * the link is by using the tag <% %>
+ * @return the HTML.
+ */
@JsonProperty("html")
public String getHtml() {
return html;
}
+ /**
+ * Set the HTML.
+ * @param html the HTML.
+ */
public void setHtml(String html) {
this.html = html;
}
+ /**
+ * Get the tag that will be replaced with the
+ * unsubscribe URL. for example: [unsubscribe_url].
+ * If this parameter is used, it will override both
+ * the text and html parameters. The URL of the link
+ * will be placed at the substitution tag’s location,
+ * with no additional formatting.
+ * @return the substitution tag.
+ */
@JsonProperty("substitution_tag")
public String getSubstitutionTag() {
return substitutionTag;
}
+ /**
+ * Set the substitution tag.
+ * @param substitutionTag the substitution tag.
+ */
public void setSubstitutionTag(String substitutionTag) {
this.substitutionTag = substitutionTag;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
index 4da565d5..0e2a47bb 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
@@ -4,6 +4,11 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * An object representing the settings to determine how
+ * you would like to track the metrics of how your recipients
+ * interact with your email.
+ */
@JsonInclude(Include.NON_DEFAULT)
public class TrackingSettings {
@JsonProperty("click_tracking") private ClickTrackingSetting clickTrackingSetting;
@@ -11,39 +16,79 @@ public class TrackingSettings {
@JsonProperty("subscription_tracking") private SubscriptionTrackingSetting subscriptionTrackingSetting;
@JsonProperty("ganalytics") private GoogleAnalyticsSetting googleAnalyticsSetting;
+ /**
+ * Get the click tracking setting. Click tracking allows you to
+ * track whether a recipient clicked a link in your email.
+ * @return the setting.
+ */
@JsonProperty("click_tracking")
public ClickTrackingSetting getClickTrackingSetting() {
return clickTrackingSetting;
}
+ /**
+ * Set the click tracking setting.
+ * @param clickTrackingSetting the setting.
+ */
public void setClickTrackingSetting(ClickTrackingSetting clickTrackingSetting) {
this.clickTrackingSetting = clickTrackingSetting;
}
+ /**
+ * Get the open tracking setting. The open tracking allows you to
+ * track whether the email was opened or not, but including a single
+ * pixel image in the body of the content. When the pixel is loaded, we can log that the email was opened.
+ * @return the setting.
+ */
@JsonProperty("open_tracking")
public OpenTrackingSetting getOpenTrackingSetting() {
return openTrackingSetting;
}
+ /**
+ * Set the open tracking setting.
+ * @param openTrackingSetting the setting.
+ */
public void setOpenTrackingSetting(OpenTrackingSetting openTrackingSetting) {
this.openTrackingSetting = openTrackingSetting;
}
+ /**
+ * Get the subscription tracking setting. The subscription
+ * tracking setting allows you to insert a subscription
+ * management link at the bottom of the text and html bodies
+ * of your email. If you would like to specify the location
+ * of the link within your email, you may use the substitution_tag.
+ * @return the setting.
+ */
@JsonProperty("subscription_tracking")
public SubscriptionTrackingSetting getSubscriptionTrackingSetting() {
return subscriptionTrackingSetting;
}
+ /**
+ * Set the subscription tracking setting.
+ * @param subscriptionTrackingSetting the setting.
+ */
public void setSubscriptionTrackingSetting(SubscriptionTrackingSetting subscriptionTrackingSetting) {
this.subscriptionTrackingSetting = subscriptionTrackingSetting;
}
+ /**
+ * Get the Google Analytics setting. This setting allows you to
+ * enable tracking provided by Google Analytics.
+ * @return the setting.
+ */
@JsonProperty("ganalytics")
public GoogleAnalyticsSetting getGoogleAnalyticsSetting() {
return googleAnalyticsSetting;
}
+ /**
+ * Set the Google Analytics setting.
+ * @param googleAnalyticsSetting the setting.
+ */
public void setGoogleAnalyticsSetting(GoogleAnalyticsSetting googleAnalyticsSetting) {
this.googleAnalyticsSetting = googleAnalyticsSetting;
}
-}
\ No newline at end of file
+}
From 083f524811265af0a08d6ed0039a2cba60285ba9 Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Tue, 10 Oct 2017 15:44:11 +0200
Subject: [PATCH 023/345] Adds new lines to the end of the files.
---
scripts/startPrism.sh | 2 +-
test/prism.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/startPrism.sh b/scripts/startPrism.sh
index 7438aa5d..13c35548 100755
--- a/scripts/startPrism.sh
+++ b/scripts/startPrism.sh
@@ -55,4 +55,4 @@ else
echo "Prism is not installed."
install
run
-fi
\ No newline at end of file
+fi
diff --git a/test/prism.sh b/test/prism.sh
index 5d9d3002..d6e0f251 100644
--- a/test/prism.sh
+++ b/test/prism.sh
@@ -39,4 +39,4 @@ else
fi
}
-install
\ No newline at end of file
+install
From a21f3da020ef4ff8eaa01c4ccc9952cf7006b3a1 Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Tue, 10 Oct 2017 17:22:32 +0200
Subject: [PATCH 024/345] Makes prism script executable.
---
test/prism.sh | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 test/prism.sh
diff --git a/test/prism.sh b/test/prism.sh
old mode 100644
new mode 100755
From 0000925234db32bff25ba723f06338746fe32531 Mon Sep 17 00:00:00 2001
From: Andy Trimble
Date: Tue, 10 Oct 2017 13:57:47 -0600
Subject: [PATCH 025/345] Initial implementation.
---
src/main/java/com/sendgrid/APICallback.java | 19 +++
.../java/com/sendgrid/RateLimitException.java | 36 +++++
src/main/java/com/sendgrid/SendGrid.java | 126 +++++++++++++++++-
src/test/java/com/sendgrid/SendGridTest.java | 92 +++++++++++++
4 files changed, 266 insertions(+), 7 deletions(-)
create mode 100644 src/main/java/com/sendgrid/APICallback.java
create mode 100644 src/main/java/com/sendgrid/RateLimitException.java
diff --git a/src/main/java/com/sendgrid/APICallback.java b/src/main/java/com/sendgrid/APICallback.java
new file mode 100644
index 00000000..fde54f9d
--- /dev/null
+++ b/src/main/java/com/sendgrid/APICallback.java
@@ -0,0 +1,19 @@
+package com.sendgrid;
+
+/**
+ * An interface describing a callback mechanism for the
+ * asynchronous, rate limit aware API connection.
+ */
+public interface APICallback {
+ /**
+ * Callback method in case of an error.
+ * @param ex the error that was thrown.
+ */
+ public void error(Exception ex);
+
+ /**
+ * Callback method in case of a valid response.
+ * @param response the valid response.
+ */
+ public void response(Response response);
+}
diff --git a/src/main/java/com/sendgrid/RateLimitException.java b/src/main/java/com/sendgrid/RateLimitException.java
new file mode 100644
index 00000000..4912ac92
--- /dev/null
+++ b/src/main/java/com/sendgrid/RateLimitException.java
@@ -0,0 +1,36 @@
+package com.sendgrid;
+
+/**
+ * An exception thrown when the maximum number of retries
+ * have occurred, and the API calls are still rate limited.
+ */
+public class RateLimitException extends Exception {
+ private final Request request;
+ private final int retryCount;
+
+ /**
+ * Construct a new exception.
+ * @param request the originating request object.
+ * @param retryCount the number of times a retry was attempted.
+ */
+ public RateLimitException(Request request, int retryCount) {
+ this.request = request;
+ this.retryCount = retryCount;
+ }
+
+ /**
+ * Get the originating request object.
+ * @return the request object.
+ */
+ public Request getRequest() {
+ return this.request;
+ }
+
+ /**
+ * Get the number of times the action was attemted.
+ * @return the retry count.
+ */
+ public int getRetryCount() {
+ return this.retryCount;
+ }
+}
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 6bf14295..1d49d4f4 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ExecutorService;
/**
* Class SendGrid allows for quick and easy access to the SendGrid API.
@@ -13,6 +15,10 @@ public class SendGrid {
/** The user agent string to return to SendGrid. */
private static final String USER_AGENT = "sendgrid/" + VERSION + ";java";
+ private static final int RATE_LIMIT_RESPONSE_CODE = 429;
+ private static final int THREAD_POOL_SIZE = 8;
+
+ private ExecutorService pool;
/** The user's API key. */
private String apiKey;
@@ -27,7 +33,13 @@ public class SendGrid {
private Client client;
/** The request headers container. */
- private Map requestHeaders;
+ private Map requestHeaders;
+
+ /** The number of times to try after a rate limit. */
+ private int rateLimitRetry;
+
+ /** The number of milliseconds to sleep between retries. */
+ private int rateLimitSleep;
/**
* Construct a new SendGrid API wrapper.
@@ -73,6 +85,10 @@ public void initializeSendGrid(String apiKey) {
this.requestHeaders.put("Authorization", "Bearer " + apiKey);
this.requestHeaders.put("User-agent", USER_AGENT);
this.requestHeaders.put("Accept", "application/json");
+ this.rateLimitRetry = 5;
+ this.rateLimitSleep = 1100;
+
+ this.pool = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
}
/**
@@ -103,7 +119,7 @@ public void setVersion(String version) {
* Obtain the request headers.
* @return the request headers.
*/
- public Map getRequestHeaders() {
+ public Map getRequestHeaders() {
return this.requestHeaders;
}
@@ -113,7 +129,7 @@ public Map getRequestHeaders() {
* @param value the header value.
* @return the new set of request headers.
*/
- public Map addRequestHeader(String key, String value) {
+ public Map addRequestHeader(String key, String value) {
this.requestHeaders.put(key, value);
return getRequestHeaders();
}
@@ -123,7 +139,7 @@ public Map addRequestHeader(String key, String value) {
* @param key the header key to remove.
* @return the new set of request headers.
*/
- public Map removeRequestHeader(String key) {
+ public Map removeRequestHeader(String key) {
this.requestHeaders.remove(key);
return getRequestHeaders();
}
@@ -145,7 +161,43 @@ public void setHost(String host) {
}
/**
- * Class makeCall makes the call to the SendGrid API, override this method for testing.
+ * Get the maximum number of retries on a rate limit response.
+ * The default is 5.
+ * @return the number of retries on a rate limit.
+ */
+ public int getRateLimitRetry() {
+ return this.rateLimitRetry;
+ }
+
+ /**
+ * Set the maximum number of retries on a rate limit response.
+ * @param rateLimitRetry the maximum retry count.
+ */
+ public void setRateLimitRetry(int rateLimitRetry) {
+ this.rateLimitRetry = rateLimitRetry;
+ }
+
+ /**
+ * Get the duration of time (in milliseconds) to sleep between
+ * consecutive rate limit retries. The SendGrid API enforces
+ * the rate limit to the second. The default value is 1.1 seconds.
+ * @return the sleep duration.
+ */
+ public int getRateLimitSleep() {
+ return this.rateLimitSleep;
+ }
+
+ /**
+ * Set the duration of time (in milliseconds) to sleep between
+ * consecutive rate limit retries.
+ * @param rateLimitSleep the sleep duration.
+ */
+ public void setRateLimitSleep(int rateLimitSleep) {
+ this.rateLimitSleep = rateLimitSleep;
+ }
+
+ /**
+ * Makes the call to the SendGrid API, override this method for testing.
* @param request the request to make.
* @return the response object.
* @throws IOException in case of a network error.
@@ -166,13 +218,73 @@ public Response api(Request request) throws IOException {
req.setBaseUri(this.host);
req.setEndpoint("/" + version + "/" + request.getEndpoint());
req.setBody(request.getBody());
- for (Map.Entry header : this.requestHeaders.entrySet()) {
+ for (Map.Entry header : this.requestHeaders.entrySet()) {
req.addHeader(header.getKey(), header.getValue());
}
- for (Map.Entry queryParam : request.getQueryParams().entrySet()) {
+ for (Map.Entry queryParam : request.getQueryParams().entrySet()) {
req.addQueryParam(queryParam.getKey(), queryParam.getValue());
}
return makeCall(req);
}
+
+ /**
+ * Attempt an API call. This method executes the API call asynchronously
+ * on an internal thread pool. If the call is rate limited, the thread
+ * will retry up to the maximum configured time.
+ * @param request the API request.
+ */
+ public void attempt(Request request) {
+ this.attempt(request, new APICallback() {
+ @Override
+ public void error(Exception ex) {
+ }
+
+ public void response(Response r) {
+ }
+ });
+ }
+
+ /**
+ * Attempt an API call. This method executes the API call asynchronously
+ * on an internal thread pool. If the call is rate limited, the thread
+ * will retry up to the maximum configured time. The supplied callback
+ * will be called in the event of an error, or a successful response.
+ * @param request the API request.
+ * @param callback the callback.
+ */
+ public void attempt(Request request, APICallback callback) {
+ this.pool.execute(new Runnable() {
+ @Override
+ public void run() {
+ Response response;
+
+ // Retry until the retry limit has been reached.
+ for (int i = 0; i < rateLimitRetry; ++i) {
+ try {
+ response = api(request);
+ } catch (IOException ex) {
+ // Stop retrying if there is a network error.
+ callback.error(ex);
+ return;
+ }
+
+ // We have been rate limited.
+ if (response.getStatusCode() == RATE_LIMIT_RESPONSE_CODE) {
+ try {
+ Thread.sleep(rateLimitSleep);
+ } catch (InterruptedException ex) {
+ // Can safely ignore this exception and retry.
+ }
+ } else {
+ callback.response(response);
+ return;
+ }
+ }
+
+ // Retries exhausted. Return error.
+ callback.error(new RateLimitException(request, rateLimitRetry));
+ }
+ });
+ }
}
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 5ec45eab..8f469bf0 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -74,6 +74,98 @@ public void testHost() {
Assert.assertEquals(sg.getHost(), "api.new.com");
}
+ @Test
+ public void testRateLimitRetry() {
+ SendGrid sg = new SendGrid(SENDGRID_API_KEY);
+ sg.setRateLimitRetry(100);
+ Assert.assertEquals(sg.getRateLimitRetry(), 100);
+ }
+
+ @Test
+ public void testRateLimitSleep() {
+ SendGrid sg = new SendGrid(SENDGRID_API_KEY);
+ sg.setRateLimitSleep(999);
+ Assert.assertEquals(sg.getRateLimitSleep(), 999);
+ }
+
+
+ @Test
+ public void test_async() {
+ Object sync = new Object();
+ SendGrid sg = null;
+ if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
+ sg = new SendGrid("SENDGRID_API_KEY");
+ sg.setHost(System.getenv("MOCK_HOST"));
+ } else {
+ sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
+ }
+ sg.addRequestHeader("X-Mock", "200");
+
+ Request request = new Request();
+
+ request.setMethod(Method.GET);
+ request.setEndpoint("access_settings/activity");
+ request.addQueryParam("limit", "1");
+ sg.attempt(request, new APICallback() {
+ @Override
+ public void error(Exception e) {
+ Assert.fail();
+ sync.notify();
+ }
+
+ @Override
+ public void response(Response response) {
+ Assert.assertEquals(200, response.getStatusCode());
+ sync.notify();
+ }
+ });
+
+ try {
+ sync.wait(2000);
+ } catch(InterruptedException ex) {
+ Assert.fail(ex.toString());
+ }
+ }
+
+ @Test
+ public void test_async_rate_limit() {
+ Object sync = new Object();
+ SendGrid sg = null;
+ if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
+ sg = new SendGrid("SENDGRID_API_KEY");
+ sg.setHost(System.getenv("MOCK_HOST"));
+ } else {
+ sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
+ }
+ sg.addRequestHeader("X-Mock", "429");
+
+ Request request = new Request();
+
+ request.setMethod(Method.GET);
+ request.setEndpoint("access_settings/activity");
+ request.addQueryParam("limit", "1");
+ sg.attempt(request, new APICallback() {
+ @Override
+ public void error(Exception e) {
+ Assert.assertEquals(e.getClass(), RateLimitException.class);
+ sync.notify();
+ }
+
+ @Override
+ public void response(Response response) {
+ Assert.fail();
+ sync.notify();
+ }
+ });
+
+ try {
+ sync.wait(2000);
+ } catch(InterruptedException ex) {
+ Assert.fail(ex.toString());
+ }
+ }
@Test
public void test_access_settings_activity_get() throws IOException {
From 6e6d7b59499ecac98765e3288ebe5d646e4d9027 Mon Sep 17 00:00:00 2001
From: Andy Trimble
Date: Tue, 10 Oct 2017 14:07:45 -0600
Subject: [PATCH 026/345] Fixed test race condition, and compile issue.
---
src/main/java/com/sendgrid/SendGrid.java | 2 +-
src/test/java/com/sendgrid/SendGridTest.java | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 1d49d4f4..37839f56 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -253,7 +253,7 @@ public void response(Response r) {
* @param request the API request.
* @param callback the callback.
*/
- public void attempt(Request request, APICallback callback) {
+ public void attempt(final Request request, final APICallback callback) {
this.pool.execute(new Runnable() {
@Override
public void run() {
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 8f469bf0..2249b81f 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -91,7 +91,7 @@ public void testRateLimitSleep() {
@Test
public void test_async() {
- Object sync = new Object();
+ final Object sync = new Object();
SendGrid sg = null;
if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
sg = new SendGrid("SENDGRID_API_KEY");
@@ -111,18 +111,24 @@ public void test_async() {
@Override
public void error(Exception e) {
Assert.fail();
- sync.notify();
+ synchronized(sync) {
+ sync.notify();
+ }
}
@Override
public void response(Response response) {
Assert.assertEquals(200, response.getStatusCode());
- sync.notify();
+ synchronized(sync) {
+ sync.notify();
+ }
}
});
try {
- sync.wait(2000);
+ synchronized(sync) {
+ sync.wait(2000);
+ }
} catch(InterruptedException ex) {
Assert.fail(ex.toString());
}
@@ -130,7 +136,7 @@ public void response(Response response) {
@Test
public void test_async_rate_limit() {
- Object sync = new Object();
+ final Object sync = new Object();
SendGrid sg = null;
if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
sg = new SendGrid("SENDGRID_API_KEY");
@@ -161,7 +167,9 @@ public void response(Response response) {
});
try {
- sync.wait(2000);
+ synchronized(sync) {
+ sync.wait(2000);
+ }
} catch(InterruptedException ex) {
Assert.fail(ex.toString());
}
From 2afa5192a9b26c16c16618c2f8de0ba223c91fc2 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Tue, 10 Oct 2017 13:20:20 -0700
Subject: [PATCH 027/345] Version Bump v4.1.1: PR #247 Added Javadocs.
---
CHANGELOG.md | 5 +++++
CONTRIBUTING.md | 2 +-
README.md | 2 +-
build.gradle | 2 +-
pom.xml | 2 +-
src/main/java/com/sendgrid/SendGrid.java | 5 +----
.../helpers/mail/objects/Personalization.java | 20 +++++++++----------
.../objects/SubscriptionTrackingSetting.java | 4 ++--
8 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8fd10782..7a85d7e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.
+## [4.1.1] - 2017-10-10
+### Added
+- PR #247 Added Javadocs.
+- BIG thanks to [Andy Trimble](https://github.com/andy-trimble)
+
## [4.1.0] - 2017-08-16
### Added
- PR #211 Return empty collections in place of nulls
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e627ccc1..afec7437 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -102,7 +102,7 @@ touch Example.java
Add the example you want to test to Example.java, including the headers at the top of the file.
``` bash
-javac -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.0-jar.jar:. Example
+javac -classpath ../repo/com/sendgrid/4.1.1/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.1-jar.jar:. Example
```
diff --git a/README.md b/README.md
index 99fceeb3..02725369 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
- compile 'com.sendgrid:sendgrid-java:4.1.0'
+ compile 'com.sendgrid:sendgrid-java:4.1.1'
}
repositories {
diff --git a/build.gradle b/build.gradle
index 881a496e..52c07eb5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'
group = 'com.sendgrid'
-version = '4.1.0'
+version = '4.1.1'
ext.packaging = 'jar'
allprojects {
diff --git a/pom.xml b/pom.xml
index 07545420..249d79d4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.sendgrid
sendgrid-java
SendGrid Java helper library
- 4.1.0
+ 4.1.1
This Java module allows you to quickly and easily send emails through SendGrid using Java.
https://github.com/sendgrid/sendgrid-java
diff --git a/src/main/java/com/sendgrid/SendGrid.java b/src/main/java/com/sendgrid/SendGrid.java
index 6bf14295..897728bc 100644
--- a/src/main/java/com/sendgrid/SendGrid.java
+++ b/src/main/java/com/sendgrid/SendGrid.java
@@ -32,7 +32,6 @@ public class SendGrid {
/**
* Construct a new SendGrid API wrapper.
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- * @return a SendGrid object.
*/
public SendGrid(String apiKey) {
this.client = new Client();
@@ -43,7 +42,6 @@ public SendGrid(String apiKey) {
* Construct a new SendGrid API wrapper.
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
* @param test is true if you are unit testing
- * @return a SendGrid object.
*/
public SendGrid(String apiKey, Boolean test) {
this.client = new Client(test);
@@ -54,7 +52,6 @@ public SendGrid(String apiKey, Boolean test) {
* Construct a new SendGrid API wrapper.
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
* @param client the Client to use (allows to customize its configuration)
- * @return a SendGrid object.
*/
public SendGrid(String apiKey, Client client) {
this.client = client;
@@ -138,7 +135,7 @@ public String getHost() {
/**
* Set the SendGrid host.
- * @host the new SendGrid host.
+ * @param host the new SendGrid host.
*/
public void setHost(String host) {
this.host = host;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index b72f2316..83bd9c56 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -31,9 +31,9 @@ public class Personalization {
* Get the to list. This is an array of recipients. Each object
* within this array may contain the name, but must always
* contain the email, of a recipient.
- *
+ *
* The maximum number of entries is 1000.
- *
+ *
* Content added to the returned list will be included when sent.
* @return the to list.
*/
@@ -64,9 +64,9 @@ public void addTo(Email email) {
* Set the CC list. This is an array of recipients. Each object
* within this array may contain the name, but must always
* contain the email, of a recipient.
- *
+ *
* The maximum number of entries is 1000.
- *
+ *
* Content added to the returned list will be included when sent.
* @return the CC list.
*/
@@ -97,9 +97,9 @@ public void addCc(Email email) {
* Set the BCC list. This is an array of recipients. Each object
* within this array may contain the name, but must always
* contain the email, of a recipient.
- *
+ *
* The maximum number of entries is 1000.
- *
+ *
* Content added to the returned list will be included when sent.
* @return the BCC list.
*/
@@ -150,7 +150,7 @@ public void setSubject(String subject) {
* following headers: x-sg-id, x-sg-eid, received,
* dkim-signature, Content-Type, Content-Transfer-Encoding,
* To, From, Subject, Reply-To, CC, BCC
- *
+ *
* Content added to the returned list will be included when sent.
* @return the headers.
*/
@@ -184,9 +184,9 @@ public void addHeader(String key, String value) {
* to the subject and reply-to parameters. The total
* collective size of your substitutions may not exceed
* 10,000 bytes per personalization object.
- *
+ *
* The maximum number of entries is 1000.
- *
+ *
* Content added to the returned list will be included when sent.
* @return the substitutions.
*/
@@ -219,7 +219,7 @@ public void addSubstitution(String key, String value) {
* is entered into this parameter will be assumed to be
* the custom argument that you would like to be used. i
* May not exceed 10,000 bytes.
- *
+ *
* Content added to the returned list will be included when sent.
* @return the custom arguments.
*/
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
index 2ca6616b..304eb916 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
@@ -38,7 +38,7 @@ public void setEnable(boolean enable) {
/**
* Get the plain text to be appended to the email, with the
* subscription tracking link. You may control where
- * the link is by using the tag <% %>
+ * the link is by using the tag <% %>
* @return the plain text.
*/
@JsonProperty("text")
@@ -57,7 +57,7 @@ public void setText(String text) {
/**
* Get the HTML to be appended to the email, with the
* subscription tracking link. You may control where
- * the link is by using the tag <% %>
+ * the link is by using the tag <% %>
* @return the HTML.
*/
@JsonProperty("html")
From 725d0f9e175c77c8de6137937832f6e49030f3f6 Mon Sep 17 00:00:00 2001
From: JR
Date: Tue, 10 Oct 2017 18:37:37 -0400
Subject: [PATCH 028/345] Added CODE_OF_CONDUCT.md
Added CODE_OF_CONDUCT.md to root of this repo
---
CODE_OF_CONDUCT.md | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 CODE_OF_CONDUCT.md
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..a6ad51a7
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,42 @@
+
+ # SendGrid Community Code of Conduct
+
+ The SendGrid open source community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences successes and continued growth. When you're working with members of the community, we encourage you to follow these guidelines, which help steer our interactions and strive to maintain a positive, successful and growing community.
+
+ ### Be Open
+ Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference.
+
+ ### Be Considerate
+ Members of the community are considerate of their peers, which include other contributors and users of SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.
+
+ ### Be Respectful
+ Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
+
+ ## Additional Guidance
+
+ ### Disclose Potential Conflicts of Interest
+ Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another.
+
+ ### Interpretation
+ This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest.
+
+ ### Enforcement
+ Most members of the SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors.
+
+ ## If you have concerns about someone’s conduct
+ **Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code.
+
+ **Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first.
+
+ **Contact the Moderators** - You can reach the SendGrid moderators by emailing dx@sendgrid.com.
+
+ ## Submission to SendGrid Repositories
+ Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com).
+
+ ## Attribution
+
+ SendGrid thanks the following, on which it draws for content and inspiration:
+
+ * [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/)
+ * [Open Source Initiative General Code of Conduct](https://opensource.org/codeofconduct)
+ * [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html)
From 10a0ea26446a5c225ddeb4172e2c3b449d552507 Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Tue, 10 Oct 2017 21:59:09 -0500
Subject: [PATCH 029/345] Adding @return @throws @param and formatting file.
---
src/main/java/com/sendgrid/SendGridAPI.java | 128 ++++++++++++--------
1 file changed, 75 insertions(+), 53 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGridAPI.java b/src/main/java/com/sendgrid/SendGridAPI.java
index bfbb230c..d190675c 100644
--- a/src/main/java/com/sendgrid/SendGridAPI.java
+++ b/src/main/java/com/sendgrid/SendGridAPI.java
@@ -5,66 +5,88 @@
public interface SendGridAPI {
- /**
- * Initializes SendGrid
- * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- */
- public void initializeSendGrid(String apiKey);
+ /**
+ * Initializes SendGrid
+ *
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ */
+ public void initializeSendGrid(String apiKey);
- /**
- * Initializes SendGrid
- * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- */
- public String getLibraryVersion();
+ /**
+ * Initializes SendGrid
+ *
+ * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
+ * @return
+ */
+ public String getLibraryVersion();
- /**
- * Gets the version.
- */
- public String getVersion();
+ /**
+ * Gets the version.
+ *
+ * @return
+ */
+ public String getVersion();
- /**
- * Sets the version.
- * @param version the SendGrid version.
- */
- public void setVersion(String version);
+ /**
+ * Sets the version.
+ *
+ * @param version the SendGrid version.
+ */
+ public void setVersion(String version);
+ /**
+ * Gets the request headers.
+ * @return
+ */
+ public Map getRequestHeaders();
- /**
- * Gets the request headers.
- */
- public Map getRequestHeaders();
+ /**
+ * Adds a request headers.
+ *
+ * @param keythe key
+ * @param valuethe value
+ * @return
+ */
+ public Map addRequestHeader(String key, String value);
- /**
- * Adds a request headers.
- * @param key the key
- * @param value the value
- */
- public Map addRequestHeader(String key, String value);
+ /**
+ * Removes a request headers.
+ *
+ * @param key the key
+ * @return
+ */
+ public Map removeRequestHeader(String key);
- /**
- * Removes a request headers.
- * @param key the key
- */
- public Map removeRequestHeader(String key);
-
- /**
- * Gets the host.
- */
- public String getHost();
-
- /**
- * Sets the host.
- * @param host the host to set
- */
- public void setHost(String host);
+ /**
+ * Gets the host.
+ *
+ * @return
+ */
+ public String getHost();
- /**
- * Class makeCall makes the call to the SendGrid API, override this method for testing.
- */
- public Response makeCall(Request request) throws IOException;
+ /**
+ * Sets the host.
+ *
+ * @param host the host to set
+ */
+ public void setHost(String host);
- /**
- * Class api sets up the request to the SendGrid API, this is main interface.
- */
- public Response api(Request request) throws IOException;
+ /**
+ * Class makeCall makes the call to the SendGrid API, override this method for
+ * testing.
+ *
+ * @param request
+ * @return
+ * @throws IOException
+ */
+ public Response makeCall(Request request) throws IOException;
+
+ /**
+ * Class api sets up the request to the SendGrid API, this is main interface.
+ *
+ * @param request
+ * @return
+ * @throws IOException
+ */
+ public Response api(Request request) throws IOException;
}
From 665b0b4829f15965d1fee7bb09c6985ca921f13a Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Wed, 11 Oct 2017 17:15:03 +0200
Subject: [PATCH 030/345] Fixes prism startup script. Attempts to fix travis
build.
---
.travis.yml | 5 ++---
scripts/startPrism.sh | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index a07cec04..8ad70c07 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,9 +11,8 @@ matrix:
- os: linux
jdk: oraclejdk8
before_script:
-- mkdir -p prism/bin
-- export PATH=$PATH:$PWD/prism/bin/
-- ./test/prism.sh
+- "./scripts/startPrism.sh &"
+- sleep 10
after_script:
- "./gradlew build"
diff --git a/scripts/startPrism.sh b/scripts/startPrism.sh
index 13c35548..53923593 100755
--- a/scripts/startPrism.sh
+++ b/scripts/startPrism.sh
@@ -45,7 +45,7 @@ fi
run () {
echo "Running prism..."
cd ../prism/bin
- prism run --mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
+ ./prism run --mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json
}
if [ -f ../prism/bin/prism ]; then
From 8895f22a083623141a856fdd3d0a7284e78599a1 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Wed, 11 Oct 2017 08:43:16 -0700
Subject: [PATCH 031/345] Update .travis.yml
---
.travis.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 8ad70c07..6d5607bd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,7 +13,11 @@ matrix:
before_script:
- "./scripts/startPrism.sh &"
- sleep 10
-
+before_install:
+- cat /etc/hosts # optionally check the content *before*
+- sudo hostname "$(hostname | cut -c1-63)"
+- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
+- cat /etc/hosts # optionally check the content *after*
after_script:
- "./gradlew build"
- "./scripts/upload.sh"
From 02c6f4e50015a01f7125f7c1a493bd661707ce55 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Wed, 11 Oct 2017 08:46:23 -0700
Subject: [PATCH 032/345] Update .travis.yml
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 6d5607bd..dc8a908f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ matrix:
- os: linux
jdk: oraclejdk8
before_script:
-- "./scripts/startPrism.sh &"
+- "./scripts/startPrism.sh"
- sleep 10
before_install:
- cat /etc/hosts # optionally check the content *before*
From 5a0da482e7fe8e75c1c0645b569c63e92b3fedec Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Thu, 12 Oct 2017 12:06:17 +0200
Subject: [PATCH 033/345] Fixes field naming in tests.
---
.../objects/SettingsSerializationTest.java | 40 +++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java b/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
index 48fbfcc6..74e6c8b5 100644
--- a/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
+++ b/src/test/java/com/sendgrid/helpers/mail/objects/SettingsSerializationTest.java
@@ -20,8 +20,8 @@ public void testOpenTrackingSettingSerialization() throws Exception {
OpenTrackingSetting setting = new OpenTrackingSetting();
setting.setEnable(false);
- String jsonOne = mapper.writeValueAsString(setting);
- Assert.assertEquals(jsonOne, "{\"enable\":false}");
+ String json = mapper.writeValueAsString(setting);
+ Assert.assertEquals(json, "{\"enable\":false}");
}
@Test
@@ -29,9 +29,9 @@ public void testClickTrackingSettingSerialization() throws Exception {
ClickTrackingSetting setting = new ClickTrackingSetting();
setting.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(setting);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false,\"enable_text\":false}");
+ String json = mapper.writeValueAsString(setting);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false,\"enable_text\":false}");
}
@Test
@@ -39,9 +39,9 @@ public void testSubscriptionTrackingSettingSerialization() throws Exception {
SubscriptionTrackingSetting setting = new SubscriptionTrackingSetting();
setting.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(setting);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ String json = mapper.writeValueAsString(setting);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false}");
}
@Test
@@ -49,9 +49,9 @@ public void testGoogleAnalyticsTrackingSettingSerialization() throws Exception {
GoogleAnalyticsSetting setting = new GoogleAnalyticsSetting();
setting.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(setting);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ String json = mapper.writeValueAsString(setting);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false}");
}
@Test
@@ -59,9 +59,9 @@ public void testSpamCheckSettingSerialization() throws Exception {
SpamCheckSetting setting = new SpamCheckSetting();
setting.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(setting);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false,\"threshold\":0}");
+ String json = mapper.writeValueAsString(setting);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false,\"threshold\":0}");
}
@Test
@@ -69,9 +69,9 @@ public void testFooterSettingSerialization() throws Exception {
FooterSetting setting = new FooterSetting();
setting.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(setting);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ String json = mapper.writeValueAsString(setting);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false}");
}
@Test
@@ -79,8 +79,8 @@ public void testBccSettingsSerialization() throws Exception {
BccSettings settings = new BccSettings();
settings.setEnable(false);
- String jsonTwo = mapper.writeValueAsString(settings);
- System.out.println(jsonTwo);
- Assert.assertEquals(jsonTwo, "{\"enable\":false}");
+ String json = mapper.writeValueAsString(settings);
+ System.out.println(json);
+ Assert.assertEquals(json, "{\"enable\":false}");
}
}
From a43392fac958dd60acdcbc09189c16e3828389c2 Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Thu, 12 Oct 2017 16:54:51 +0200
Subject: [PATCH 034/345] Checks if the prism port is in use.
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index dc8a908f..7f50f52b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,7 @@ before_install:
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
- cat /etc/hosts # optionally check the content *after*
after_script:
+- lsof -i :4010 -S # adds some debugging statements
- "./gradlew build"
- "./scripts/upload.sh"
env:
From 9b3f92cbc1116b9cd6b2a873fd098ee50004fc44 Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Thu, 12 Oct 2017 17:06:22 +0200
Subject: [PATCH 035/345] Reverts back to running prism in background.
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 7f50f52b..4fc4dbee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ matrix:
- os: linux
jdk: oraclejdk8
before_script:
-- "./scripts/startPrism.sh"
+- "./scripts/startPrism.sh &"
- sleep 10
before_install:
- cat /etc/hosts # optionally check the content *before*
From 2464dd8747e6e7da35c9513a0b6c25ee2a57c7fb Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Thu, 12 Oct 2017 22:15:55 -0500
Subject: [PATCH 036/345] Adding new line at the end of the file.
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 86ef37d8..7cc79a80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,4 +127,4 @@
test
-
\ No newline at end of file
+
From e28455d4391aca01a053b72ff7c302fbad99b97e Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Thu, 12 Oct 2017 22:17:33 -0500
Subject: [PATCH 037/345] Adding new line at the end of the file.
---
pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/pom.xml b/pom.xml
index 7cc79a80..d250df9f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,3 +128,4 @@
+
From a061b8c747c9282dee845d16371d9e44e05f22fd Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Fri, 13 Oct 2017 17:45:37 +0200
Subject: [PATCH 038/345] Prints debug statement and exception.
---
src/test/java/com/sendgrid/SendGridTest.java | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 5ec45eab..7d056d92 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -4163,18 +4163,28 @@ public void test_whitelabel_domains_post() throws IOException {
if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
sg = new SendGrid("SENDGRID_API_KEY");
sg.setHost(System.getenv("MOCK_HOST"));
+
+ System.out.println("===== Use ??? === ");
} else {
sg = new SendGrid("SENDGRID_API_KEY", true);
sg.setHost("localhost:4010");
+
+ System.out.println("===== Use localhost === ");
}
sg.addRequestHeader("X-Mock", "201");
- Request request = new Request();
- request.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains");
- request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
- Response response = sg.api(request);
- Assert.assertEquals(201, response.getStatusCode());
+ try {
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains");
+ request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
+ Response response = sg.api(request);
+ Assert.assertEquals(201, response.getStatusCode());
+ } catch (Exception e) {
+ System.out.println("Debugging prism setup.");
+ e.printStackTrace();
+ }
+
}
@Test
From 6a626f35d6b9052164dfc9f1a362ca45176ed503 Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Fri, 13 Oct 2017 17:51:24 +0200
Subject: [PATCH 039/345] Rethrow exception in a test.
---
src/test/java/com/sendgrid/SendGridTest.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 7d056d92..5ff38886 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -4183,6 +4183,7 @@ public void test_whitelabel_domains_post() throws IOException {
} catch (Exception e) {
System.out.println("Debugging prism setup.");
e.printStackTrace();
+ throw e;
}
}
From 1ae3ed2011fbfc083a2e26aa2fbbfe3db9fa6b2d Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Sun, 15 Oct 2017 11:04:52 +0200
Subject: [PATCH 040/345] Reverts debugging statements.
---
src/test/java/com/sendgrid/SendGridTest.java | 23 +++++---------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 5ff38886..5ec45eab 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -4163,29 +4163,18 @@ public void test_whitelabel_domains_post() throws IOException {
if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
sg = new SendGrid("SENDGRID_API_KEY");
sg.setHost(System.getenv("MOCK_HOST"));
-
- System.out.println("===== Use ??? === ");
} else {
sg = new SendGrid("SENDGRID_API_KEY", true);
sg.setHost("localhost:4010");
-
- System.out.println("===== Use localhost === ");
}
sg.addRequestHeader("X-Mock", "201");
- try {
- Request request = new Request();
- request.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains");
- request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
- Response response = sg.api(request);
- Assert.assertEquals(201, response.getStatusCode());
- } catch (Exception e) {
- System.out.println("Debugging prism setup.");
- e.printStackTrace();
- throw e;
- }
-
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains");
+ request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
+ Response response = sg.api(request);
+ Assert.assertEquals(201, response.getStatusCode());
}
@Test
From c866a493c6759a5914051b0225be4203544f23a2 Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Sun, 15 Oct 2017 11:07:46 +0200
Subject: [PATCH 041/345] Sets MOCK_HOST env variable in travis.
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 4fc4dbee..5f0a4358 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,7 @@ after_script:
- "./scripts/upload.sh"
env:
global:
+ - MOCK_HOST=localhost:4010
- S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLWphdmEvIl0sCiAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMjA0OCwgMjY4NDM1NDU2XSwKICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJhcHBsaWNhdGlvbi96aXAiXQogIF0KfQo=
- secure: Iki1btwhG1nlyjnEMu90Oh/hoatFpPiiKkqpj7siLnlLp2xbBQ2003jRsn30I3Vujes2ugvzdlHqBJ9lDwRvfGrKXcLlRvYuDQ24N2YKquEiKHUxs+iMOzTQj6Sf64KL5O0aSZd1l5rjWgsQ0qqjHW9u3l5bUjqxzrhAI2Js37U=
- secure: Khi6a4z1lfZmDEDV738MOiWznRcTv5ILZUM+igEw2txX7PGX+B5909WridpAijTGiurJ6eda7jvsUgci8DTPQCXB18LD6N870hnPcSQkuI6zDAhKTx+w/ZsfPLWh28sP2CVzbqGdxaitZDKxRWaVmKnBZpyi8XI9UKjmyK2sjwE=
From db3f6c7ea9829530139944fb879ba7adf82037ea Mon Sep 17 00:00:00 2001
From: Shubheksha Jalan
Date: Mon, 16 Oct 2017 12:22:15 +0530
Subject: [PATCH 042/345] Update USE_CASES.md
- Add sections on email stats and setting up domain white labels
---
USE_CASES.md | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/USE_CASES.md b/USE_CASES.md
index 1bfb62f0..b9f7863f 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -98,4 +98,18 @@ public class Example {
}
}
}
-```
\ No newline at end of file
+```
+
+
+# How to Setup a Domain Whitelabel
+
+You can find documentation for how to setup a domain whitelabel via the UI [here](https://sendgrid.com/docs/Classroom/Basics/Whitelabel/setup_domain_whitelabel.html) and via API [here](https://github.com/sendgrid/sendgrid-csharp/blob/master/USAGE.md#whitelabel).
+
+Find more information about all of SendGrid's whitelabeling related documentation [here](https://sendgrid.com/docs/Classroom/Basics/Whitelabel/index.html).
+
+
+# How to View Email Statistics
+
+You can find documentation for how to view your email statistics via the UI [here](https://app.sendgrid.com/statistics) and via API [here](https://github.com/sendgrid/sendgrid-csharp/blob/master/USAGE.md#stats).
+
+Alternatively, we can post events to a URL of your choice via our [Event Webhook](https://sendgrid.com/docs/API_Reference/Webhooks/event.html) about events that occur as SendGrid processes your email.
From 56e8770c72f5a3e06416bfc6e7eb1655700ce071 Mon Sep 17 00:00:00 2001
From: Diego Camargo
Date: Mon, 16 Oct 2017 21:09:20 +0200
Subject: [PATCH 043/345] Add a way to verify that the content doesn't contain
sensitive information
---
.../helpers/mail/objects/Content.java | 23 +++++++++
.../com/sendgrid/helpers/ContentTest.java | 47 +++++++++++++++++++
2 files changed, 70 insertions(+)
create mode 100644 src/test/java/com/sendgrid/helpers/ContentTest.java
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
index f6621ac9..1a348ea5 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
@@ -4,6 +4,14 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.lang.IllegalArgumentException;
+
/**
* An object in which you may specify the content of your email.
*/
@@ -64,6 +72,21 @@ public String getValue() {
* @param value the value.
*/
public void setValue(String value) {
+ ContentVerifier.verifyContent(value);
this.value = value;
}
}
+
+class ContentVerifier {
+ private static final List FORBIDDEN_PATTERNS = Collections.singletonList(
+ Pattern.compile(".*SG\\.[a-zA-Z0-9(-|_)]*\\.[a-zA-Z0-9(-|_)]*.*")
+ );
+
+ static void verifyContent(String content) {
+ for (Pattern pattern: FORBIDDEN_PATTERNS) {
+ if (pattern.matcher(content).matches()) {
+ throw new IllegalArgumentException("Found a Forbidden Pattern in the content of the email");
+ }
+ }
+ }
+}
diff --git a/src/test/java/com/sendgrid/helpers/ContentTest.java b/src/test/java/com/sendgrid/helpers/ContentTest.java
new file mode 100644
index 00000000..05e2328c
--- /dev/null
+++ b/src/test/java/com/sendgrid/helpers/ContentTest.java
@@ -0,0 +1,47 @@
+package com.sendgrid;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class ContentTest {
+ private Content content;
+
+ @Before
+ public void setUp() {
+ this.content = new Content();
+ }
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Test
+ public void testForbiddenContentIsRejected() {
+
+ ArrayList sampleApiKeys = new ArrayList<>(
+ Arrays.asList(
+ "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",
+ "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"
+ )
+
+ );
+
+ for (String apiKey: sampleApiKeys) {
+ exception.expect(IllegalArgumentException.class);
+ this.content.setValue("My api key is: " + apiKey);
+ }
+ }
+
+ @Test
+ public void testNormalContentIsAllowed() {
+ String message = "I will not send you my api key!";
+ this.content.setValue(message);
+ Assert.assertEquals(message, this.content.getValue());
+ }
+
+}
From a2e2213f1e438a92e85cbb9b5900c4ded5dad3ac Mon Sep 17 00:00:00 2001
From: Shubheksha Jalan
Date: Tue, 17 Oct 2017 01:36:02 +0530
Subject: [PATCH 044/345] Add links in the table of contents, fix repo name in
links
---
USE_CASES.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/USE_CASES.md b/USE_CASES.md
index b9f7863f..13a06be9 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -3,6 +3,8 @@ This documentation provides examples for specific use cases. Please [open an iss
# Table of Contents
* [Transactional Templates](#transactional_templates)
+* [How to Setup a Domain Whitelabel](#domain_whitelabel)
+* [How to View Email Statistics](#email_stats)
# Transactional Templates
@@ -103,13 +105,13 @@ public class Example {
# How to Setup a Domain Whitelabel
-You can find documentation for how to setup a domain whitelabel via the UI [here](https://sendgrid.com/docs/Classroom/Basics/Whitelabel/setup_domain_whitelabel.html) and via API [here](https://github.com/sendgrid/sendgrid-csharp/blob/master/USAGE.md#whitelabel).
+You can find documentation for how to setup a domain whitelabel via the UI [here](https://sendgrid.com/docs/Classroom/Basics/Whitelabel/setup_domain_whitelabel.html) and via API [here](https://github.com/sendgrid/sendgrid-java/blob/master/USAGE.md#whitelabel).
Find more information about all of SendGrid's whitelabeling related documentation [here](https://sendgrid.com/docs/Classroom/Basics/Whitelabel/index.html).
# How to View Email Statistics
-You can find documentation for how to view your email statistics via the UI [here](https://app.sendgrid.com/statistics) and via API [here](https://github.com/sendgrid/sendgrid-csharp/blob/master/USAGE.md#stats).
+You can find documentation for how to view your email statistics via the UI [here](https://app.sendgrid.com/statistics) and via API [here](https://github.com/sendgrid/sendgrid-java/blob/master/USAGE.md#stats).
Alternatively, we can post events to a URL of your choice via our [Event Webhook](https://sendgrid.com/docs/API_Reference/Webhooks/event.html) about events that occur as SendGrid processes your email.
From ba59272eb88b0c3115a957e86c9fc064967144af Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Tue, 17 Oct 2017 20:15:05 +0300
Subject: [PATCH 045/345] add "viewing request body" section to troubleshooting
---
TROUBLESHOOTING.md | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md
index 7a4aace1..fc282d40 100644
--- a/TROUBLESHOOTING.md
+++ b/TROUBLESHOOTING.md
@@ -12,6 +12,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
* [Environment Variables and Your SendGrid API Key](#environment)
* [Using the Package Manager](#package-manager)
* [Android Compatibility](#android)
+* [Viewing the Request Body](#request-body)
## Migrating from v2 to v3
@@ -97,3 +98,14 @@ repositories {
Since Android SDK 23, HttpClient is no longer supported. Some workarounds can be found [here](http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio).
We have an issue to remove that dependency [here](https://github.com/sendgrid/java-http-client/issues/2), please upvote to move it up the queue.
+
+
+## Viewing the Request Body
+
+When debugging or testing, it may be useful to exampine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).
+
+You can do this right before you call `request.setBody(mail.build())` like so:
+
+```java
+System.out.println(mail.build());
+```
\ No newline at end of file
From 6517d4a2c7c1959e3f79f9239f871988d3e41210 Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Tue, 17 Oct 2017 20:48:38 +0300
Subject: [PATCH 046/345] Update USAGE.md and CONTRIBUTING.md
---
CONTRIBUTING.md | 2 +-
USAGE.md | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a515809f..8cb8ea5c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -167,7 +167,7 @@ Please run your code through:
# Clone your fork of the repo into the current directory
git clone https://github.com/sendgrid/sendgrid-java
# Navigate to the newly cloned directory
- cd sendgrid-python
+ cd sendgrid-java
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/sendgrid/sendgrid-java
```
diff --git a/USAGE.md b/USAGE.md
index bc64978b..b29616d7 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -2,7 +2,7 @@ This documentation is based on our [OAI specification](https://github.com/sendgr
# INITIALIZATION
-```ruby
+```java
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
From 25fafa89da47e65393630d8da26f6117bea60e5b Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Fri, 20 Oct 2017 08:35:01 +0200
Subject: [PATCH 047/345] Prints TRVIS and MOCK_HOST env variables.
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 5f0a4358..9986d9a1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,8 @@ matrix:
- os: linux
jdk: oraclejdk8
before_script:
+- echo TRAVIS $TRAVIS
+- echo MOCK_HOST $MOCK_HOST
- "./scripts/startPrism.sh &"
- sleep 10
before_install:
@@ -24,7 +26,6 @@ after_script:
- "./scripts/upload.sh"
env:
global:
- - MOCK_HOST=localhost:4010
- S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLWphdmEvIl0sCiAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMjA0OCwgMjY4NDM1NDU2XSwKICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJhcHBsaWNhdGlvbi96aXAiXQogIF0KfQo=
- secure: Iki1btwhG1nlyjnEMu90Oh/hoatFpPiiKkqpj7siLnlLp2xbBQ2003jRsn30I3Vujes2ugvzdlHqBJ9lDwRvfGrKXcLlRvYuDQ24N2YKquEiKHUxs+iMOzTQj6Sf64KL5O0aSZd1l5rjWgsQ0qqjHW9u3l5bUjqxzrhAI2Js37U=
- secure: Khi6a4z1lfZmDEDV738MOiWznRcTv5ILZUM+igEw2txX7PGX+B5909WridpAijTGiurJ6eda7jvsUgci8DTPQCXB18LD6N870hnPcSQkuI6zDAhKTx+w/ZsfPLWh28sP2CVzbqGdxaitZDKxRWaVmKnBZpyi8XI9UKjmyK2sjwE=
From ff020faf43fa7958aeb72fd3751567d177a63a1e Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Fri, 20 Oct 2017 21:40:09 +0200
Subject: [PATCH 048/345] Removes TRAVIS related logic from 10 tests.
---
src/test/java/com/sendgrid/SendGridTest.java | 100 ++++---------------
1 file changed, 20 insertions(+), 80 deletions(-)
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 5ec45eab..953e43c8 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -4159,14 +4159,8 @@ public void test_user_webhooks_parse_stats_get() throws IOException {
@Test
public void test_whitelabel_domains_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -4179,14 +4173,8 @@ public void test_whitelabel_domains_post() throws IOException {
@Test
public void test_whitelabel_domains_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4203,14 +4191,8 @@ public void test_whitelabel_domains_get() throws IOException {
@Test
public void test_whitelabel_domains_default_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4222,14 +4204,8 @@ public void test_whitelabel_domains_default_get() throws IOException {
@Test
public void test_whitelabel_domains_subuser_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4241,14 +4217,8 @@ public void test_whitelabel_domains_subuser_get() throws IOException {
@Test
public void test_whitelabel_domains_subuser_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4260,14 +4230,8 @@ public void test_whitelabel_domains_subuser_delete() throws IOException {
@Test
public void test_whitelabel_domains__domain_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4280,14 +4244,8 @@ public void test_whitelabel_domains__domain_id__patch() throws IOException {
@Test
public void test_whitelabel_domains__domain_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4299,14 +4257,8 @@ public void test_whitelabel_domains__domain_id__get() throws IOException {
@Test
public void test_whitelabel_domains__domain_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4318,14 +4270,8 @@ public void test_whitelabel_domains__domain_id__delete() throws IOException {
@Test
public void test_whitelabel_domains__domain_id__subuser_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -4338,14 +4284,8 @@ public void test_whitelabel_domains__domain_id__subuser_post() throws IOExceptio
@Test
public void test_whitelabel_domains__id__ips_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
From 377892c9f0f085512b24f25bc3ac2280f37cc0da Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sat, 21 Oct 2017 01:42:49 +0300
Subject: [PATCH 049/345] More SEO Friendly Section links
---
CONTRIBUTING.md | 25 +++++++++++++------------
README.md | 14 +++++++-------
USAGE.md | 24 ++++++++++++------------
USE_CASES.md | 4 ++--
4 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8cb8ea5c..aeaa6486 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,13 +2,13 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou
- [CLAs and CCLAs](#cla)
- [Roadmap & Milestones](#roadmap)
-- [Feature Request](#feature_request)
-- [Submit a Bug Report](#submit_a_bug_report)
-- [Improvements to the Codebase](#improvements_to_the_codebase)
-- [Understanding the Code Base](#understanding_the_codebase)
+- [Feature Request](#feature-request)
+- [Submit a Bug Report](#submit-a-bug-report)
+- [Improvements to the Codebase](#improvements-to-the-codebase)
+- [Understanding the Code Base](#understanding-the-codebase)
- [Testing](#testing)
-- [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions)
-- [Creating a Pull Request](#creating_a_pull_request)
+- [Style Guidelines & Naming Conventions](#style-guidelines-and-naming-conventions)
+- [Creating a Pull Request](#creating-a-pull-request)
We use [Milestones](https://github.com/sendgrid/sendgrid-java/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
@@ -26,7 +26,7 @@ When you create a Pull Request, after a few seconds, a comment will appear with
There are a few ways to contribute, which we'll enumerate below:
-
+
## Feature Request
If you'd like to make a feature request, please read this section.
@@ -36,7 +36,7 @@ The GitHub issue tracker is the preferred channel for library feature requests,
- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
- Please be respectful and considerate of others when commenting on issues
-
+
## Submit a Bug Report
Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
@@ -53,7 +53,7 @@ Before you decide to create a new issue, please try the following:
In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-java/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
-
+
## Improvements to the Codebase
We welcome direct contributions to the sendgrid-java code base. Thank you!
@@ -105,7 +105,7 @@ Add the example you want to test to Example.java, including the headers at the t
javac -classpath ../repo/com/sendgrid/4.1.1/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.1-jar.jar:. Example
```
-
+
## Understanding the Code Base
**/examples**
@@ -149,7 +149,7 @@ For the purposes of contributing to this repo, please update the [`SendGridTest.
./gradlew test -i
```
-
+
## Style Guidelines & Naming Conventions
Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
@@ -158,7 +158,8 @@ Please run your code through:
- [FindBugs](http://findbugs.sourceforge.net/)
- [CheckStyle](http://checkstyle.sourceforge.net/) with [Google's Java Style Guide](http://checkstyle.sourceforge.net/reports/google-java-style.html).
-## Creating a Pull Request
+
+## Creating a Pull Request
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:
diff --git a/README.md b/README.md
index 02725369..45abaabf 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,9 @@ We appreciate your continued support, thank you!
# Table of Contents
* [Installation](#installation)
-* [Quick Start](#quick_start)
+* [Quick Start](#quick-start)
* [Usage](#usage)
-* [Use Cases](#use_cases)
+* [Use Cases](#use-cases)
* [Announcements](#announcements)
* [Roadmap](#roadmap)
* [How to Contribute](#contribute)
@@ -79,7 +79,7 @@ You can just drop the jar file in. It's a fat jar - it has all the dependencies
- [Java-HTTP-Client](https://github.com/sendgrid/java-http-client)
-
+
# Quick Start
## Hello Email
@@ -180,7 +180,7 @@ public class Example {
- [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-java/tree/master/src/main/java/com/sendgrid/helpers) - build a request object payload for a v3 /mail/send API call.
-
+
# Use Cases
[Examples of common API use cases](https://github.com/sendgrid/sendgrid-java/blob/master/USE_CASES.md), such as how to send an email with a transactional template.
@@ -204,10 +204,10 @@ We encourage contribution to our libraries (you might even score some nifty swag
Quick links:
-- [Feature Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#feature_request)
-- [Bug Reports](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#submit_a_bug_report)
+- [Feature Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#feature-request)
+- [Bug Reports](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#submit-a-bug-report)
- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#cla)
-- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#improvements_to_the_codebase)
+- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#improvements-to-the-codebase)
# Troubleshooting
diff --git a/USAGE.md b/USAGE.md
index b29616d7..c014d11d 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -22,9 +22,9 @@ public class Example {
# Table of Contents
-* [ACCESS SETTINGS](#access_settings)
+* [ACCESS SETTINGS](#access-settings)
* [ALERTS](#alerts)
-* [API KEYS](#api_keys)
+* [API KEYS](#api-keys)
* [ASM](#asm)
* [BROWSERS](#browsers)
* [CAMPAIGNS](#campaigns)
@@ -35,21 +35,21 @@ public class Example {
* [GEO](#geo)
* [IPS](#ips)
* [MAIL](#mail)
-* [MAIL SETTINGS](#mail_settings)
-* [MAILBOX PROVIDERS](#mailbox_providers)
-* [PARTNER SETTINGS](#partner_settings)
+* [MAIL SETTINGS](#mail-settings)
+* [MAILBOX PROVIDERS](#mailbox-providers)
+* [PARTNER SETTINGS](#partner-settings)
* [SCOPES](#scopes)
* [SENDERS](#senders)
* [STATS](#stats)
* [SUBUSERS](#subusers)
* [SUPPRESSION](#suppression)
* [TEMPLATES](#templates)
-* [TRACKING SETTINGS](#tracking_settings)
+* [TRACKING SETTINGS](#tracking-settings)
* [USER](#user)
* [WHITELABEL](#whitelabel)
-
+
# ACCESS SETTINGS
## Retrieve all recent access attempts
@@ -353,7 +353,7 @@ For more information about alerts, please see our [User Guide](https://sendgrid.
throw ex;
}
```
-
+
# API KEYS
## Create API keys
@@ -2710,7 +2710,7 @@ This endpoint has a helper, check it out [here](https://github.com/sendgrid/send
throw ex;
}
```
-
+
# MAIL SETTINGS
## Retrieve all mail settings
@@ -3201,7 +3201,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
throw ex;
}
```
-
+
# MAILBOX PROVIDERS
## Retrieve email statistics by mailbox provider.
@@ -3235,7 +3235,7 @@ Advanced Stats provide a more in-depth view of your email statistics and the act
throw ex;
}
```
-
+
# PARTNER SETTINGS
## Returns a list of all partner settings.
@@ -4675,7 +4675,7 @@ For more information about transactional templates, please see our [User Guide](
throw ex;
}
```
-
+
# TRACKING SETTINGS
## Retrieve Tracking Settings
diff --git a/USE_CASES.md b/USE_CASES.md
index 1bfb62f0..9fd05950 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -2,9 +2,9 @@ This documentation provides examples for specific use cases. Please [open an iss
# Table of Contents
-* [Transactional Templates](#transactional_templates)
+* [Transactional Templates](#transactional-templates)
-
+
# Transactional Templates
For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
From 0b9c047278cd4529529bab08eba0667f7991dc32 Mon Sep 17 00:00:00 2001
From: mptap
Date: Fri, 20 Oct 2017 16:16:14 -0700
Subject: [PATCH 050/345] Add/Update Badges on README
---
README.md | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 02725369..57372f2b 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
+
[](https://travis-ci.org/sendgrid/sendgrid-java)
[](https://dx.sendgrid.com/newsletter/java)
+[](https://twitter.com/sendgrid)
+[](https://github.com/sendgrid/sendgrid-java/graphs/contributors)
+[](./LICENSE.txt)
**NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/java) for releases and breaking changes.
@@ -24,6 +28,7 @@ We appreciate your continued support, thank you!
* [How to Contribute](#contribute)
* [Troubleshooting](#troubleshooting)
* [About](#about)
+* [License](#license)
# Installation
@@ -221,4 +226,5 @@ sendgrid-java is guided and supported by the SendGrid [Developer Experience Team
sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
-
+# License
+[The MIT License (MIT)](LICENSE.txt)
From 802f36d9eca501c7eb5e2ad44420c42549afa4ba Mon Sep 17 00:00:00 2001
From: Dmitry Avershin
Date: Sat, 21 Oct 2017 08:10:25 +0200
Subject: [PATCH 051/345] Removes TRAVIS related logic from all tests.
---
src/test/java/com/sendgrid/SendGridTest.java | 2210 ++++--------------
1 file changed, 442 insertions(+), 1768 deletions(-)
diff --git a/src/test/java/com/sendgrid/SendGridTest.java b/src/test/java/com/sendgrid/SendGridTest.java
index 953e43c8..c633554b 100644
--- a/src/test/java/com/sendgrid/SendGridTest.java
+++ b/src/test/java/com/sendgrid/SendGridTest.java
@@ -77,14 +77,8 @@ public void testHost() {
@Test
public void test_access_settings_activity_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -97,14 +91,8 @@ public void test_access_settings_activity_get() throws IOException {
@Test
public void test_access_settings_whitelist_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -117,14 +105,8 @@ public void test_access_settings_whitelist_post() throws IOException {
@Test
public void test_access_settings_whitelist_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -136,14 +118,8 @@ public void test_access_settings_whitelist_get() throws IOException {
@Test
public void test_access_settings_whitelist_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -156,14 +132,8 @@ public void test_access_settings_whitelist_delete() throws IOException {
@Test
public void test_access_settings_whitelist__rule_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -175,14 +145,8 @@ public void test_access_settings_whitelist__rule_id__get() throws IOException {
@Test
public void test_access_settings_whitelist__rule_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -194,14 +158,8 @@ public void test_access_settings_whitelist__rule_id__delete() throws IOException
@Test
public void test_alerts_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -214,14 +172,8 @@ public void test_alerts_post() throws IOException {
@Test
public void test_alerts_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -233,14 +185,8 @@ public void test_alerts_get() throws IOException {
@Test
public void test_alerts__alert_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -253,14 +199,8 @@ public void test_alerts__alert_id__patch() throws IOException {
@Test
public void test_alerts__alert_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -272,14 +212,8 @@ public void test_alerts__alert_id__get() throws IOException {
@Test
public void test_alerts__alert_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -291,14 +225,8 @@ public void test_alerts__alert_id__delete() throws IOException {
@Test
public void test_api_keys_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -311,14 +239,8 @@ public void test_api_keys_post() throws IOException {
@Test
public void test_api_keys_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -331,14 +253,8 @@ public void test_api_keys_get() throws IOException {
@Test
public void test_api_keys__api_key_id__put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -351,14 +267,8 @@ public void test_api_keys__api_key_id__put() throws IOException {
@Test
public void test_api_keys__api_key_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -371,14 +281,8 @@ public void test_api_keys__api_key_id__patch() throws IOException {
@Test
public void test_api_keys__api_key_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -390,14 +294,8 @@ public void test_api_keys__api_key_id__get() throws IOException {
@Test
public void test_api_keys__api_key_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -409,14 +307,8 @@ public void test_api_keys__api_key_id__delete() throws IOException {
@Test
public void test_asm_groups_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -429,14 +321,8 @@ public void test_asm_groups_post() throws IOException {
@Test
public void test_asm_groups_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -449,14 +335,8 @@ public void test_asm_groups_get() throws IOException {
@Test
public void test_asm_groups__group_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -469,14 +349,8 @@ public void test_asm_groups__group_id__patch() throws IOException {
@Test
public void test_asm_groups__group_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -488,14 +362,8 @@ public void test_asm_groups__group_id__get() throws IOException {
@Test
public void test_asm_groups__group_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -507,14 +375,8 @@ public void test_asm_groups__group_id__delete() throws IOException {
@Test
public void test_asm_groups__group_id__suppressions_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -527,14 +389,8 @@ public void test_asm_groups__group_id__suppressions_post() throws IOException {
@Test
public void test_asm_groups__group_id__suppressions_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -546,14 +402,8 @@ public void test_asm_groups__group_id__suppressions_get() throws IOException {
@Test
public void test_asm_groups__group_id__suppressions_search_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -566,14 +416,8 @@ public void test_asm_groups__group_id__suppressions_search_post() throws IOExcep
@Test
public void test_asm_groups__group_id__suppressions__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -585,14 +429,8 @@ public void test_asm_groups__group_id__suppressions__email__delete() throws IOEx
@Test
public void test_asm_suppressions_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -604,14 +442,8 @@ public void test_asm_suppressions_get() throws IOException {
@Test
public void test_asm_suppressions_global_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -624,14 +456,8 @@ public void test_asm_suppressions_global_post() throws IOException {
@Test
public void test_asm_suppressions_global__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -643,14 +469,8 @@ public void test_asm_suppressions_global__email__get() throws IOException {
@Test
public void test_asm_suppressions_global__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -662,14 +482,8 @@ public void test_asm_suppressions_global__email__delete() throws IOException {
@Test
public void test_asm_suppressions__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -681,14 +495,8 @@ public void test_asm_suppressions__email__get() throws IOException {
@Test
public void test_browsers_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -706,14 +514,8 @@ public void test_browsers_stats_get() throws IOException {
@Test
public void test_campaigns_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -726,14 +528,8 @@ public void test_campaigns_post() throws IOException {
@Test
public void test_campaigns_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -747,14 +543,8 @@ public void test_campaigns_get() throws IOException {
@Test
public void test_campaigns__campaign_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -767,14 +557,8 @@ public void test_campaigns__campaign_id__patch() throws IOException {
@Test
public void test_campaigns__campaign_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -786,14 +570,8 @@ public void test_campaigns__campaign_id__get() throws IOException {
@Test
public void test_campaigns__campaign_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -805,14 +583,8 @@ public void test_campaigns__campaign_id__delete() throws IOException {
@Test
public void test_campaigns__campaign_id__schedules_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -825,14 +597,8 @@ public void test_campaigns__campaign_id__schedules_patch() throws IOException {
@Test
public void test_campaigns__campaign_id__schedules_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -845,14 +611,8 @@ public void test_campaigns__campaign_id__schedules_post() throws IOException {
@Test
public void test_campaigns__campaign_id__schedules_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -864,14 +624,8 @@ public void test_campaigns__campaign_id__schedules_get() throws IOException {
@Test
public void test_campaigns__campaign_id__schedules_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -883,14 +637,8 @@ public void test_campaigns__campaign_id__schedules_delete() throws IOException {
@Test
public void test_campaigns__campaign_id__schedules_now_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -902,14 +650,8 @@ public void test_campaigns__campaign_id__schedules_now_post() throws IOException
@Test
public void test_campaigns__campaign_id__schedules_test_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -922,14 +664,8 @@ public void test_campaigns__campaign_id__schedules_test_post() throws IOExceptio
@Test
public void test_categories_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -944,14 +680,8 @@ public void test_categories_get() throws IOException {
@Test
public void test_categories_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -969,14 +699,8 @@ public void test_categories_stats_get() throws IOException {
@Test
public void test_categories_stats_sums_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -995,14 +719,8 @@ public void test_categories_stats_sums_get() throws IOException {
@Test
public void test_clients_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1017,14 +735,8 @@ public void test_clients_stats_get() throws IOException {
@Test
public void test_clients__client_type__stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1039,14 +751,8 @@ public void test_clients__client_type__stats_get() throws IOException {
@Test
public void test_contactdb_custom_fields_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1059,14 +765,8 @@ public void test_contactdb_custom_fields_post() throws IOException {
@Test
public void test_contactdb_custom_fields_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1078,14 +778,8 @@ public void test_contactdb_custom_fields_get() throws IOException {
@Test
public void test_contactdb_custom_fields__custom_field_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1097,14 +791,8 @@ public void test_contactdb_custom_fields__custom_field_id__get() throws IOExcept
@Test
public void test_contactdb_custom_fields__custom_field_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "202");
Request request = new Request();
@@ -1116,14 +804,8 @@ public void test_contactdb_custom_fields__custom_field_id__delete() throws IOExc
@Test
public void test_contactdb_lists_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1136,14 +818,8 @@ public void test_contactdb_lists_post() throws IOException {
@Test
public void test_contactdb_lists_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1155,14 +831,8 @@ public void test_contactdb_lists_get() throws IOException {
@Test
public void test_contactdb_lists_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1175,14 +845,8 @@ public void test_contactdb_lists_delete() throws IOException {
@Test
public void test_contactdb_lists__list_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1196,14 +860,8 @@ public void test_contactdb_lists__list_id__patch() throws IOException {
@Test
public void test_contactdb_lists__list_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1216,14 +874,8 @@ public void test_contactdb_lists__list_id__get() throws IOException {
@Test
public void test_contactdb_lists__list_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "202");
Request request = new Request();
@@ -1236,14 +888,8 @@ public void test_contactdb_lists__list_id__delete() throws IOException {
@Test
public void test_contactdb_lists__list_id__recipients_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1256,14 +902,8 @@ public void test_contactdb_lists__list_id__recipients_post() throws IOException
@Test
public void test_contactdb_lists__list_id__recipients_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1278,14 +918,8 @@ public void test_contactdb_lists__list_id__recipients_get() throws IOException {
@Test
public void test_contactdb_lists__list_id__recipients__recipient_id__post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1297,14 +931,8 @@ public void test_contactdb_lists__list_id__recipients__recipient_id__post() thro
@Test
public void test_contactdb_lists__list_id__recipients__recipient_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1318,14 +946,8 @@ public void test_contactdb_lists__list_id__recipients__recipient_id__delete() th
@Test
public void test_contactdb_recipients_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1338,14 +960,8 @@ public void test_contactdb_recipients_patch() throws IOException {
@Test
public void test_contactdb_recipients_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1358,14 +974,8 @@ public void test_contactdb_recipients_post() throws IOException {
@Test
public void test_contactdb_recipients_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1379,14 +989,8 @@ public void test_contactdb_recipients_get() throws IOException {
@Test
public void test_contactdb_recipients_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1399,14 +1003,8 @@ public void test_contactdb_recipients_delete() throws IOException {
@Test
public void test_contactdb_recipients_billable_count_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1418,14 +1016,8 @@ public void test_contactdb_recipients_billable_count_get() throws IOException {
@Test
public void test_contactdb_recipients_count_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1437,14 +1029,8 @@ public void test_contactdb_recipients_count_get() throws IOException {
@Test
public void test_contactdb_recipients_search_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1457,14 +1043,8 @@ public void test_contactdb_recipients_search_get() throws IOException {
@Test
public void test_contactdb_recipients__recipient_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1476,14 +1056,8 @@ public void test_contactdb_recipients__recipient_id__get() throws IOException {
@Test
public void test_contactdb_recipients__recipient_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1495,14 +1069,8 @@ public void test_contactdb_recipients__recipient_id__delete() throws IOException
@Test
public void test_contactdb_recipients__recipient_id__lists_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1514,14 +1082,8 @@ public void test_contactdb_recipients__recipient_id__lists_get() throws IOExcept
@Test
public void test_contactdb_reserved_fields_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1533,14 +1095,8 @@ public void test_contactdb_reserved_fields_get() throws IOException {
@Test
public void test_contactdb_segments_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1553,14 +1109,8 @@ public void test_contactdb_segments_post() throws IOException {
@Test
public void test_contactdb_segments_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1572,14 +1122,8 @@ public void test_contactdb_segments_get() throws IOException {
@Test
public void test_contactdb_segments__segment_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1593,14 +1137,8 @@ public void test_contactdb_segments__segment_id__patch() throws IOException {
@Test
public void test_contactdb_segments__segment_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1613,14 +1151,8 @@ public void test_contactdb_segments__segment_id__get() throws IOException {
@Test
public void test_contactdb_segments__segment_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1633,14 +1165,8 @@ public void test_contactdb_segments__segment_id__delete() throws IOException {
@Test
public void test_contactdb_segments__segment_id__recipients_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1654,14 +1180,8 @@ public void test_contactdb_segments__segment_id__recipients_get() throws IOExcep
@Test
public void test_devices_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1678,14 +1198,8 @@ public void test_devices_stats_get() throws IOException {
@Test
public void test_geo_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1703,14 +1217,8 @@ public void test_geo_stats_get() throws IOException {
@Test
public void test_ips_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1727,14 +1235,8 @@ public void test_ips_get() throws IOException {
@Test
public void test_ips_assigned_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1746,14 +1248,8 @@ public void test_ips_assigned_get() throws IOException {
@Test
public void test_ips_pools_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1766,14 +1262,8 @@ public void test_ips_pools_post() throws IOException {
@Test
public void test_ips_pools_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1785,14 +1275,8 @@ public void test_ips_pools_get() throws IOException {
@Test
public void test_ips_pools__pool_name__put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1805,14 +1289,8 @@ public void test_ips_pools__pool_name__put() throws IOException {
@Test
public void test_ips_pools__pool_name__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1824,14 +1302,8 @@ public void test_ips_pools__pool_name__get() throws IOException {
@Test
public void test_ips_pools__pool_name__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1843,14 +1315,8 @@ public void test_ips_pools__pool_name__delete() throws IOException {
@Test
public void test_ips_pools__pool_name__ips_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1863,14 +1329,8 @@ public void test_ips_pools__pool_name__ips_post() throws IOException {
@Test
public void test_ips_pools__pool_name__ips__ip__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1882,14 +1342,8 @@ public void test_ips_pools__pool_name__ips__ip__delete() throws IOException {
@Test
public void test_ips_warmup_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1902,14 +1356,8 @@ public void test_ips_warmup_post() throws IOException {
@Test
public void test_ips_warmup_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1921,14 +1369,8 @@ public void test_ips_warmup_get() throws IOException {
@Test
public void test_ips_warmup__ip_address__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1940,14 +1382,8 @@ public void test_ips_warmup__ip_address__get() throws IOException {
@Test
public void test_ips_warmup__ip_address__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -1959,14 +1395,8 @@ public void test_ips_warmup__ip_address__delete() throws IOException {
@Test
public void test_ips__ip_address__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -1978,14 +1408,8 @@ public void test_ips__ip_address__get() throws IOException {
@Test
public void test_mail_batch_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -1997,14 +1421,8 @@ public void test_mail_batch_post() throws IOException {
@Test
public void test_mail_batch__batch_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2016,14 +1434,8 @@ public void test_mail_batch__batch_id__get() throws IOException {
@Test
public void test_mail_send_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "202");
Request request = new Request();
@@ -2036,14 +1448,8 @@ public void test_mail_send_post() throws IOException {
@Test
public void test_mail_settings_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2057,14 +1463,8 @@ public void test_mail_settings_get() throws IOException {
@Test
public void test_mail_settings_address_whitelist_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2077,14 +1477,8 @@ public void test_mail_settings_address_whitelist_patch() throws IOException {
@Test
public void test_mail_settings_address_whitelist_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2096,14 +1490,8 @@ public void test_mail_settings_address_whitelist_get() throws IOException {
@Test
public void test_mail_settings_bcc_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2116,14 +1504,8 @@ public void test_mail_settings_bcc_patch() throws IOException {
@Test
public void test_mail_settings_bcc_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2135,14 +1517,8 @@ public void test_mail_settings_bcc_get() throws IOException {
@Test
public void test_mail_settings_bounce_purge_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2155,14 +1531,8 @@ public void test_mail_settings_bounce_purge_patch() throws IOException {
@Test
public void test_mail_settings_bounce_purge_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2174,14 +1544,8 @@ public void test_mail_settings_bounce_purge_get() throws IOException {
@Test
public void test_mail_settings_footer_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2194,14 +1558,8 @@ public void test_mail_settings_footer_patch() throws IOException {
@Test
public void test_mail_settings_footer_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2213,14 +1571,8 @@ public void test_mail_settings_footer_get() throws IOException {
@Test
public void test_mail_settings_forward_bounce_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2233,14 +1585,8 @@ public void test_mail_settings_forward_bounce_patch() throws IOException {
@Test
public void test_mail_settings_forward_bounce_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2252,14 +1598,8 @@ public void test_mail_settings_forward_bounce_get() throws IOException {
@Test
public void test_mail_settings_forward_spam_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2272,14 +1612,8 @@ public void test_mail_settings_forward_spam_patch() throws IOException {
@Test
public void test_mail_settings_forward_spam_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2291,14 +1625,8 @@ public void test_mail_settings_forward_spam_get() throws IOException {
@Test
public void test_mail_settings_plain_content_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2311,14 +1639,8 @@ public void test_mail_settings_plain_content_patch() throws IOException {
@Test
public void test_mail_settings_plain_content_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2330,14 +1652,8 @@ public void test_mail_settings_plain_content_get() throws IOException {
@Test
public void test_mail_settings_spam_check_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2350,14 +1666,8 @@ public void test_mail_settings_spam_check_patch() throws IOException {
@Test
public void test_mail_settings_spam_check_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2369,14 +1679,8 @@ public void test_mail_settings_spam_check_get() throws IOException {
@Test
public void test_mail_settings_template_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2389,14 +1693,8 @@ public void test_mail_settings_template_patch() throws IOException {
@Test
public void test_mail_settings_template_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2408,14 +1706,8 @@ public void test_mail_settings_template_get() throws IOException {
@Test
public void test_mailbox_providers_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2433,14 +1725,8 @@ public void test_mailbox_providers_stats_get() throws IOException {
@Test
public void test_partner_settings_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2454,14 +1740,8 @@ public void test_partner_settings_get() throws IOException {
@Test
public void test_partner_settings_new_relic_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2474,14 +1754,8 @@ public void test_partner_settings_new_relic_patch() throws IOException {
@Test
public void test_partner_settings_new_relic_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2493,14 +1767,8 @@ public void test_partner_settings_new_relic_get() throws IOException {
@Test
public void test_scopes_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2512,14 +1780,8 @@ public void test_scopes_get() throws IOException {
@Test
public void test_senders_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -2532,14 +1794,8 @@ public void test_senders_post() throws IOException {
@Test
public void test_senders_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2551,14 +1807,8 @@ public void test_senders_get() throws IOException {
@Test
public void test_senders__sender_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2571,14 +1821,8 @@ public void test_senders__sender_id__patch() throws IOException {
@Test
public void test_senders__sender_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2590,14 +1834,8 @@ public void test_senders__sender_id__get() throws IOException {
@Test
public void test_senders__sender_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2609,14 +1847,8 @@ public void test_senders__sender_id__delete() throws IOException {
@Test
public void test_senders__sender_id__resend_verification_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2628,14 +1860,8 @@ public void test_senders__sender_id__resend_verification_post() throws IOExcepti
@Test
public void test_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2652,14 +1878,8 @@ public void test_stats_get() throws IOException {
@Test
public void test_subusers_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2672,14 +1892,8 @@ public void test_subusers_post() throws IOException {
@Test
public void test_subusers_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2694,14 +1908,8 @@ public void test_subusers_get() throws IOException {
@Test
public void test_subusers_reputations_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2714,14 +1922,8 @@ public void test_subusers_reputations_get() throws IOException {
@Test
public void test_subusers_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2739,14 +1941,8 @@ public void test_subusers_stats_get() throws IOException {
@Test
public void test_subusers_stats_monthly_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2764,14 +1960,8 @@ public void test_subusers_stats_monthly_get() throws IOException {
@Test
public void test_subusers_stats_sums_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2790,14 +1980,8 @@ public void test_subusers_stats_sums_get() throws IOException {
@Test
public void test_subusers__subuser_name__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2810,14 +1994,8 @@ public void test_subusers__subuser_name__patch() throws IOException {
@Test
public void test_subusers__subuser_name__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2829,14 +2007,8 @@ public void test_subusers__subuser_name__delete() throws IOException {
@Test
public void test_subusers__subuser_name__ips_put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2849,14 +2021,8 @@ public void test_subusers__subuser_name__ips_put() throws IOException {
@Test
public void test_subusers__subuser_name__monitor_put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2869,14 +2035,8 @@ public void test_subusers__subuser_name__monitor_put() throws IOException {
@Test
public void test_subusers__subuser_name__monitor_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2889,14 +2049,8 @@ public void test_subusers__subuser_name__monitor_post() throws IOException {
@Test
public void test_subusers__subuser_name__monitor_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2908,14 +2062,8 @@ public void test_subusers__subuser_name__monitor_get() throws IOException {
@Test
public void test_subusers__subuser_name__monitor_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2927,14 +2075,8 @@ public void test_subusers__subuser_name__monitor_delete() throws IOException {
@Test
public void test_subusers__subuser_name__stats_monthly_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2951,14 +2093,8 @@ public void test_subusers__subuser_name__stats_monthly_get() throws IOException
@Test
public void test_suppression_blocks_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -2974,14 +2110,8 @@ public void test_suppression_blocks_get() throws IOException {
@Test
public void test_suppression_blocks_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -2994,14 +2124,8 @@ public void test_suppression_blocks_delete() throws IOException {
@Test
public void test_suppression_blocks__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3013,14 +2137,8 @@ public void test_suppression_blocks__email__get() throws IOException {
@Test
public void test_suppression_blocks__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3032,14 +2150,8 @@ public void test_suppression_blocks__email__delete() throws IOException {
@Test
public void test_suppression_bounces_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3053,14 +2165,8 @@ public void test_suppression_bounces_get() throws IOException {
@Test
public void test_suppression_bounces_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3073,14 +2179,8 @@ public void test_suppression_bounces_delete() throws IOException {
@Test
public void test_suppression_bounces__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3092,14 +2192,8 @@ public void test_suppression_bounces__email__get() throws IOException {
@Test
public void test_suppression_bounces__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3112,14 +2206,8 @@ public void test_suppression_bounces__email__delete() throws IOException {
@Test
public void test_suppression_invalid_emails_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3135,14 +2223,8 @@ public void test_suppression_invalid_emails_get() throws IOException {
@Test
public void test_suppression_invalid_emails_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3155,14 +2237,8 @@ public void test_suppression_invalid_emails_delete() throws IOException {
@Test
public void test_suppression_invalid_emails__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3174,14 +2250,8 @@ public void test_suppression_invalid_emails__email__get() throws IOException {
@Test
public void test_suppression_invalid_emails__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3193,14 +2263,8 @@ public void test_suppression_invalid_emails__email__delete() throws IOException
@Test
public void test_suppression_spam_report__email__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3212,14 +2276,8 @@ public void test_suppression_spam_report__email__get() throws IOException {
@Test
public void test_suppression_spam_report__email__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3231,14 +2289,8 @@ public void test_suppression_spam_report__email__delete() throws IOException {
@Test
public void test_suppression_spam_reports_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3254,14 +2306,8 @@ public void test_suppression_spam_reports_get() throws IOException {
@Test
public void test_suppression_spam_reports_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3274,14 +2320,8 @@ public void test_suppression_spam_reports_delete() throws IOException {
@Test
public void test_suppression_unsubscribes_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3297,14 +2337,8 @@ public void test_suppression_unsubscribes_get() throws IOException {
@Test
public void test_templates_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -3317,14 +2351,8 @@ public void test_templates_post() throws IOException {
@Test
public void test_templates_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3336,14 +2364,8 @@ public void test_templates_get() throws IOException {
@Test
public void test_templates__template_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3356,14 +2378,8 @@ public void test_templates__template_id__patch() throws IOException {
@Test
public void test_templates__template_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3375,14 +2391,8 @@ public void test_templates__template_id__get() throws IOException {
@Test
public void test_templates__template_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3394,14 +2404,8 @@ public void test_templates__template_id__delete() throws IOException {
@Test
public void test_templates__template_id__versions_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -3414,14 +2418,8 @@ public void test_templates__template_id__versions_post() throws IOException {
@Test
public void test_templates__template_id__versions__version_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3434,14 +2432,8 @@ public void test_templates__template_id__versions__version_id__patch() throws IO
@Test
public void test_templates__template_id__versions__version_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3453,14 +2445,8 @@ public void test_templates__template_id__versions__version_id__get() throws IOEx
@Test
public void test_templates__template_id__versions__version_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3472,14 +2458,8 @@ public void test_templates__template_id__versions__version_id__delete() throws I
@Test
public void test_templates__template_id__versions__version_id__activate_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3491,14 +2471,8 @@ public void test_templates__template_id__versions__version_id__activate_post() t
@Test
public void test_tracking_settings_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3512,14 +2486,8 @@ public void test_tracking_settings_get() throws IOException {
@Test
public void test_tracking_settings_click_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3532,14 +2500,8 @@ public void test_tracking_settings_click_patch() throws IOException {
@Test
public void test_tracking_settings_click_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3551,14 +2513,8 @@ public void test_tracking_settings_click_get() throws IOException {
@Test
public void test_tracking_settings_google_analytics_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3571,14 +2527,8 @@ public void test_tracking_settings_google_analytics_patch() throws IOException {
@Test
public void test_tracking_settings_google_analytics_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3590,14 +2540,8 @@ public void test_tracking_settings_google_analytics_get() throws IOException {
@Test
public void test_tracking_settings_open_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3610,14 +2554,8 @@ public void test_tracking_settings_open_patch() throws IOException {
@Test
public void test_tracking_settings_open_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3629,14 +2567,8 @@ public void test_tracking_settings_open_get() throws IOException {
@Test
public void test_tracking_settings_subscription_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3649,14 +2581,8 @@ public void test_tracking_settings_subscription_patch() throws IOException {
@Test
public void test_tracking_settings_subscription_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3668,14 +2594,8 @@ public void test_tracking_settings_subscription_get() throws IOException {
@Test
public void test_user_account_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3687,14 +2607,8 @@ public void test_user_account_get() throws IOException {
@Test
public void test_user_credits_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3706,14 +2620,8 @@ public void test_user_credits_get() throws IOException {
@Test
public void test_user_email_put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3726,14 +2634,8 @@ public void test_user_email_put() throws IOException {
@Test
public void test_user_email_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3745,14 +2647,8 @@ public void test_user_email_get() throws IOException {
@Test
public void test_user_password_put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3765,14 +2661,8 @@ public void test_user_password_put() throws IOException {
@Test
public void test_user_profile_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3785,14 +2675,8 @@ public void test_user_profile_patch() throws IOException {
@Test
public void test_user_profile_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3804,14 +2688,8 @@ public void test_user_profile_get() throws IOException {
@Test
public void test_user_scheduled_sends_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -3824,14 +2702,8 @@ public void test_user_scheduled_sends_post() throws IOException {
@Test
public void test_user_scheduled_sends_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3843,14 +2715,8 @@ public void test_user_scheduled_sends_get() throws IOException {
@Test
public void test_user_scheduled_sends__batch_id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3863,14 +2729,8 @@ public void test_user_scheduled_sends__batch_id__patch() throws IOException {
@Test
public void test_user_scheduled_sends__batch_id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3882,14 +2742,8 @@ public void test_user_scheduled_sends__batch_id__get() throws IOException {
@Test
public void test_user_scheduled_sends__batch_id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -3901,14 +2755,8 @@ public void test_user_scheduled_sends__batch_id__delete() throws IOException {
@Test
public void test_user_settings_enforced_tls_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3921,14 +2769,8 @@ public void test_user_settings_enforced_tls_patch() throws IOException {
@Test
public void test_user_settings_enforced_tls_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3940,14 +2782,8 @@ public void test_user_settings_enforced_tls_get() throws IOException {
@Test
public void test_user_username_put() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3960,14 +2796,8 @@ public void test_user_username_put() throws IOException {
@Test
public void test_user_username_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3979,14 +2809,8 @@ public void test_user_username_get() throws IOException {
@Test
public void test_user_webhooks_event_settings_patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -3999,14 +2823,8 @@ public void test_user_webhooks_event_settings_patch() throws IOException {
@Test
public void test_user_webhooks_event_settings_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4018,14 +2836,8 @@ public void test_user_webhooks_event_settings_get() throws IOException {
@Test
public void test_user_webhooks_event_test_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4038,14 +2850,8 @@ public void test_user_webhooks_event_test_post() throws IOException {
@Test
public void test_user_webhooks_parse_settings_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -4058,14 +2864,8 @@ public void test_user_webhooks_parse_settings_post() throws IOException {
@Test
public void test_user_webhooks_parse_settings_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4077,14 +2877,8 @@ public void test_user_webhooks_parse_settings_get() throws IOException {
@Test
public void test_user_webhooks_parse_settings__hostname__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4097,14 +2891,8 @@ public void test_user_webhooks_parse_settings__hostname__patch() throws IOExcept
@Test
public void test_user_webhooks_parse_settings__hostname__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4116,14 +2904,8 @@ public void test_user_webhooks_parse_settings__hostname__get() throws IOExceptio
@Test
public void test_user_webhooks_parse_settings__hostname__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4135,14 +2917,8 @@ public void test_user_webhooks_parse_settings__hostname__delete() throws IOExcep
@Test
public void test_user_webhooks_parse_stats_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4298,14 +3074,8 @@ public void test_whitelabel_domains__id__ips_post() throws IOException {
@Test
public void test_whitelabel_domains__id__ips__ip__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4317,14 +3087,8 @@ public void test_whitelabel_domains__id__ips__ip__delete() throws IOException {
@Test
public void test_whitelabel_domains__id__validate_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4336,14 +3100,8 @@ public void test_whitelabel_domains__id__validate_post() throws IOException {
@Test
public void test_whitelabel_ips_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -4356,14 +3114,8 @@ public void test_whitelabel_ips_post() throws IOException {
@Test
public void test_whitelabel_ips_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4378,14 +3130,8 @@ public void test_whitelabel_ips_get() throws IOException {
@Test
public void test_whitelabel_ips__id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4397,14 +3143,8 @@ public void test_whitelabel_ips__id__get() throws IOException {
@Test
public void test_whitelabel_ips__id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4416,14 +3156,8 @@ public void test_whitelabel_ips__id__delete() throws IOException {
@Test
public void test_whitelabel_ips__id__validate_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4435,14 +3169,8 @@ public void test_whitelabel_ips__id__validate_post() throws IOException {
@Test
public void test_whitelabel_links_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "201");
Request request = new Request();
@@ -4457,14 +3185,8 @@ public void test_whitelabel_links_post() throws IOException {
@Test
public void test_whitelabel_links_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4477,14 +3199,8 @@ public void test_whitelabel_links_get() throws IOException {
@Test
public void test_whitelabel_links_default_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4497,14 +3213,8 @@ public void test_whitelabel_links_default_get() throws IOException {
@Test
public void test_whitelabel_links_subuser_get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4517,14 +3227,8 @@ public void test_whitelabel_links_subuser_get() throws IOException {
@Test
public void test_whitelabel_links_subuser_delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4537,14 +3241,8 @@ public void test_whitelabel_links_subuser_delete() throws IOException {
@Test
public void test_whitelabel_links__id__patch() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4557,14 +3255,8 @@ public void test_whitelabel_links__id__patch() throws IOException {
@Test
public void test_whitelabel_links__id__get() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4576,14 +3268,8 @@ public void test_whitelabel_links__id__get() throws IOException {
@Test
public void test_whitelabel_links__id__delete() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "204");
Request request = new Request();
@@ -4595,14 +3281,8 @@ public void test_whitelabel_links__id__delete() throws IOException {
@Test
public void test_whitelabel_links__id__validate_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
@@ -4614,14 +3294,8 @@ public void test_whitelabel_links__id__validate_post() throws IOException {
@Test
public void test_whitelabel_links__link_id__subuser_post() throws IOException {
- SendGrid sg = null;
- if(System.getenv("TRAVIS") != null && Boolean.parseBoolean(System.getenv("TRAVIS"))) {
- sg = new SendGrid("SENDGRID_API_KEY");
- sg.setHost(System.getenv("MOCK_HOST"));
- } else {
- sg = new SendGrid("SENDGRID_API_KEY", true);
- sg.setHost("localhost:4010");
- }
+ SendGrid sg = new SendGrid("SENDGRID_API_KEY", true);
+ sg.setHost("localhost:4010");
sg.addRequestHeader("X-Mock", "200");
Request request = new Request();
From 1df94b5758d0ee88011a492c748b0b375c870f58 Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sat, 21 Oct 2017 14:18:10 +0300
Subject: [PATCH 052/345] Update readme - added maven central badge
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 02725369..505fa717 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
[](https://travis-ci.org/sendgrid/sendgrid-java)
+[](http://mvnrepository.com/artifact/com.sendgrid/sendgrid-java)
[](https://dx.sendgrid.com/newsletter/java)
**NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/java) for releases and breaking changes.
From e224ab20f740df09d97dad439d60443ef04307b1 Mon Sep 17 00:00:00 2001
From: Brandon Smith
Date: Sat, 21 Oct 2017 20:37:48 -0400
Subject: [PATCH 053/345] Spelling corrections in .md files
---
CHANGELOG.md | 8 ++++----
TROUBLESHOOTING.md | 2 +-
USAGE.md | 28 ++++++++++++++--------------
proposals/mail-helper-refactor.md | 2 +-
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a85d7e2..818020a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,12 +20,12 @@ All notable changes to this project will be documented in this file.
### BREAKING CHANGE
- PR #162 Update java http client dependency to [4.1.0 from 2.3.4](https://github.com/sendgrid/java-http-client/releases)
- BIG thanks to [Diego Camargo](https://github.com/belfazt) for the pull request!
-- The breaking change is that variables that were public are now private and accessable only via getters and setters
-- The `Request` object attributes are now only accessable through getters/setters
+- The breaking change is that variables that were public are now private and accessible only via getters and setters
+- The `Request` object attributes are now only accessible through getters/setters
- `request.method` is now `request.setMethod(string)`
- `request.endpoint` is now `request.setEndpoint(string)`
- `request.body` is now `request.setBody(string)`
-- The `Response` object attributes are now only accessable through getters/setters
+- The `Response` object attributes are now only accessible through getters/setters
- `response.statusCode` is now `response.getStatusCode()`
- `response.body` is now `response.getBody()`
- `response.headers` is now `response.getHeaders()`
@@ -118,7 +118,7 @@ request.addQueryParam("limit", "1");
## [2.2.2] - 2015-5-23
### Fixed
-- Subsitution orders being swapped via [#65](https://github.com/sendgrid/sendgrid-java/pull/65)
+- Substitution orders being swapped via [#65](https://github.com/sendgrid/sendgrid-java/pull/65)
## [2.2.1] - 2015-5-14
### Changed
diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md
index fc282d40..e510304b 100644
--- a/TROUBLESHOOTING.md
+++ b/TROUBLESHOOTING.md
@@ -102,7 +102,7 @@ We have an issue to remove that dependency [here](https://github.com/sendgrid/ja
## Viewing the Request Body
-When debugging or testing, it may be useful to exampine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).
+When debugging or testing, it may be useful to examine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).
You can do this right before you call `request.setBody(mail.build())` like so:
diff --git a/USAGE.md b/USAGE.md
index b29616d7..1374bc51 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -161,7 +161,7 @@ For more information, please see our [User Guide](http://sendgrid.com/docs/User_
```
## Retrieve a specific whitelisted IP
-**This endpoint allows you to retreive a specific IP address that has been whitelisted.**
+**This endpoint allows you to retrieve a specific IP address that has been whitelisted.**
You must include the ID for the specific IP address you want to retrieve in your call.
@@ -497,7 +497,7 @@ If the API Key ID does not exist an HTTP 404 will be returned.
**This endpoint allows you to revoke an existing API Key.**
-Authentications using this API Key will fail after this request is made, with some small propogation delay.If the API Key ID does not exist an HTTP 404 will be returned.
+Authentications using this API Key will fail after this request is made, with some small propagation delay.If the API Key ID does not exist an HTTP 404 will be returned.
The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
@@ -563,7 +563,7 @@ This endpoint will return information for each group ID that you include in your
Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html).
-Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html), allow you to label a category of content that you regularly send. This gives your recipients the ability to opt out of a specific set of your email. For example, you might define a group for your transactional email, and one for your marketing email so that your users can continue recieving your transactional email witout having to receive your marketing content.
+Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html), allow you to label a category of content that you regularly send. This gives your recipients the ability to opt out of a specific set of your email. For example, you might define a group for your transactional email, and one for your marketing email so that your users can continue receiving your transactional email without having to receive your marketing content.
### GET /asm/groups
@@ -814,9 +814,9 @@ A global suppression (or global unsubscribe) is an email address of a recipient
```
## Retrieve a Global Suppression
-**This endpoint allows you to retrieve a global suppression. You can also use this endpoint to confirm if an email address is already globally suppresed.**
+**This endpoint allows you to retrieve a global suppression. You can also use this endpoint to confirm if an email address is already globally suppressed.**
-If the email address you include in the URL path parameter `{email}` is alreayd globally suppressed, the response will include that email address. If the address you enter for `{email}` is not globally suppressed, an empty JSON object `{}` will be returned.
+If the email address you include in the URL path parameter `{email}` is already globally suppressed, the response will include that email address. If the address you enter for `{email}` is not globally suppressed, an empty JSON object `{}` will be returned.
A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html).
@@ -2018,7 +2018,7 @@ Valid operators for create and update depend on the type of the field you are se
Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign.
-Segments may contain multiple condtions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or".
+Segments may contain multiple conditions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or".
The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
@@ -2701,7 +2701,7 @@ This endpoint has a helper, check it out [here](https://github.com/sendgrid/send
Request request = new Request();
request.setMethod(Method.POST);
request.setEndpoint("mail/send");
- request.setBody("{\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\")[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"from\":{\"email\":\"sam.smith@example.com\",\"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\":\"john.doe@example.com\",\"name\":\"John Doe\"}],\"cc\":[{\"email\":\"jane.doe@example.com\",\"name\":\"Jane Doe\"}],\"bcc\":[{\"email\":\"sam.doe@example.com\",\"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\":\"Hello, world!
\"}],\"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\":\"ThanksThe SendGrid Team
\"},\"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\":\"ben.doe@example.com\"}},\"reply_to\":{\"email\":\"sam.smith@example.com\",\"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.setBody("{\"custom_args\":{\"New Argument 1\":\"New Value 1\",\"activationAttempt\":\"1\",\"customerAccountNumber\":\")[CUSTOMER ACCOUNT NUMBER GOES HERE]\"},\"from\":{\"email\":\"sam.smith@example.com\",\"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\":\"john.doe@example.com\",\"name\":\"John Doe\"}],\"cc\":[{\"email\":\"jane.doe@example.com\",\"name\":\"Jane Doe\"}],\"bcc\":[{\"email\":\"sam.doe@example.com\",\"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\":\"Hello, world!
\"}],\"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 receiving 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\":\"ThanksThe SendGrid Team
\"},\"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\":\"ben.doe@example.com\"}},\"reply_to\":{\"email\":\"sam.smith@example.com\",\"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.getStatusCode());
System.out.println(response.getBody());
@@ -4961,7 +4961,7 @@ For more information about your user profile:
**This endpoint allows you to retrieve the current credit balance for your account.**
-Your monthly credit allotment limits the number of emails you may send before incurring overage charges. For more information about credits and billing, please visit our [Clssroom](https://sendgrid.com/docs/Classroom/Basics/Billing/billing_info_and_faqs.html).
+Your monthly credit allotment limits the number of emails you may send before incurring overage charges. For more information about credits and billing, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Basics/Billing/billing_info_and_faqs.html).
### GET /user/credits
@@ -5453,7 +5453,7 @@ The inbound parse webhook allows you to have incoming emails parsed, extracting
**This endpoint allows you to retrieve all of your current inbound parse settings.**
-The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
+The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
### GET /user/webhooks/parse/settings
@@ -5476,7 +5476,7 @@ The inbound parse webhook allows you to have incoming emails parsed, extracting
**This endpoint allows you to update a specific inbound parse setting.**
-The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
+The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
### PATCH /user/webhooks/parse/settings/{hostname}
@@ -5500,7 +5500,7 @@ The inbound parse webhook allows you to have incoming emails parsed, extracting
**This endpoint allows you to retrieve a specific inbound parse setting.**
-The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
+The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
### GET /user/webhooks/parse/settings/{hostname}
@@ -5523,7 +5523,7 @@ The inbound parse webhook allows you to have incoming emails parsed, extracting
**This endpoint allows you to delete a specific inbound parse setting.**
-The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
+The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).
### DELETE /user/webhooks/parse/settings/{hostname}
@@ -5544,9 +5544,9 @@ The inbound parse webhook allows you to have incoming emails parsed, extracting
```
## Retrieves Inbound Parse Webhook statistics.
-**This endpoint allows you to retrieve the statistics for your Parse Webhook useage.**
+**This endpoint allows you to retrieve the statistics for your Parse Webhook usage.**
-SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incomming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 20MB in size, including all attachments.
+SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incoming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 20MB in size, including all attachments.
There are a number of pre-made integrations for the SendGrid Parse Webhook which make processing events easy. You can find these integrations in the [Library Index](https://sendgrid.com/docs/Integrate/libraries.html#-Webhook-Libraries).
diff --git a/proposals/mail-helper-refactor.md b/proposals/mail-helper-refactor.md
index b050491a..b06d2f1e 100644
--- a/proposals/mail-helper-refactor.md
+++ b/proposals/mail-helper-refactor.md
@@ -110,7 +110,7 @@ public class SendGridExample {
tos,
plainTextContent,
htmlContent,
- globalSubstition); // or globalSubstitutions
+ globalSubstitution); // or globalSubstitutions
SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
try {
From a74a8dfe24d0161db01d30211cf2a4efd8aeb2c4 Mon Sep 17 00:00:00 2001
From: Shashank Sharma
Date: Sat, 21 Oct 2017 21:05:55 -0400
Subject: [PATCH 054/345] Making ReadMe/Doc sections more SEO Friendly
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 02725369..45abaabf 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,9 @@ We appreciate your continued support, thank you!
# Table of Contents
* [Installation](#installation)
-* [Quick Start](#quick_start)
+* [Quick Start](#quick-start)
* [Usage](#usage)
-* [Use Cases](#use_cases)
+* [Use Cases](#use-cases)
* [Announcements](#announcements)
* [Roadmap](#roadmap)
* [How to Contribute](#contribute)
@@ -79,7 +79,7 @@ You can just drop the jar file in. It's a fat jar - it has all the dependencies
- [Java-HTTP-Client](https://github.com/sendgrid/java-http-client)
-
+
# Quick Start
## Hello Email
@@ -180,7 +180,7 @@ public class Example {
- [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-java/tree/master/src/main/java/com/sendgrid/helpers) - build a request object payload for a v3 /mail/send API call.
-
+
# Use Cases
[Examples of common API use cases](https://github.com/sendgrid/sendgrid-java/blob/master/USE_CASES.md), such as how to send an email with a transactional template.
@@ -204,10 +204,10 @@ We encourage contribution to our libraries (you might even score some nifty swag
Quick links:
-- [Feature Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#feature_request)
-- [Bug Reports](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#submit_a_bug_report)
+- [Feature Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#feature-request)
+- [Bug Reports](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#submit-a-bug-report)
- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#cla)
-- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#improvements_to_the_codebase)
+- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md#improvements-to-the-codebase)
# Troubleshooting
From ab346685994c72b46924501c4423358a34f5ce25 Mon Sep 17 00:00:00 2001
From: Shashank Sharma
Date: Sat, 21 Oct 2017 21:09:52 -0400
Subject: [PATCH 055/345] Making README/Doc sections more SEO friendly
---
CONTRIBUTING.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8cb8ea5c..8545e2f1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,13 +2,13 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou
- [CLAs and CCLAs](#cla)
- [Roadmap & Milestones](#roadmap)
-- [Feature Request](#feature_request)
-- [Submit a Bug Report](#submit_a_bug_report)
-- [Improvements to the Codebase](#improvements_to_the_codebase)
-- [Understanding the Code Base](#understanding_the_codebase)
+- [Feature Request](#feature-request)
+- [Submit a Bug Report](#submit-a-bug-report)
+- [Improvements to the Codebase](#improvements-to-the-codebase)
+- [Understanding the Code Base](#understanding-the-codebase)
- [Testing](#testing)
-- [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions)
-- [Creating a Pull Request](#creating_a_pull_request)
+- [Style Guidelines & Naming Conventions](#style-guidelines-and-naming-conventions)
+- [Creating a Pull Request](#creating-a-pull-request)
We use [Milestones](https://github.com/sendgrid/sendgrid-java/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
@@ -26,7 +26,7 @@ When you create a Pull Request, after a few seconds, a comment will appear with
There are a few ways to contribute, which we'll enumerate below:
-
+
## Feature Request
If you'd like to make a feature request, please read this section.
@@ -36,7 +36,7 @@ The GitHub issue tracker is the preferred channel for library feature requests,
- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
- Please be respectful and considerate of others when commenting on issues
-
+
## Submit a Bug Report
Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
@@ -53,7 +53,7 @@ Before you decide to create a new issue, please try the following:
In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-java/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
-
+
## Improvements to the Codebase
We welcome direct contributions to the sendgrid-java code base. Thank you!
@@ -105,7 +105,7 @@ Add the example you want to test to Example.java, including the headers at the t
javac -classpath ../repo/com/sendgrid/4.1.1/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.1-jar.jar:. Example
```
-
+
## Understanding the Code Base
**/examples**
@@ -149,7 +149,7 @@ For the purposes of contributing to this repo, please update the [`SendGridTest.
./gradlew test -i
```
-
+
## Style Guidelines & Naming Conventions
Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
@@ -158,7 +158,7 @@ Please run your code through:
- [FindBugs](http://findbugs.sourceforge.net/)
- [CheckStyle](http://checkstyle.sourceforge.net/) with [Google's Java Style Guide](http://checkstyle.sourceforge.net/reports/google-java-style.html).
-## Creating a Pull Request
+## Creating a Pull Request
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:
From bbf0d51a4b8cbf4c5565ca49fa8fa43bb6ee121d Mon Sep 17 00:00:00 2001
From: Shashank Sharma
Date: Sat, 21 Oct 2017 21:14:17 -0400
Subject: [PATCH 056/345] Making README/Doc sections more SEO friendly
---
USAGE.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index b29616d7..c014d11d 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -22,9 +22,9 @@ public class Example {
# Table of Contents
-* [ACCESS SETTINGS](#access_settings)
+* [ACCESS SETTINGS](#access-settings)
* [ALERTS](#alerts)
-* [API KEYS](#api_keys)
+* [API KEYS](#api-keys)
* [ASM](#asm)
* [BROWSERS](#browsers)
* [CAMPAIGNS](#campaigns)
@@ -35,21 +35,21 @@ public class Example {
* [GEO](#geo)
* [IPS](#ips)
* [MAIL](#mail)
-* [MAIL SETTINGS](#mail_settings)
-* [MAILBOX PROVIDERS](#mailbox_providers)
-* [PARTNER SETTINGS](#partner_settings)
+* [MAIL SETTINGS](#mail-settings)
+* [MAILBOX PROVIDERS](#mailbox-providers)
+* [PARTNER SETTINGS](#partner-settings)
* [SCOPES](#scopes)
* [SENDERS](#senders)
* [STATS](#stats)
* [SUBUSERS](#subusers)
* [SUPPRESSION](#suppression)
* [TEMPLATES](#templates)
-* [TRACKING SETTINGS](#tracking_settings)
+* [TRACKING SETTINGS](#tracking-settings)
* [USER](#user)
* [WHITELABEL](#whitelabel)
-
+
# ACCESS SETTINGS
## Retrieve all recent access attempts
@@ -353,7 +353,7 @@ For more information about alerts, please see our [User Guide](https://sendgrid.
throw ex;
}
```
-
+
# API KEYS
## Create API keys
@@ -2710,7 +2710,7 @@ This endpoint has a helper, check it out [here](https://github.com/sendgrid/send
throw ex;
}
```
-
+
# MAIL SETTINGS
## Retrieve all mail settings
@@ -3201,7 +3201,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
throw ex;
}
```
-
+
# MAILBOX PROVIDERS
## Retrieve email statistics by mailbox provider.
@@ -3235,7 +3235,7 @@ Advanced Stats provide a more in-depth view of your email statistics and the act
throw ex;
}
```
-
+
# PARTNER SETTINGS
## Returns a list of all partner settings.
@@ -4675,7 +4675,7 @@ For more information about transactional templates, please see our [User Guide](
throw ex;
}
```
-
+
# TRACKING SETTINGS
## Retrieve Tracking Settings
From 8000a368731d596c76025023b9d1d6b9cd560d12 Mon Sep 17 00:00:00 2001
From: Shashank Sharma
Date: Sat, 21 Oct 2017 21:15:24 -0400
Subject: [PATCH 057/345] Making README/Doc sections more SEO friendly
---
USE_CASES.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/USE_CASES.md b/USE_CASES.md
index 1bfb62f0..de1613f3 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -2,9 +2,9 @@ This documentation provides examples for specific use cases. Please [open an iss
# Table of Contents
-* [Transactional Templates](#transactional_templates)
+* [Transactional Templates](#transactional-templates)
-
+
# Transactional Templates
For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
@@ -98,4 +98,4 @@ public class Example {
}
}
}
-```
\ No newline at end of file
+```
From ff37ee084ad4d907a5d63eec4a7720515cd899b0 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Sat, 21 Oct 2017 18:32:07 -0700
Subject: [PATCH 058/345] Update .travis.yml
---
.travis.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 9986d9a1..4fc4dbee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,8 +11,6 @@ matrix:
- os: linux
jdk: oraclejdk8
before_script:
-- echo TRAVIS $TRAVIS
-- echo MOCK_HOST $MOCK_HOST
- "./scripts/startPrism.sh &"
- sleep 10
before_install:
From 5671dcaf42155265e85b5d8e39a666752f58b2ff Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sun, 22 Oct 2017 14:19:40 +0300
Subject: [PATCH 059/345] update readme - logo on separate line
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 82f67c59..2f8aed20 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@

+
[](https://travis-ci.org/sendgrid/sendgrid-java)
[](http://mvnrepository.com/artifact/com.sendgrid/sendgrid-java)
[](https://dx.sendgrid.com/newsletter/java)
From f9b1b920b590e992bb2df201943ade47c65bf5df Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Sun, 22 Oct 2017 13:17:33 -0500
Subject: [PATCH 060/345] Addressing comments.
---
src/main/java/com/sendgrid/SendGridAPI.java | 24 ++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGridAPI.java b/src/main/java/com/sendgrid/SendGridAPI.java
index d190675c..4f277cd7 100644
--- a/src/main/java/com/sendgrid/SendGridAPI.java
+++ b/src/main/java/com/sendgrid/SendGridAPI.java
@@ -13,17 +13,17 @@ public interface SendGridAPI {
public void initializeSendGrid(String apiKey);
/**
- * Initializes SendGrid
+ * Returns the library version
*
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
- * @return
+ * @return the library version.
*/
public String getLibraryVersion();
/**
* Gets the version.
*
- * @return
+ * @return returns the version.
*/
public String getVersion();
@@ -36,16 +36,16 @@ public interface SendGridAPI {
/**
* Gets the request headers.
- * @return
+ * @return returns a map of request headers.
*/
public Map getRequestHeaders();
/**
* Adds a request headers.
*
- * @param keythe key
- * @param valuethe value
- * @return
+ * @param key the key
+ * @param value the value
+ * @return returns a map of request headers.
*/
public Map addRequestHeader(String key, String value);
@@ -53,14 +53,14 @@ public interface SendGridAPI {
* Removes a request headers.
*
* @param key the key
- * @return
+ * @return returns a map of request headers.
*/
public Map removeRequestHeader(String key);
/**
* Gets the host.
*
- * @return
+ * @return returns the host.
*/
public String getHost();
@@ -76,8 +76,8 @@ public interface SendGridAPI {
* testing.
*
* @param request
- * @return
- * @throws IOException
+ * @return returns a response.
+ * @throws IOException in case of network or marshal error.
*/
public Response makeCall(Request request) throws IOException;
@@ -86,7 +86,7 @@ public interface SendGridAPI {
*
* @param request
* @return
- * @throws IOException
+ * @throws IOException in case of network or marshal error.
*/
public Response api(Request request) throws IOException;
}
From 65ce199f4da67991eccfd948caf36d6e8d0b27f3 Mon Sep 17 00:00:00 2001
From: shra1cumar
Date: Mon, 23 Oct 2017 14:54:54 +0530
Subject: [PATCH 061/345] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 2f8aed20..c20e01fb 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Version 3.X.X of this library provides full support for all SendGrid [Web API v3
This library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-java/issues) and [pull requests](https://github.com/sendgrid/sendgrid-java/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.
-Please browse the rest of this README for further detail.
+Please browse the rest of this README for further details.
We appreciate your continued support, thank you!
From ac1a990c7869e3fdb2a2a1a30ddff6b7a4623465 Mon Sep 17 00:00:00 2001
From: btrajkovski
Date: Mon, 23 Oct 2017 18:32:47 +0200
Subject: [PATCH 062/345] Fix java package names
Java packages were not corresponding to the actual location of classes,
all packages were update to match class location.
---
.../java/com/sendgrid/helpers/mail/Mail.java | 9 +----
.../sendgrid/helpers/mail/objects/ASM.java | 2 +-
.../helpers/mail/objects/Attachments.java | 2 +-
.../helpers/mail/objects/BccSettings.java | 2 +-
.../mail/objects/ClickTrackingSetting.java | 2 +-
.../helpers/mail/objects/Content.java | 2 +-
.../sendgrid/helpers/mail/objects/Email.java | 2 +-
.../helpers/mail/objects/FooterSetting.java | 2 +-
.../mail/objects/GoogleAnalyticsSetting.java | 2 +-
.../helpers/mail/objects/MailSettings.java | 38 +++++++++----------
.../mail/objects/OpenTrackingSetting.java | 2 +-
.../helpers/mail/objects/Personalization.java | 2 +-
.../helpers/mail/objects/Setting.java | 2 +-
.../mail/objects/SpamCheckSetting.java | 2 +-
.../objects/SubscriptionTrackingSetting.java | 2 +-
.../mail/objects/TrackingSettings.java | 2 +-
.../helpers/AttachmentBuilderTest.java | 2 +-
.../java/com/sendgrid/helpers/MailTest.java | 5 ++-
18 files changed, 39 insertions(+), 43 deletions(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index edf02a15..937b1e62 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -1,16 +1,11 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
+import com.sendgrid.helpers.mail.objects.*;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
index 00763af7..c92a6243 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
index 059fc835..cb075ed5 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
import com.fasterxml.jackson.annotation.JsonInclude;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
index 37be0866..e1c2fa1b 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index e901e086..7e40b57d 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
index f6621ac9..81994296 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
index 5642e345..a1b22212 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
index 1428b66b..ee033101 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
index eac91899..0c6cf0f3 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
index 1210eb08..76b21502 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
@@ -1,12 +1,12 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
- * An object representing a collection of different mail
- * settings that you can use to specify how you would
+ * An object representing a collection of different mail
+ * settings that you can use to specify how you would
* like this email to be handled.
*/
@JsonInclude(Include.NON_DEFAULT)
@@ -25,7 +25,7 @@ public class MailSettings {
public BccSettings getBccSettings() {
return bccSettings;
}
-
+
/**
* Set the BCC settings.
* @param bccSettings the BCC settings.
@@ -33,12 +33,12 @@ public BccSettings getBccSettings() {
public void setBccSettings(BccSettings bccSettings) {
this.bccSettings = bccSettings;
}
-
+
/**
- * A setting that allows you to bypass all unsubscribe
- * groups and suppressions to ensure that the email is
- * delivered to every single recipient. This should only
- * be used in emergencies when it is absolutely necessary
+ * A setting that allows you to bypass all unsubscribe
+ * groups and suppressions to ensure that the email is
+ * delivered to every single recipient. This should only
+ * be used in emergencies when it is absolutely necessary
* that every recipient receives your email.
* @return the bypass list setting.
*/
@@ -54,7 +54,7 @@ public Setting getBypassListManagement() {
public void setBypassListManagement(Setting bypassListManagement) {
this.bypassListManagement = bypassListManagement;
}
-
+
/**
* Get the the footer settings that you would like included on every email.
* @return the setting.
@@ -63,7 +63,7 @@ public void setBypassListManagement(Setting bypassListManagement) {
public FooterSetting getFooterSetting() {
return footerSetting;
}
-
+
/**
* Set the the footer settings that you would like included on every email.
* @param footerSetting the setting.
@@ -71,9 +71,9 @@ public FooterSetting getFooterSetting() {
public void setFooterSetting(FooterSetting footerSetting) {
this.footerSetting = footerSetting;
}
-
+
/**
- * Get sandbox mode. This allows you to send a test email to
+ * Get sandbox mode. This allows you to send a test email to
* ensure that your request body is valid and formatted correctly.
* @return the sandbox mode setting.
*/
@@ -81,18 +81,18 @@ public void setFooterSetting(FooterSetting footerSetting) {
public Setting getSandBoxMode() {
return sandBoxMode;
}
-
+
/**
- * Set sandbox mode.
+ * Set sandbox mode.
* @param sandBoxMode the sandbox mode setting.
*/
@JsonProperty("sandbox_mode")
public void setSandboxMode(Setting sandBoxMode) {
this.sandBoxMode = sandBoxMode;
}
-
+
/**
- * Get the spam check setting. This allows you to test the
+ * Get the spam check setting. This allows you to test the
* content of your email for spam.
* @return the spam check setting.
*/
@@ -100,9 +100,9 @@ public void setSandboxMode(Setting sandBoxMode) {
public SpamCheckSetting getSpamCheck() {
return spamCheckSetting;
}
-
+
/**
- * Set the spam check setting. This allows you to test the
+ * Set the spam check setting. This allows you to test the
* content of your email for spam.
* @param spamCheckSetting the spam check setting.
*/
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
index deba6d33..a0dab662 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index 83bd9c56..67226059 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
index 20b8d64e..c6157711 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
index dbd43955..95f425b9 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
index 304eb916..1280d440 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
index 0e2a47bb..72be0747 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java
@@ -1,4 +1,4 @@
-package com.sendgrid;
+package com.sendgrid.helpers.mail.objects;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
diff --git a/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java b/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java
index 824e8145..3ea3f379 100644
--- a/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java
+++ b/src/test/java/com/sendgrid/helpers/AttachmentBuilderTest.java
@@ -1,6 +1,6 @@
package com.sendgrid.helpers;
-import com.sendgrid.Attachments;
+import com.sendgrid.helpers.mail.objects.Attachments;
import org.apache.commons.codec.binary.Base64;
import org.junit.Assert;
import org.junit.Test;
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index e4eedd58..9476a1d5 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -1,7 +1,8 @@
-package com.sendgrid;
+package com.sendgrid.helpers;
+import com.sendgrid.helpers.mail.Mail;
+import com.sendgrid.helpers.mail.objects.*;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
From a0a51afa4bb675fa706935843860a8e71ca8a901 Mon Sep 17 00:00:00 2001
From: Ajitesh Rai
Date: Mon, 23 Oct 2017 23:36:08 +0530
Subject: [PATCH 063/345] Fix a typo
Removed duplicate 'the'.
---
USAGE.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index 7d32bc39..a254fd98 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -5672,7 +5672,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
@@ -5704,7 +5704,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
@@ -5813,7 +5813,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
From bd28104bf69f639d6e0329d99f72407a8e72827b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1t=C3=A9=20Sz=C3=A9les?=
Date: Mon, 23 Oct 2017 20:14:11 +0200
Subject: [PATCH 064/345] Remove redundant word 'the' from USAGE.md.
Change the sentence 'The the parent may then associate the whitelabel via the subuser management tools.' to 'The parent may then associate the whitelabel via the subuser management tools.'.
---
USAGE.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index 7d32bc39..a254fd98 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -5672,7 +5672,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
@@ -5704,7 +5704,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
@@ -5813,7 +5813,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record.
-Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools.
+Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The parent may then associate the whitelabel via the subuser management tools.
For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html)
From 22aee8718c90caa87fbc55eb62471574f4227378 Mon Sep 17 00:00:00 2001
From: Pooja Bharadwaj
Date: Tue, 24 Oct 2017 17:40:20 +0530
Subject: [PATCH 065/345] correction of typo in USAGE.md
replaced "visible by recipient" by "visible to recipient"
---
USAGE.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/USAGE.md b/USAGE.md
index a254fd98..cf25b2c6 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -533,7 +533,7 @@ The API Keys feature allows customers to be able to generate an API Key credenti
Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
-The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
+The **name** and **description** of the unsubscribe group will be visible to recipients when they are managing their subscriptions.
Each user can create up to 25 different suppression groups.
@@ -589,7 +589,7 @@ Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Refere
Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
-The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
+The **name** and **description** of the unsubscribe group will be visible to recipients when they are managing their subscriptions.
Each user can create up to 25 different suppression groups.
@@ -617,7 +617,7 @@ Each user can create up to 25 different suppression groups.
Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
-The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
+The **name** and **description** of the unsubscribe group will be visible to recipients when they are managing their subscriptions.
Each user can create up to 25 different suppression groups.
@@ -646,7 +646,7 @@ You can only delete groups that have not been attached to sent mail in the last
Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts.
-The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions.
+The **name** and **description** of the unsubscribe group will be visible to recipients when they are managing their subscriptions.
Each user can create up to 25 different suppression groups.
From e6b838a9c0d1a0f55cb8cb6b27af94d81e83c1a4 Mon Sep 17 00:00:00 2001
From: Nishith Shah
Date: Fri, 27 Oct 2017 01:56:19 +0530
Subject: [PATCH 066/345] Create PULL_REQUEST_TEMPLATE
Add a template for describing the change(s) being done.
---
.github/PULL_REQUEST_TEMPLATE | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 .github/PULL_REQUEST_TEMPLATE
diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE
new file mode 100644
index 00000000..e4059635
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE
@@ -0,0 +1,19 @@
+
+Closes: #[Issue number]
+
+**Description of the change**:
+
+If you have questions, please send an email [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.
+
From b9ddb85b2e2c5f4856d2bc8eed9215af7715f66d Mon Sep 17 00:00:00 2001
From: Thiago Barbato
Date: Thu, 26 Oct 2017 23:12:06 -0200
Subject: [PATCH 067/345] Add .env_sample file
---
.env_sample | 1 +
.gitignore | 3 ++-
README.md | 8 +++++---
3 files changed, 8 insertions(+), 4 deletions(-)
create mode 100644 .env_sample
diff --git a/.env_sample b/.env_sample
new file mode 100644
index 00000000..937e999d
--- /dev/null
+++ b/.env_sample
@@ -0,0 +1 @@
+export SENDGRID_API_KEY=''
diff --git a/.gitignore b/.gitignore
index 009d149a..2c5dd118 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,5 @@ target
examples/Example.java
.settings
.classpath
-.project
\ No newline at end of file
+.project
+.env
diff --git a/README.md b/README.md
index 9155acd6..009eeb0b 100644
--- a/README.md
+++ b/README.md
@@ -44,11 +44,13 @@ We appreciate your continued support, thank you!
Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example:
+1. Copy the sample environment file to a new file
```bash
-echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
-echo "sendgrid.env" >> .gitignore
-source ./sendgrid.env
+cp .env_sample .env
```
+2. Edit the new `.env` to add your API key
+3. Source the `.env` file to set rhe variable in the current session
+
## Install Package
Choose your installation method - Maven w/ Gradle (recommended), Maven or Jar file.
From 2f198a23eb62af443f4dbe3fa471e5573c02cdca Mon Sep 17 00:00:00 2001
From: teisena
Date: Sat, 28 Oct 2017 02:14:57 +0300
Subject: [PATCH 068/345] split examples by endpoint
---
examples/contactdb/contactdb.java | 717 -------------------------
examples/contactdb/customfields.java | 97 ++++
examples/contactdb/lists.java | 240 +++++++++
examples/contactdb/recipients.java | 305 +++++++++++
examples/contactdb/reservedfields.java | 30 ++
examples/contactdb/segments.java | 147 +++++
6 files changed, 819 insertions(+), 717 deletions(-)
delete mode 100644 examples/contactdb/contactdb.java
create mode 100644 examples/contactdb/customfields.java
create mode 100644 examples/contactdb/lists.java
create mode 100644 examples/contactdb/recipients.java
create mode 100644 examples/contactdb/reservedfields.java
create mode 100644 examples/contactdb/segments.java
diff --git a/examples/contactdb/contactdb.java b/examples/contactdb/contactdb.java
deleted file mode 100644
index 1f971c8f..00000000
--- a/examples/contactdb/contactdb.java
+++ /dev/null
@@ -1,717 +0,0 @@
-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 Custom Field
-// POST /contactdb/custom_fields
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/custom_fields");
- request.setBody("{\"type\":\"text\",\"name\":\"pet\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all custom fields
-// GET /contactdb/custom_fields
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/custom_fields");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a Custom Field
-// GET /contactdb/custom_fields/{custom_field_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.setMethod(Method.GET);
- request.setEndpoint("contactdb/custom_fields/{custom_field_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Custom Field
-// DELETE /contactdb/custom_fields/{custom_field_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/custom_fields/{custom_field_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create a List
-// POST /contactdb/lists
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists");
- request.setBody("{\"name\":\"your list name\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all lists
-// GET /contactdb/lists
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/lists");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete Multiple lists
-// DELETE /contactdb/lists
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/lists");
- request.setBody("[1,2,3,4]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update a List
-// PATCH /contactdb/lists/{list_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.setMethod(Method.PATCH);
- request.setEndpoint("contactdb/lists/{list_id}");
- request.setBody("{\"name\":\"newlistname\"}");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a single list
-// GET /contactdb/lists/{list_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.setMethod(Method.GET);
- request.setEndpoint("contactdb/lists/{list_id}");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a List
-// DELETE /contactdb/lists/{list_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/lists/{list_id}");
- request.addQueryParam("delete_contacts", "true");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add Multiple Recipients to a List
-// POST /contactdb/lists/{list_id}/recipients
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists/{list_id}/recipients");
- request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all recipients on a List
-// GET /contactdb/lists/{list_id}/recipients
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/lists/{list_id}/recipients");
- request.addQueryParam("page", "1");
- request.addQueryParam("page_size", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add a Single Recipient to a List
-// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Single Recipient from a Single List
-// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- request.addQueryParam("recipient_id", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update Recipient
-// PATCH /contactdb/recipients
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("contactdb/recipients");
- request.setBody("[{\"first_name\":\"Guy\",\"last_name\":\"Jones\",\"email\":\"jones@example.com\"}]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add recipients
-// POST /contactdb/recipients
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/recipients");
- request.setBody("[{\"age\":25,\"last_name\":\"User\",\"email\":\"example@example.com\",\"first_name\":\"\"},{\"age\":25,\"last_name\":\"User\",\"email\":\"example2@example.com\",\"first_name\":\"Example\"}]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve recipients
-// GET /contactdb/recipients
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients");
- request.addQueryParam("page", "1");
- request.addQueryParam("page_size", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete Recipient
-// DELETE /contactdb/recipients
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/recipients");
- request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve the count of billable recipients
-// GET /contactdb/recipients/billable_count
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients/billable_count");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a Count of Recipients
-// GET /contactdb/recipients/count
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients/count");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve recipients matching search criteria
-// GET /contactdb/recipients/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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients/search");
- request.addQueryParam("{field_name}", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a single recipient
-// GET /contactdb/recipients/{recipient_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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients/{recipient_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Recipient
-// DELETE /contactdb/recipients/{recipient_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/recipients/{recipient_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve the lists that a recipient is on
-// GET /contactdb/recipients/{recipient_id}/lists
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/recipients/{recipient_id}/lists");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve reserved fields
-// GET /contactdb/reserved_fields
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/reserved_fields");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create a Segment
-// POST /contactdb/segments
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/segments");
- request.setBody("{\"conditions\":[{\"operator\":\"eq\",\"field\":\"last_name\",\"and_or\":\"\",\"value\":\"Miller\"},{\"operator\":\"gt\",\"field\":\"last_clicked\",\"and_or\":\"and\",\"value\":\"01/02/2015\"},{\"operator\":\"eq\",\"field\":\"clicks.campaign_identifier\",\"and_or\":\"or\",\"value\":\"513\"}],\"name\":\"Last Name Miller\",\"list_id\":4}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all segments
-// GET /contactdb/segments
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/segments");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update a segment
-// PATCH /contactdb/segments/{segment_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.setMethod(Method.PATCH);
- request.setEndpoint("contactdb/segments/{segment_id}");
- request.setBody("{\"conditions\":[{\"operator\":\"eq\",\"field\":\"last_name\",\"and_or\":\"\",\"value\":\"Miller\"}],\"name\":\"The Millers\",\"list_id\":5}");
- request.addQueryParam("segment_id", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a segment
-// GET /contactdb/segments/{segment_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.setMethod(Method.GET);
- request.setEndpoint("contactdb/segments/{segment_id}");
- request.addQueryParam("segment_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a segment
-// DELETE /contactdb/segments/{segment_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/segments/{segment_id}");
- request.addQueryParam("delete_contacts", "true");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve recipients on a segment
-// GET /contactdb/segments/{segment_id}/recipients
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/segments/{segment_id}/recipients");
- request.addQueryParam("page", "1");
- request.addQueryParam("page_size", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
diff --git a/examples/contactdb/customfields.java b/examples/contactdb/customfields.java
new file mode 100644
index 00000000..e4ce5c58
--- /dev/null
+++ b/examples/contactdb/customfields.java
@@ -0,0 +1,97 @@
+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 Custom Field
+// POST /contactdb/custom_fields
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/custom_fields");
+ request.setBody("{\"type\":\"text\",\"name\":\"pet\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all custom fields
+// GET /contactdb/custom_fields
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/custom_fields");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a Custom Field
+// GET /contactdb/custom_fields/{custom_field_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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/custom_fields/{custom_field_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Custom Field
+// DELETE /contactdb/custom_fields/{custom_field_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/custom_fields/{custom_field_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/contactdb/lists.java b/examples/contactdb/lists.java
new file mode 100644
index 00000000..534a739c
--- /dev/null
+++ b/examples/contactdb/lists.java
@@ -0,0 +1,240 @@
+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 List
+// POST /contactdb/lists
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists");
+ request.setBody("{\"name\":\"your list name\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all lists
+// GET /contactdb/lists
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/lists");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete Multiple lists
+// DELETE /contactdb/lists
+
+
+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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/lists");
+ request.setBody("[1,2,3,4]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Update a List
+// PATCH /contactdb/lists/{list_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.setMethod(Method.PATCH);
+ request.setEndpoint("contactdb/lists/{list_id}");
+ request.setBody("{\"name\":\"newlistname\"}");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a single list
+// GET /contactdb/lists/{list_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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/lists/{list_id}");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a List
+// DELETE /contactdb/lists/{list_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/lists/{list_id}");
+ request.addQueryParam("delete_contacts", "true");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add Multiple Recipients to a List
+// POST /contactdb/lists/{list_id}/recipients
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients");
+ request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all recipients on a List
+// GET /contactdb/lists/{list_id}/recipients
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients");
+ request.addQueryParam("page", "1");
+ request.addQueryParam("page_size", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add a Single Recipient to a List
+// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Single Recipient from a Single List
+// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ request.addQueryParam("recipient_id", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/contactdb/recipients.java b/examples/contactdb/recipients.java
new file mode 100644
index 00000000..255a8e97
--- /dev/null
+++ b/examples/contactdb/recipients.java
@@ -0,0 +1,305 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all recipients on a List
+// GET /contactdb/lists/{list_id}/recipients
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients");
+ request.addQueryParam("page", "1");
+ request.addQueryParam("page_size", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add a Single Recipient to a List
+// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Single Recipient from a Single List
+// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ request.addQueryParam("recipient_id", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Update Recipient
+// PATCH /contactdb/recipients
+
+
+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.setMethod(Method.PATCH);
+ request.setEndpoint("contactdb/recipients");
+ request.setBody("[{\"first_name\":\"Guy\",\"last_name\":\"Jones\",\"email\":\"jones@example.com\"}]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add recipients
+// POST /contactdb/recipients
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/recipients");
+ request.setBody("[{\"age\":25,\"last_name\":\"User\",\"email\":\"example@example.com\",\"first_name\":\"\"},{\"age\":25,\"last_name\":\"User\",\"email\":\"example2@example.com\",\"first_name\":\"Example\"}]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve recipients
+// GET /contactdb/recipients
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients");
+ request.addQueryParam("page", "1");
+ request.addQueryParam("page_size", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete Recipient
+// DELETE /contactdb/recipients
+
+
+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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/recipients");
+ request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve the count of billable recipients
+// GET /contactdb/recipients/billable_count
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients/billable_count");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a Count of Recipients
+// GET /contactdb/recipients/count
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients/count");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve recipients matching search criteria
+// GET /contactdb/recipients/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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients/search");
+ request.addQueryParam("{field_name}", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a single recipient
+// GET /contactdb/recipients/{recipient_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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients/{recipient_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Recipient
+// DELETE /contactdb/recipients/{recipient_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/recipients/{recipient_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve the lists that a recipient is on
+// GET /contactdb/recipients/{recipient_id}/lists
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/recipients/{recipient_id}/lists");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/contactdb/reservedfields.java b/examples/contactdb/reservedfields.java
new file mode 100644
index 00000000..e9ceafa9
--- /dev/null
+++ b/examples/contactdb/reservedfields.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve reserved fields
+// GET /contactdb/reserved_fields
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/reserved_fields");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/contactdb/segments.java b/examples/contactdb/segments.java
new file mode 100644
index 00000000..84c60027
--- /dev/null
+++ b/examples/contactdb/segments.java
@@ -0,0 +1,147 @@
+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 Segment
+// POST /contactdb/segments
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/segments");
+ request.setBody("{\"conditions\":[{\"operator\":\"eq\",\"field\":\"last_name\",\"and_or\":\"\",\"value\":\"Miller\"},{\"operator\":\"gt\",\"field\":\"last_clicked\",\"and_or\":\"and\",\"value\":\"01/02/2015\"},{\"operator\":\"eq\",\"field\":\"clicks.campaign_identifier\",\"and_or\":\"or\",\"value\":\"513\"}],\"name\":\"Last Name Miller\",\"list_id\":4}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all segments
+// GET /contactdb/segments
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/segments");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Update a segment
+// PATCH /contactdb/segments/{segment_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.setMethod(Method.PATCH);
+ request.setEndpoint("contactdb/segments/{segment_id}");
+ request.setBody("{\"conditions\":[{\"operator\":\"eq\",\"field\":\"last_name\",\"and_or\":\"\",\"value\":\"Miller\"}],\"name\":\"The Millers\",\"list_id\":5}");
+ request.addQueryParam("segment_id", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a segment
+// GET /contactdb/segments/{segment_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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/segments/{segment_id}");
+ request.addQueryParam("segment_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a segment
+// DELETE /contactdb/segments/{segment_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/segments/{segment_id}");
+ request.addQueryParam("delete_contacts", "true");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve recipients on a segment
+// GET /contactdb/segments/{segment_id}/recipients
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/segments/{segment_id}/recipients");
+ request.addQueryParam("page", "1");
+ request.addQueryParam("page_size", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
From 711217924795279c26787302ea6d3d1313e03208 Mon Sep 17 00:00:00 2001
From: teisena
Date: Sat, 28 Oct 2017 02:21:13 +0300
Subject: [PATCH 069/345] split lists/recipients endpoint
---
examples/contactdb/listrecipients.java | 102 +++++++++++++++++++++++++
examples/contactdb/lists.java | 94 -----------------------
examples/contactdb/recipients.java | 71 -----------------
3 files changed, 102 insertions(+), 165 deletions(-)
create mode 100644 examples/contactdb/listrecipients.java
diff --git a/examples/contactdb/listrecipients.java b/examples/contactdb/listrecipients.java
new file mode 100644
index 00000000..cfe621e7
--- /dev/null
+++ b/examples/contactdb/listrecipients.java
@@ -0,0 +1,102 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Add Multiple Recipients to a List
+// POST /contactdb/lists/{list_id}/recipients
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients");
+ request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all recipients on a List
+// GET /contactdb/lists/{list_id}/recipients
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients");
+ request.addQueryParam("page", "1");
+ request.addQueryParam("page_size", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add a Single Recipient to a List
+// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Single Recipient from a Single List
+// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
+ request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
+ request.addQueryParam("recipient_id", "1");
+ request.addQueryParam("list_id", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/contactdb/lists.java b/examples/contactdb/lists.java
index 534a739c..1e55fd29 100644
--- a/examples/contactdb/lists.java
+++ b/examples/contactdb/lists.java
@@ -144,97 +144,3 @@ public static void main(String[] args) throws IOException {
}
}
}
-
-//////////////////////////////////////////////////////////////////
-// Add Multiple Recipients to a List
-// POST /contactdb/lists/{list_id}/recipients
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists/{list_id}/recipients");
- request.setBody("[\"recipient_id1\",\"recipient_id2\"]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all recipients on a List
-// GET /contactdb/lists/{list_id}/recipients
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/lists/{list_id}/recipients");
- request.addQueryParam("page", "1");
- request.addQueryParam("page_size", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add a Single Recipient to a List
-// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Single Recipient from a Single List
-// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- request.addQueryParam("recipient_id", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
diff --git a/examples/contactdb/recipients.java b/examples/contactdb/recipients.java
index 255a8e97..ebba8d90 100644
--- a/examples/contactdb/recipients.java
+++ b/examples/contactdb/recipients.java
@@ -7,77 +7,6 @@
import java.util.HashMap;
import java.util.Map;
-//////////////////////////////////////////////////////////////////
-// Retrieve all recipients on a List
-// GET /contactdb/lists/{list_id}/recipients
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("contactdb/lists/{list_id}/recipients");
- request.addQueryParam("page", "1");
- request.addQueryParam("page_size", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add a Single Recipient to a List
-// POST /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.POST);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Single Recipient from a Single List
-// DELETE /contactdb/lists/{list_id}/recipients/{recipient_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.setMethod(Method.DELETE);
- request.setEndpoint("contactdb/lists/{list_id}/recipients/{recipient_id}");
- request.addQueryParam("recipient_id", "1");
- request.addQueryParam("list_id", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
//////////////////////////////////////////////////////////////////
// Update Recipient
// PATCH /contactdb/recipients
From 1ca8320d332ec293c9f87e823ed55e24a5a0c541 Mon Sep 17 00:00:00 2001
From: teisena
Date: Sat, 28 Oct 2017 02:43:28 +0300
Subject: [PATCH 070/345] split whitelabel examples by endpoint
---
examples/whitelabel/domains.java | 281 +++++++++++++
examples/whitelabel/ips.java | 122 ++++++
examples/whitelabel/links.java | 238 +++++++++++
examples/whitelabel/whitelabel.java | 625 ----------------------------
4 files changed, 641 insertions(+), 625 deletions(-)
create mode 100644 examples/whitelabel/domains.java
create mode 100644 examples/whitelabel/ips.java
create mode 100644 examples/whitelabel/links.java
delete mode 100644 examples/whitelabel/whitelabel.java
diff --git a/examples/whitelabel/domains.java b/examples/whitelabel/domains.java
new file mode 100644
index 00000000..26a0d0a2
--- /dev/null
+++ b/examples/whitelabel/domains.java
@@ -0,0 +1,281 @@
+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 domain whitelabel.
+// POST /whitelabel/domains
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains");
+ request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// List all domain whitelabels.
+// GET /whitelabel/domains
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/domains");
+ request.addQueryParam("username", "test_string");
+ request.addQueryParam("domain", "test_string");
+ request.addQueryParam("exclude_subusers", "true");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Get the default domain whitelabel.
+// GET /whitelabel/domains/default
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/domains/default");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// List the domain whitelabel associated with the given user.
+// GET /whitelabel/domains/subuser
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/domains/subuser");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Disassociate a domain whitelabel from a given user.
+// DELETE /whitelabel/domains/subuser
+
+
+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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/domains/subuser");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Update a domain whitelabel.
+// PATCH /whitelabel/domains/{domain_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.setMethod(Method.PATCH);
+ request.setEndpoint("whitelabel/domains/{domain_id}");
+ request.setBody("{\"default\":false,\"custom_spf\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a domain whitelabel.
+// GET /whitelabel/domains/{domain_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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/domains/{domain_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a domain whitelabel.
+// DELETE /whitelabel/domains/{domain_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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/domains/{domain_id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Associate a domain whitelabel with a given user.
+// POST /whitelabel/domains/{domain_id}/subuser
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains/{domain_id}/subuser");
+ request.setBody("{\"username\":\"jane@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Add an IP to a domain whitelabel.
+// POST /whitelabel/domains/{id}/ips
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains/{id}/ips");
+ request.setBody("{\"ip\":\"192.168.0.1\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Remove an IP from a domain whitelabel.
+// DELETE /whitelabel/domains/{id}/ips/{ip}
+
+
+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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/domains/{id}/ips/{ip}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Validate a domain whitelabel.
+// POST /whitelabel/domains/{id}/validate
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/domains/{id}/validate");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/whitelabel/ips.java b/examples/whitelabel/ips.java
new file mode 100644
index 00000000..54cb2af3
--- /dev/null
+++ b/examples/whitelabel/ips.java
@@ -0,0 +1,122 @@
+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 an IP whitelabel
+// POST /whitelabel/ips
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/ips");
+ request.setBody("{\"ip\":\"192.168.1.1\",\"domain\":\"example.com\",\"subdomain\":\"email\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IP whitelabels
+// GET /whitelabel/ips
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/ips");
+ request.addQueryParam("ip", "test_string");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve an IP whitelabel
+// GET /whitelabel/ips/{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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/ips/{id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete an IP whitelabel
+// DELETE /whitelabel/ips/{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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/ips/{id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Validate an IP whitelabel
+// POST /whitelabel/ips/{id}/validate
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/ips/{id}/validate");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/whitelabel/links.java b/examples/whitelabel/links.java
new file mode 100644
index 00000000..ca7218ff
--- /dev/null
+++ b/examples/whitelabel/links.java
@@ -0,0 +1,238 @@
+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 Link Whitelabel
+// POST /whitelabel/links
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/links");
+ request.setBody("{\"default\":true,\"domain\":\"example.com\",\"subdomain\":\"mail\"}");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all link whitelabels
+// GET /whitelabel/links
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/links");
+ request.addQueryParam("limit", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a Default Link Whitelabel
+// GET /whitelabel/links/default
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/links/default");
+ request.addQueryParam("domain", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve Associated Link Whitelabel
+// GET /whitelabel/links/subuser
+
+
+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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/links/subuser");
+ request.addQueryParam("username", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Disassociate a Link Whitelabel
+// DELETE /whitelabel/links/subuser
+
+
+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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/links/subuser");
+ request.addQueryParam("username", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Update a Link Whitelabel
+// PATCH /whitelabel/links/{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.setMethod(Method.PATCH);
+ request.setEndpoint("whitelabel/links/{id}");
+ request.setBody("{\"default\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a Link Whitelabel
+// GET /whitelabel/links/{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.setMethod(Method.GET);
+ request.setEndpoint("whitelabel/links/{id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Delete a Link Whitelabel
+// DELETE /whitelabel/links/{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.setMethod(Method.DELETE);
+ request.setEndpoint("whitelabel/links/{id}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Validate a Link Whitelabel
+// POST /whitelabel/links/{id}/validate
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/links/{id}/validate");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////
+// Associate a Link Whitelabel
+// POST /whitelabel/links/{link_id}/subuser
+
+
+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.setMethod(Method.POST);
+ request.setEndpoint("whitelabel/links/{link_id}/subuser");
+ request.setBody("{\"username\":\"jane@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
diff --git a/examples/whitelabel/whitelabel.java b/examples/whitelabel/whitelabel.java
deleted file mode 100644
index 4c668de5..00000000
--- a/examples/whitelabel/whitelabel.java
+++ /dev/null
@@ -1,625 +0,0 @@
-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 domain whitelabel.
-// POST /whitelabel/domains
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains");
- request.setBody("{\"automatic_security\":false,\"username\":\"john@example.com\",\"domain\":\"example.com\",\"default\":true,\"custom_spf\":true,\"ips\":[\"192.168.1.1\",\"192.168.1.2\"],\"subdomain\":\"news\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// List all domain whitelabels.
-// GET /whitelabel/domains
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/domains");
- request.addQueryParam("username", "test_string");
- request.addQueryParam("domain", "test_string");
- request.addQueryParam("exclude_subusers", "true");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Get the default domain whitelabel.
-// GET /whitelabel/domains/default
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/domains/default");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// List the domain whitelabel associated with the given user.
-// GET /whitelabel/domains/subuser
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/domains/subuser");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Disassociate a domain whitelabel from a given user.
-// DELETE /whitelabel/domains/subuser
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/domains/subuser");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update a domain whitelabel.
-// PATCH /whitelabel/domains/{domain_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.setMethod(Method.PATCH);
- request.setEndpoint("whitelabel/domains/{domain_id}");
- request.setBody("{\"default\":false,\"custom_spf\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a domain whitelabel.
-// GET /whitelabel/domains/{domain_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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/domains/{domain_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a domain whitelabel.
-// DELETE /whitelabel/domains/{domain_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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/domains/{domain_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Associate a domain whitelabel with a given user.
-// POST /whitelabel/domains/{domain_id}/subuser
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains/{domain_id}/subuser");
- request.setBody("{\"username\":\"jane@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add an IP to a domain whitelabel.
-// POST /whitelabel/domains/{id}/ips
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains/{id}/ips");
- request.setBody("{\"ip\":\"192.168.0.1\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Remove an IP from a domain whitelabel.
-// DELETE /whitelabel/domains/{id}/ips/{ip}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/domains/{id}/ips/{ip}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Validate a domain whitelabel.
-// POST /whitelabel/domains/{id}/validate
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/domains/{id}/validate");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create an IP whitelabel
-// POST /whitelabel/ips
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/ips");
- request.setBody("{\"ip\":\"192.168.1.1\",\"domain\":\"example.com\",\"subdomain\":\"email\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IP whitelabels
-// GET /whitelabel/ips
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/ips");
- request.addQueryParam("ip", "test_string");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve an IP whitelabel
-// GET /whitelabel/ips/{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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/ips/{id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete an IP whitelabel
-// DELETE /whitelabel/ips/{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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/ips/{id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Validate an IP whitelabel
-// POST /whitelabel/ips/{id}/validate
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/ips/{id}/validate");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create a Link Whitelabel
-// POST /whitelabel/links
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/links");
- request.setBody("{\"default\":true,\"domain\":\"example.com\",\"subdomain\":\"mail\"}");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all link whitelabels
-// GET /whitelabel/links
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/links");
- request.addQueryParam("limit", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a Default Link Whitelabel
-// GET /whitelabel/links/default
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/links/default");
- request.addQueryParam("domain", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve Associated Link Whitelabel
-// GET /whitelabel/links/subuser
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/links/subuser");
- request.addQueryParam("username", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Disassociate a Link Whitelabel
-// DELETE /whitelabel/links/subuser
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/links/subuser");
- request.addQueryParam("username", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update a Link Whitelabel
-// PATCH /whitelabel/links/{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.setMethod(Method.PATCH);
- request.setEndpoint("whitelabel/links/{id}");
- request.setBody("{\"default\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a Link Whitelabel
-// GET /whitelabel/links/{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.setMethod(Method.GET);
- request.setEndpoint("whitelabel/links/{id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a Link Whitelabel
-// DELETE /whitelabel/links/{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.setMethod(Method.DELETE);
- request.setEndpoint("whitelabel/links/{id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Validate a Link Whitelabel
-// POST /whitelabel/links/{id}/validate
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/links/{id}/validate");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Associate a Link Whitelabel
-// POST /whitelabel/links/{link_id}/subuser
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("whitelabel/links/{link_id}/subuser");
- request.setBody("{\"username\":\"jane@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
From 61de103f6df7b786bf477e519e96c90767ccf70a Mon Sep 17 00:00:00 2001
From: Luan Cestari
Date: Fri, 27 Oct 2017 22:44:41 -0200
Subject: [PATCH 071/345] [issue#336] Possible fix the duplciated code
---
.../java/com/sendgrid/helpers/mail/Mail.java | 71 ++++++++-----------
1 file changed, 29 insertions(+), 42 deletions(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index edf02a15..034e768c 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -200,12 +200,7 @@ public List getPersonalization() {
* @param personalization a personalization.
*/
public void addPersonalization(Personalization personalization) {
- if (this.personalization == null) {
- this.personalization = new ArrayList();
- this.personalization.add(personalization);
- } else {
- this.personalization.add(personalization);
- }
+ this.personalization = addToList(personalization, this.personalization);
}
/**
@@ -226,12 +221,7 @@ public void addContent(Content content) {
Content newContent = new Content();
newContent.setType(content.getType());
newContent.setValue(content.getValue());
- if (this.content == null) {
- this.content = new ArrayList();
- this.content.add(newContent);
- } else {
- this.content.add(newContent);
- }
+ this.content = addToList(newContent, this.content);
}
/**
@@ -255,12 +245,7 @@ public void addAttachments(Attachments attachments) {
newAttachment.setFilename(attachments.getFilename());
newAttachment.setDisposition(attachments.getDisposition());
newAttachment.setContentId(attachments.getContentId());
- if (this.attachments == null) {
- this.attachments = new ArrayList();
- this.attachments.add(newAttachment);
- } else {
- this.attachments.add(newAttachment);
- }
+ this.attachments = addToList(newAttachment, this.attachments);
}
/**
@@ -296,12 +281,7 @@ public Map getSections() {
* @param value the section's value.
*/
public void addSection(String key, String value) {
- if (sections == null) {
- sections = new HashMap();
- sections.put(key, value);
- } else {
- sections.put(key, value);
- }
+ this.sections = addToMap(key, value, this.sections);
}
/**
@@ -320,12 +300,7 @@ public Map getHeaders() {
* @param value the header's value.
*/
public void addHeader(String key, String value) {
- if (headers == null) {
- headers = new HashMap();
- headers.put(key, value);
- } else {
- headers.put(key, value);
- }
+ this.headers = addToMap(key, value, this.headers);
}
/**
@@ -343,12 +318,7 @@ public List getCategories() {
* @param category the category.
*/
public void addCategory(String category) {
- if (categories == null) {
- categories = new ArrayList();
- categories.add(category);
- } else {
- categories.add(category);
- }
+ this.categories = addToList(category, this.categories);
}
/**
@@ -367,12 +337,7 @@ public Map getCustomArgs() {
* @param value the argument's value.
*/
public void addCustomArg(String key, String value) {
- if (customArgs == null) {
- customArgs = new HashMap();
- customArgs.put(key, value);
- } else {
- customArgs.put(key, value);
- }
+ this.customArgs = addToMap(key, value, this.customArgs);
}
/**
@@ -504,4 +469,26 @@ public String buildPretty() throws IOException {
throw ex;
}
}
+
+ private List addToList(T element, List defaultList) {
+ if (defaultList != null) {
+ defaultList.add(element);
+ return defaultList;
+ } else {
+ List list = new ArrayList();
+ list.add(element);
+ return list;
+ }
+ }
+
+ private Map addToMap(K key, V value, Map defaultMap) {
+ if (defaultMap != null) {
+ defaultMap.put(key, value);
+ return defaultMap;
+ } else {
+ Map map = new HashMap();
+ map.put(key, value);
+ return map;
+ }
+ }
}
From 7cb6fb1d03e16fa24337159f75ec4e52d73df1f3 Mon Sep 17 00:00:00 2001
From: Luan Cestari
Date: Fri, 27 Oct 2017 22:50:37 -0200
Subject: [PATCH 072/345] [issue#336] Fix a generic type mismatch
---
src/main/java/com/sendgrid/helpers/mail/Mail.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index 034e768c..a1af2c2b 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -486,7 +486,7 @@ private Map addToMap(K key, V value, Map defaultMap) {
defaultMap.put(key, value);
return defaultMap;
} else {
- Map map = new HashMap();
+ Map map = new HashMap();
map.put(key, value);
return map;
}
From aaa28b33bf49c22a3ac3d121b4a530f93d90f855 Mon Sep 17 00:00:00 2001
From: Luan Cestari
Date: Fri, 27 Oct 2017 22:53:43 -0200
Subject: [PATCH 073/345] [issue#336] Fix a generic type mismatch
---
src/main/java/com/sendgrid/helpers/mail/Mail.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java
index a1af2c2b..b34d7294 100644
--- a/src/main/java/com/sendgrid/helpers/mail/Mail.java
+++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java
@@ -481,7 +481,7 @@ private List addToList(T element, List defaultList) {
}
}
- private Map addToMap(K key, V value, Map defaultMap) {
+ private Map addToMap(K key, V value, Map defaultMap) {
if (defaultMap != null) {
defaultMap.put(key, value);
return defaultMap;
From dc40bc981ae458184cf27d30b1b3dab8f1295d06 Mon Sep 17 00:00:00 2001
From: sccalabr
Date: Fri, 27 Oct 2017 20:15:10 -0500
Subject: [PATCH 074/345] Addressing comments.
---
src/main/java/com/sendgrid/SendGridAPI.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/sendgrid/SendGridAPI.java b/src/main/java/com/sendgrid/SendGridAPI.java
index 4f277cd7..32998459 100644
--- a/src/main/java/com/sendgrid/SendGridAPI.java
+++ b/src/main/java/com/sendgrid/SendGridAPI.java
@@ -75,7 +75,7 @@ public interface SendGridAPI {
* Class makeCall makes the call to the SendGrid API, override this method for
* testing.
*
- * @param request
+ * @param request the request
* @return returns a response.
* @throws IOException in case of network or marshal error.
*/
@@ -84,8 +84,8 @@ public interface SendGridAPI {
/**
* Class api sets up the request to the SendGrid API, this is main interface.
*
- * @param request
- * @return
+ * @param request the request
+ * @return returns a response.
* @throws IOException in case of network or marshal error.
*/
public Response api(Request request) throws IOException;
From 1844839842351239990442d9ced274311660884a Mon Sep 17 00:00:00 2001
From: Raja Sekhar Karanam
Date: Sat, 28 Oct 2017 15:59:04 +0530
Subject: [PATCH 075/345] Update CONTRIBUTING.md
While I was reading the CONTRIBUTING section to learn how to contribute, I stumbled upon these broken links and typos. Hope this helps!
---
CONTRIBUTING.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c818c473..8c70abe1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -129,7 +129,7 @@ All test files are in the [`tests`](https://github.com/sendgrid/sendgrid-java/tr
For the purposes of contributing to this repo, please update the [`SendGridTest.java`](https://github.com/sendgrid/sendgrid-java/tree/master/src/test/java/com/sendgrid/SendGridTest.java) file with unit tests as you modify the code.
-1. Download [prism](https://stoplight.io/prism/) for your platform ([Mac OS X](https://github.com/stoplightio/prism/releases/download/v0.1.5/prism_darwin_amd64)) and save the binary to the sendgrid-ruby directory (or any directory you would like. The sendgrid-ruby directory is chosen mostly for convenience.)
+1. Download [prism](http://stoplight.io/platform/prism/) for your platform ([Mac OS X](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_darwin_amd64), [Linux](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_linux_amd64), [Windows](https://github.com/stoplightio/prism/releases/download/v0.6.21/prism_windows_amd64.exe)) and save the binary to the sendgrid-java directory (or any directory you would like. The sendgrid-java directory is chosen mostly for convenience.)
1. Add execute permissions
From ccad505444c9da3df3c8dd8848c8d020242b684d Mon Sep 17 00:00:00 2001
From: "Julian J. Maurer"
Date: Sat, 28 Oct 2017 16:37:46 +0200
Subject: [PATCH 076/345] Fix for issue #335
Created seperate files for each example
---
examples/ips/README.md | 5 +
examples/ips/RetrieveAllIPs.java | 34 +++
examples/ips/addiptowarmup.java | 33 +++
examples/ips/addtopool.java | 32 +++
examples/ips/createpool.java | 32 +++
examples/ips/deletepool.java | 31 +++
examples/ips/ips.java | 326 -------------------------
examples/ips/removefromwarmup.java | 32 +++
examples/ips/removeipfrompool.java | 31 +++
examples/ips/retrieveallpools.java | 30 +++
examples/ips/retrieveassignedips.java | 31 +++
examples/ips/retrieveipsinpool.java | 31 +++
examples/ips/retrieveipsinwarmup.java | 32 +++
examples/ips/retrievepoolsforip.java | 33 +++
examples/ips/retrievewarmupstatus.java | 32 +++
examples/ips/updatepoolname.java | 32 +++
16 files changed, 451 insertions(+), 326 deletions(-)
create mode 100644 examples/ips/README.md
create mode 100644 examples/ips/RetrieveAllIPs.java
create mode 100644 examples/ips/addiptowarmup.java
create mode 100644 examples/ips/addtopool.java
create mode 100644 examples/ips/createpool.java
create mode 100644 examples/ips/deletepool.java
delete mode 100644 examples/ips/ips.java
create mode 100644 examples/ips/removefromwarmup.java
create mode 100644 examples/ips/removeipfrompool.java
create mode 100644 examples/ips/retrieveallpools.java
create mode 100644 examples/ips/retrieveassignedips.java
create mode 100644 examples/ips/retrieveipsinpool.java
create mode 100644 examples/ips/retrieveipsinwarmup.java
create mode 100644 examples/ips/retrievepoolsforip.java
create mode 100644 examples/ips/retrievewarmupstatus.java
create mode 100644 examples/ips/updatepoolname.java
diff --git a/examples/ips/README.md b/examples/ips/README.md
new file mode 100644
index 00000000..e4358848
--- /dev/null
+++ b/examples/ips/README.md
@@ -0,0 +1,5 @@
+
+
+This folder contains various examples on using the IPs endpoint of SendGrid with Java:
+
+* [Retrieve all IP addresses (GET /ips)](retrieveallips.java)
\ No newline at end of file
diff --git a/examples/ips/RetrieveAllIPs.java b/examples/ips/RetrieveAllIPs.java
new file mode 100644
index 00000000..14845939
--- /dev/null
+++ b/examples/ips/RetrieveAllIPs.java
@@ -0,0 +1,34 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IP addresses
+// GET /ips
+
+
+public class RetrieveAllIPs {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips");
+ request.addQueryParam("subuser", "test_string");
+ request.addQueryParam("ip", "test_string");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("exclude_whitelabels", "true");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/addiptowarmup.java b/examples/ips/addiptowarmup.java
new file mode 100644
index 00000000..89ebaad1
--- /dev/null
+++ b/examples/ips/addiptowarmup.java
@@ -0,0 +1,33 @@
+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;
+
+
+
+//////////////////////////////////////////////////////////////////
+// Add an IP to warmup
+// POST /ips/warmup
+
+
+public class AddIPToWarmup {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("ips/warmup");
+ request.setBody("{\"ip\":\"0.0.0.0\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/addtopool.java b/examples/ips/addtopool.java
new file mode 100644
index 00000000..01e6b16b
--- /dev/null
+++ b/examples/ips/addtopool.java
@@ -0,0 +1,32 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Add an IP address to a pool
+// POST /ips/pools/{pool_name}/ips
+
+
+public class AddIPToPool {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("ips/pools/{pool_name}/ips");
+ request.setBody("{\"ip\":\"0.0.0.0\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/createpool.java b/examples/ips/createpool.java
new file mode 100644
index 00000000..c91d82f0
--- /dev/null
+++ b/examples/ips/createpool.java
@@ -0,0 +1,32 @@
+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 an IP pool.
+// POST /ips/pools
+
+
+public class CreateIPPool {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("ips/pools");
+ request.setBody("{\"name\":\"marketing\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/deletepool.java b/examples/ips/deletepool.java
new file mode 100644
index 00000000..51c50249
--- /dev/null
+++ b/examples/ips/deletepool.java
@@ -0,0 +1,31 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Delete an IP pool.
+// DELETE /ips/pools/{pool_name}
+
+
+public class DeletePool {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("ips/pools/{pool_name}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/ips.java b/examples/ips/ips.java
deleted file mode 100644
index 55c97644..00000000
--- a/examples/ips/ips.java
+++ /dev/null
@@ -1,326 +0,0 @@
-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;
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IP addresses
-// GET /ips
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips");
- request.addQueryParam("subuser", "test_string");
- request.addQueryParam("ip", "test_string");
- request.addQueryParam("limit", "1");
- request.addQueryParam("exclude_whitelabels", "true");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all assigned IPs
-// GET /ips/assigned
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/assigned");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create an IP pool.
-// POST /ips/pools
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("ips/pools");
- request.setBody("{\"name\":\"marketing\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IP pools.
-// GET /ips/pools
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/pools");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update an IP pools name.
-// PUT /ips/pools/{pool_name}
-
-
-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.setMethod(Method.PUT);
- request.setEndpoint("ips/pools/{pool_name}");
- request.setBody("{\"name\":\"new_pool_name\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IPs in a specified pool.
-// GET /ips/pools/{pool_name}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/pools/{pool_name}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete an IP pool.
-// DELETE /ips/pools/{pool_name}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("ips/pools/{pool_name}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add an IP address to a pool
-// POST /ips/pools/{pool_name}/ips
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("ips/pools/{pool_name}/ips");
- request.setBody("{\"ip\":\"0.0.0.0\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Remove an IP address from a pool.
-// DELETE /ips/pools/{pool_name}/ips/{ip}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("ips/pools/{pool_name}/ips/{ip}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add an IP to warmup
-// POST /ips/warmup
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("ips/warmup");
- request.setBody("{\"ip\":\"0.0.0.0\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IPs currently in warmup
-// GET /ips/warmup
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/warmup");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve warmup status for a specific IP address
-// GET /ips/warmup/{ip_address}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/warmup/{ip_address}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Remove an IP from warmup
-// DELETE /ips/warmup/{ip_address}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("ips/warmup/{ip_address}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all IP pools an IP address belongs to
-// GET /ips/{ip_address}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("ips/{ip_address}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
diff --git a/examples/ips/removefromwarmup.java b/examples/ips/removefromwarmup.java
new file mode 100644
index 00000000..b99229de
--- /dev/null
+++ b/examples/ips/removefromwarmup.java
@@ -0,0 +1,32 @@
+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;
+
+
+
+//////////////////////////////////////////////////////////////////
+// Remove an IP from warmup
+// DELETE /ips/warmup/{ip_address}
+
+
+public class RemoveFromWarmup {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("ips/warmup/{ip_address}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/removeipfrompool.java b/examples/ips/removeipfrompool.java
new file mode 100644
index 00000000..ceb5f2be
--- /dev/null
+++ b/examples/ips/removeipfrompool.java
@@ -0,0 +1,31 @@
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+
+//////////////////////////////////////////////////////////////////
+// Remove an IP address from a pool.
+// DELETE /ips/pools/{pool_name}/ips/{ip}
+
+
+public class RemoveIPFromPool {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("ips/pools/{pool_name}/ips/{ip}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/retrieveallpools.java b/examples/ips/retrieveallpools.java
new file mode 100644
index 00000000..a4362ce0
--- /dev/null
+++ b/examples/ips/retrieveallpools.java
@@ -0,0 +1,30 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IP pools.
+// GET /ips/pools
+
+
+public class RetieveAllIPPools {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/pools");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
\ No newline at end of file
diff --git a/examples/ips/retrieveassignedips.java b/examples/ips/retrieveassignedips.java
new file mode 100644
index 00000000..968834cc
--- /dev/null
+++ b/examples/ips/retrieveassignedips.java
@@ -0,0 +1,31 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all assigned IPs
+// GET /ips/assigned
+
+
+public class RetrieveAllAssignedIPs {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/assigned");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/retrieveipsinpool.java b/examples/ips/retrieveipsinpool.java
new file mode 100644
index 00000000..72330c3f
--- /dev/null
+++ b/examples/ips/retrieveipsinpool.java
@@ -0,0 +1,31 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IPs in a specified pool.
+// GET /ips/pools/{pool_name}
+
+
+public class RetrieveIPsInPool {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/pools/{pool_name}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/retrieveipsinwarmup.java b/examples/ips/retrieveipsinwarmup.java
new file mode 100644
index 00000000..3767656b
--- /dev/null
+++ b/examples/ips/retrieveipsinwarmup.java
@@ -0,0 +1,32 @@
+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;
+
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IPs currently in warmup
+// GET /ips/warmup
+
+
+public class RetrieveIPsInWarmup {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/warmup");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/retrievepoolsforip.java b/examples/ips/retrievepoolsforip.java
new file mode 100644
index 00000000..8f19b7a7
--- /dev/null
+++ b/examples/ips/retrievepoolsforip.java
@@ -0,0 +1,33 @@
+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;
+
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all IP pools an IP address belongs to
+// GET /ips/{ip_address}
+
+
+public class RetrieveAllPoolsForIP {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/{ip_address}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+
diff --git a/examples/ips/retrievewarmupstatus.java b/examples/ips/retrievewarmupstatus.java
new file mode 100644
index 00000000..5d315b8f
--- /dev/null
+++ b/examples/ips/retrievewarmupstatus.java
@@ -0,0 +1,32 @@
+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;
+
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve warmup status for a specific IP address
+// GET /ips/warmup/{ip_address}
+
+
+public class RetrieveIPsWarmupStatus {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("ips/warmup/{ip_address}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/ips/updatepoolname.java b/examples/ips/updatepoolname.java
new file mode 100644
index 00000000..4e9c2a26
--- /dev/null
+++ b/examples/ips/updatepoolname.java
@@ -0,0 +1,32 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Update an IP pools name.
+// PUT /ips/pools/{pool_name}
+
+
+public class UpdateIPPoolName {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PUT);
+ request.setEndpoint("ips/pools/{pool_name}");
+ request.setBody("{\"name\":\"new_pool_name\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
From b02c534f777854baf9ba57ca3f7fa8c2412dea13 Mon Sep 17 00:00:00 2001
From: "Julian J. Maurer"
Date: Sat, 28 Oct 2017 16:54:13 +0200
Subject: [PATCH 077/345] Added README.md
---
examples/ips/README.md | 15 ++++++++++++++-
.../ips/{addiptowarmup.java => addtowarmup.java} | 0
...{removeipfrompool.java => removefrompool.java} | 0
.../{RetrieveAllIPs.java => retrieveallips.java} | 0
4 files changed, 14 insertions(+), 1 deletion(-)
rename examples/ips/{addiptowarmup.java => addtowarmup.java} (100%)
rename examples/ips/{removeipfrompool.java => removefrompool.java} (100%)
rename examples/ips/{RetrieveAllIPs.java => retrieveallips.java} (100%)
diff --git a/examples/ips/README.md b/examples/ips/README.md
index e4358848..f8a9780b 100644
--- a/examples/ips/README.md
+++ b/examples/ips/README.md
@@ -2,4 +2,17 @@
This folder contains various examples on using the IPs endpoint of SendGrid with Java:
-* [Retrieve all IP addresses (GET /ips)](retrieveallips.java)
\ No newline at end of file
+* [Retrieve all IP addresses (GET /ips)](retrieveallips.java)
+* [Retrieve all assigned IPs (GET /ips/assigned)](retrieveassignedips.java)
+* [Create an IP pool (POST /ips/pools)](createpool.java)
+* [Retrieve all IP pools (GET /ips/pools)](retrieveallpools.java)
+* [Update an IP pools name (PUT /ips/pools/{pool_name})](updatepoolname.java)
+* [Retrieve all IPs in a specified pool (GET /ips/pools/{pool_name})](retrieveipsinpool.java)
+* [Delete an IP pool. (DELETE /ips/pools/{pool_name})](deletepool.java)
+* [Add an IP address to a pool (POST /ips/pools/{pool_name}/ips)](addtopool.java)
+* [Remove an IP address from a pool (DELETE /ips/pools/{pool_name}/ips/{ip}](removefrompool.java)
+* [Add an IP to warmup (POST /ips/warmup)](addtowarmup.java)
+* [Retrieve all IPs currently in warmup (GET /ips/warmup)](retrieveipsinwarmup.java)
+* [Retrieve warmup status for a specific IP address (GET /ips/warmup/{ip_address})](retrievewarmupstatus.java)
+* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](removefromwarmup.java)
+* [Retrieve all IP pools an IP address belongs to (GET /ips/{ip_address})](retrievepoolsforip.java)
\ No newline at end of file
diff --git a/examples/ips/addiptowarmup.java b/examples/ips/addtowarmup.java
similarity index 100%
rename from examples/ips/addiptowarmup.java
rename to examples/ips/addtowarmup.java
diff --git a/examples/ips/removeipfrompool.java b/examples/ips/removefrompool.java
similarity index 100%
rename from examples/ips/removeipfrompool.java
rename to examples/ips/removefrompool.java
diff --git a/examples/ips/RetrieveAllIPs.java b/examples/ips/retrieveallips.java
similarity index 100%
rename from examples/ips/RetrieveAllIPs.java
rename to examples/ips/retrieveallips.java
From b845405921903e45bcc884367ed6fa3da2ac8731 Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sat, 28 Oct 2017 18:56:10 +0300
Subject: [PATCH 078/345] update LICENSE - fix year
---
LICENSE.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LICENSE.txt b/LICENSE.txt
index 3e9812c6..84a49643 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2013-2016 SendGrid
+Copyright (c) 2013-2017 SendGrid
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
From 6a32211f480cd91ccd314c93fc0f32c91409a568 Mon Sep 17 00:00:00 2001
From: Julian Jacques Maurer
Date: Sat, 28 Oct 2017 19:48:18 +0200
Subject: [PATCH 079/345] Changed file names
Made the file names more readable
---
.../ips/{addtopool.java => AddToPool.java} | 0
.../{addtowarmup.java => AddToWarmup.java} | 0
.../ips/{createpool.java => CreatePool.java} | 0
.../ips/{deletepool.java => DeletePool.java} | 0
examples/ips/README.md | 28 +++++++++----------
...emovefrompool.java => RemoveFromPool.java} | 0
...efromwarmup.java => RemoveFromWarmup.java} | 0
...etrieveallips.java => RetrieveAllIPs.java} | 0
...eveallpools.java => RetrieveAllPools.java} | 0
...ignedips.java => RetrieveAssignedIPs.java} | 0
...eipsinpool.java => RetrieveIPsInPool.java} | 0
...inwarmup.java => RetrieveIPsInWarmup.java} | 0
...oolsforip.java => RetrievePoolsForIP.java} | 0
...pstatus.java => RetrieveWarmupStatus.java} | 0
...pdatepoolname.java => UpdatePoolName.java} | 0
15 files changed, 14 insertions(+), 14 deletions(-)
rename examples/ips/{addtopool.java => AddToPool.java} (100%)
rename examples/ips/{addtowarmup.java => AddToWarmup.java} (100%)
rename examples/ips/{createpool.java => CreatePool.java} (100%)
rename examples/ips/{deletepool.java => DeletePool.java} (100%)
rename examples/ips/{removefrompool.java => RemoveFromPool.java} (100%)
rename examples/ips/{removefromwarmup.java => RemoveFromWarmup.java} (100%)
rename examples/ips/{retrieveallips.java => RetrieveAllIPs.java} (100%)
rename examples/ips/{retrieveallpools.java => RetrieveAllPools.java} (100%)
rename examples/ips/{retrieveassignedips.java => RetrieveAssignedIPs.java} (100%)
rename examples/ips/{retrieveipsinpool.java => RetrieveIPsInPool.java} (100%)
rename examples/ips/{retrieveipsinwarmup.java => RetrieveIPsInWarmup.java} (100%)
rename examples/ips/{retrievepoolsforip.java => RetrievePoolsForIP.java} (100%)
rename examples/ips/{retrievewarmupstatus.java => RetrieveWarmupStatus.java} (100%)
rename examples/ips/{updatepoolname.java => UpdatePoolName.java} (100%)
diff --git a/examples/ips/addtopool.java b/examples/ips/AddToPool.java
similarity index 100%
rename from examples/ips/addtopool.java
rename to examples/ips/AddToPool.java
diff --git a/examples/ips/addtowarmup.java b/examples/ips/AddToWarmup.java
similarity index 100%
rename from examples/ips/addtowarmup.java
rename to examples/ips/AddToWarmup.java
diff --git a/examples/ips/createpool.java b/examples/ips/CreatePool.java
similarity index 100%
rename from examples/ips/createpool.java
rename to examples/ips/CreatePool.java
diff --git a/examples/ips/deletepool.java b/examples/ips/DeletePool.java
similarity index 100%
rename from examples/ips/deletepool.java
rename to examples/ips/DeletePool.java
diff --git a/examples/ips/README.md b/examples/ips/README.md
index f8a9780b..6b558ce2 100644
--- a/examples/ips/README.md
+++ b/examples/ips/README.md
@@ -2,17 +2,17 @@
This folder contains various examples on using the IPs endpoint of SendGrid with Java:
-* [Retrieve all IP addresses (GET /ips)](retrieveallips.java)
-* [Retrieve all assigned IPs (GET /ips/assigned)](retrieveassignedips.java)
-* [Create an IP pool (POST /ips/pools)](createpool.java)
-* [Retrieve all IP pools (GET /ips/pools)](retrieveallpools.java)
-* [Update an IP pools name (PUT /ips/pools/{pool_name})](updatepoolname.java)
-* [Retrieve all IPs in a specified pool (GET /ips/pools/{pool_name})](retrieveipsinpool.java)
-* [Delete an IP pool. (DELETE /ips/pools/{pool_name})](deletepool.java)
-* [Add an IP address to a pool (POST /ips/pools/{pool_name}/ips)](addtopool.java)
-* [Remove an IP address from a pool (DELETE /ips/pools/{pool_name}/ips/{ip}](removefrompool.java)
-* [Add an IP to warmup (POST /ips/warmup)](addtowarmup.java)
-* [Retrieve all IPs currently in warmup (GET /ips/warmup)](retrieveipsinwarmup.java)
-* [Retrieve warmup status for a specific IP address (GET /ips/warmup/{ip_address})](retrievewarmupstatus.java)
-* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](removefromwarmup.java)
-* [Retrieve all IP pools an IP address belongs to (GET /ips/{ip_address})](retrievepoolsforip.java)
\ No newline at end of file
+* [Retrieve all IP addresses (GET /ips)](RetrieveAllIPs.java)
+* [Retrieve all assigned IPs (GET /ips/assigned)](RetrieveAssignedIPs.java)
+* [Create an IP pool (POST /ips/pools)](CreatePool.java)
+* [Retrieve all IP pools (GET /ips/pools)](RetrieveAllPools.java)
+* [Update an IP pools name (PUT /ips/pools/{pool_name})](UpdatePoolName.java)
+* [Retrieve all IPs in a specified pool (GET /ips/pools/{pool_name})](RetrieveIPsInPool.java)
+* [Delete an IP pool. (DELETE /ips/pools/{pool_name})](DeletePool.java)
+* [Add an IP address to a pool (POST /ips/pools/{pool_name}/ips)](AddToPool.java)
+* [Remove an IP address from a pool (DELETE /ips/pools/{pool_name}/ips/{ip}](RemoveFromPool.java)
+* [Add an IP to warmup (POST /ips/warmup)](AddToWarmup.java)
+* [Retrieve all IPs currently in warmup (GET /ips/warmup)](RetrieveIPsInWarmup.java)
+* [Retrieve warmup status for a specific IP address (GET /ips/warmup/{ip_address})](RetrieveWarmupStatus.java)
+* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](RemoveFromwarmup.java)
+* [Retrieve all IP pools an IP address belongs to (GET /ips/{ip_address})](RetrievePoolsForIP.java)
\ No newline at end of file
diff --git a/examples/ips/removefrompool.java b/examples/ips/RemoveFromPool.java
similarity index 100%
rename from examples/ips/removefrompool.java
rename to examples/ips/RemoveFromPool.java
diff --git a/examples/ips/removefromwarmup.java b/examples/ips/RemoveFromWarmup.java
similarity index 100%
rename from examples/ips/removefromwarmup.java
rename to examples/ips/RemoveFromWarmup.java
diff --git a/examples/ips/retrieveallips.java b/examples/ips/RetrieveAllIPs.java
similarity index 100%
rename from examples/ips/retrieveallips.java
rename to examples/ips/RetrieveAllIPs.java
diff --git a/examples/ips/retrieveallpools.java b/examples/ips/RetrieveAllPools.java
similarity index 100%
rename from examples/ips/retrieveallpools.java
rename to examples/ips/RetrieveAllPools.java
diff --git a/examples/ips/retrieveassignedips.java b/examples/ips/RetrieveAssignedIPs.java
similarity index 100%
rename from examples/ips/retrieveassignedips.java
rename to examples/ips/RetrieveAssignedIPs.java
diff --git a/examples/ips/retrieveipsinpool.java b/examples/ips/RetrieveIPsInPool.java
similarity index 100%
rename from examples/ips/retrieveipsinpool.java
rename to examples/ips/RetrieveIPsInPool.java
diff --git a/examples/ips/retrieveipsinwarmup.java b/examples/ips/RetrieveIPsInWarmup.java
similarity index 100%
rename from examples/ips/retrieveipsinwarmup.java
rename to examples/ips/RetrieveIPsInWarmup.java
diff --git a/examples/ips/retrievepoolsforip.java b/examples/ips/RetrievePoolsForIP.java
similarity index 100%
rename from examples/ips/retrievepoolsforip.java
rename to examples/ips/RetrievePoolsForIP.java
diff --git a/examples/ips/retrievewarmupstatus.java b/examples/ips/RetrieveWarmupStatus.java
similarity index 100%
rename from examples/ips/retrievewarmupstatus.java
rename to examples/ips/RetrieveWarmupStatus.java
diff --git a/examples/ips/updatepoolname.java b/examples/ips/UpdatePoolName.java
similarity index 100%
rename from examples/ips/updatepoolname.java
rename to examples/ips/UpdatePoolName.java
From f638e77d117bcd8f09d907835c4834fc6ccc084d Mon Sep 17 00:00:00 2001
From: Julian Jacques Maurer
Date: Sat, 28 Oct 2017 19:50:39 +0200
Subject: [PATCH 080/345] Fixed Typo in README.md
---
examples/ips/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/ips/README.md b/examples/ips/README.md
index 6b558ce2..7ded4310 100644
--- a/examples/ips/README.md
+++ b/examples/ips/README.md
@@ -14,5 +14,5 @@ This folder contains various examples on using the IPs endpoint of SendGrid with
* [Add an IP to warmup (POST /ips/warmup)](AddToWarmup.java)
* [Retrieve all IPs currently in warmup (GET /ips/warmup)](RetrieveIPsInWarmup.java)
* [Retrieve warmup status for a specific IP address (GET /ips/warmup/{ip_address})](RetrieveWarmupStatus.java)
-* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](RemoveFromwarmup.java)
+* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](RemoveFromWarmup.java)
* [Retrieve all IP pools an IP address belongs to (GET /ips/{ip_address})](RetrievePoolsForIP.java)
\ No newline at end of file
From c81edde5517910007403d7154f3ee0ab859f2ae6 Mon Sep 17 00:00:00 2001
From: mptap
Date: Sat, 28 Oct 2017 13:27:46 -0700
Subject: [PATCH 081/345] Added unittest to check for specific repo files
---
.../com/sendgrid/TestRequiredFilesExist.java | 92 +++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 src/test/java/com/sendgrid/TestRequiredFilesExist.java
diff --git a/src/test/java/com/sendgrid/TestRequiredFilesExist.java b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
new file mode 100644
index 00000000..eb044941
--- /dev/null
+++ b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
@@ -0,0 +1,92 @@
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertTrue;
+
+public class TestRequiredFilesExist {
+
+ // ./Docker or docker/Docker
+ @Test public void checkDockerExists() {
+ boolean dockerExists = new File("./Docker").exists() ||
+ new File("./docker/Docker").exists();
+ assertTrue(dockerExists);
+ }
+
+ // ./docker-compose.yml or ./docker/docker-compose.yml
+ @Test public void checkDockerComposeExists() {
+ boolean dockerComposeExists = new File("./docker-compose.yml").exists() ||
+ new File("./docker/docker-compose.yml").exists();
+ assertTrue(dockerComposeExists);
+ }
+
+ // ./.env_sample
+ @Test public void checkEnvSampleExists() {
+ assertTrue(new File("./.env_sample").exists());
+ }
+
+ // ./.gitignore
+ @Test public void checkGitIgnoreExists() {
+ assertTrue(new File("./.gitignore").exists());
+ }
+
+ // ./.travis.yml
+ @Test public void checkTravisExists() {
+ assertTrue(new File("./.travis.yml").exists());
+ }
+
+ // ./.codeclimate.yml
+ @Test public void checkCodeClimateExists() {
+ assertTrue(new File("./.codeclimate.yml").exists());
+ }
+
+ // ./CHANGELOG.md
+ @Test public void checkChangelogExists() {
+ assertTrue(new File("./CHANGELOG.md").exists());
+ }
+
+ // ./CODE_OF_CONDUCT.md
+ @Test public void checkCodeOfConductExists() {
+ assertTrue(new File("./CODE_OF_CONDUCT.md").exists());
+ }
+
+ // ./CONTRIBUTING.md
+ @Test public void checkContributingGuideExists() {
+ assertTrue(new File("./CONTRIBUTING.md").exists());
+ }
+
+ // ./.github/ISSUE_TEMPLATE
+ @Test public void checkIssuesTemplateExists() {
+ assertTrue(new File("./.github/ISSUE_TEMPLATE").exists());
+ }
+
+ // ./LICENSE.md
+ @Test public void checkLicenseExists() {
+ assertTrue(new File("./LICENSE.md").exists());
+ }
+
+ // ./.github/PULL_REQUEST_TEMPLATE
+ @Test public void checkPullRequestExists() {
+ assertTrue(new File("./.github/PULL_REQUEST_TEMPLATE").exists());
+ }
+
+ // ./README.md
+ @Test public void checkReadMeExists() {
+ assertTrue(new File("./README.md").exists());
+ }
+
+ // ./TROUBLESHOOTING.md
+ @Test public void checkTroubleShootingGuideExists() {
+ assertTrue(new File("./TROUBLESHOOTING.md").exists());
+ }
+
+ // ./USAGE.md
+ @Test public void checkUsageGuideExists() {
+ assertTrue(new File("./USAGE.md").exists());
+ }
+
+ // ./USE_CASES.md
+ @Test public void checkUseCases() {
+ assertTrue(new File("./USE_CASES.md").exists());
+ }
+}
From 6380cec03a26ff7dc06dc42a494763f7fa8ff833 Mon Sep 17 00:00:00 2001
From: Matt Bernier
Date: Sat, 28 Oct 2017 17:05:08 -0600
Subject: [PATCH 082/345] Quick and dirty changes to wait for prism
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 4fc4dbee..d3048eb5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,7 @@ matrix:
jdk: oraclejdk8
before_script:
- "./scripts/startPrism.sh &"
-- sleep 10
+- sleep 20
before_install:
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
From dd5ef8c541eda21e7b39da0df494181da39a1efc Mon Sep 17 00:00:00 2001
From: Andy Trimble
Date: Sat, 28 Oct 2017 17:32:05 -0600
Subject: [PATCH 083/345] Updating fix for
https://github.com/travis-ci/travis-ci/issues/5227
---
.travis.yml | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index d3048eb5..8a09eb63 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,14 +14,15 @@ before_script:
- "./scripts/startPrism.sh &"
- sleep 20
before_install:
-- cat /etc/hosts # optionally check the content *before*
-- sudo hostname "$(hostname | cut -c1-63)"
-- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
-- cat /etc/hosts # optionally check the content *after*
+ - cat /etc/hosts # optionally check the content *before*
+ - sudo hostname "$(hostname | cut -c1-63)"
+ - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts
+ - sudo mv /tmp/hosts /etc/hosts
+ - cat /etc/hosts # optionally check the content *after*
after_script:
-- lsof -i :4010 -S # adds some debugging statements
-- "./gradlew build"
-- "./scripts/upload.sh"
+ - lsof -i :4010 -S # adds some debugging statements
+ - "./gradlew build"
+ - "./scripts/upload.sh"
env:
global:
- S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLWphdmEvIl0sCiAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMjA0OCwgMjY4NDM1NDU2XSwKICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJhcHBsaWNhdGlvbi96aXAiXQogIF0KfQo=
From 36a23610bfd722bb2c605e9992ba7849e0a89764 Mon Sep 17 00:00:00 2001
From: Aditya Patil
Date: Sun, 29 Oct 2017 11:23:49 +0530
Subject: [PATCH 084/345] remove sudo: false to make prism work
---
.travis.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 8a09eb63..55ad5ae2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,4 @@
language: java
-sudo: false
matrix:
include:
- os: linux
From 2a716727efecdd5c508d659469c4464dd680e850 Mon Sep 17 00:00:00 2001
From: Aditya Patil
Date: Sun, 29 Oct 2017 11:27:28 +0530
Subject: [PATCH 085/345] update travis.yml to change openjdk7 to openjdk8
---
.travis.yml | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 55ad5ae2..944f6df3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,8 @@
language: java
matrix:
include:
- - os: linux
- dist: precise
- jdk: openjdk7
- - os: linux
- dist: precise
- jdk: oraclejdk7
- - os: linux
- jdk: oraclejdk8
+ - jdk: openjdk8
+ - jdk: oraclejdk8
before_script:
- "./scripts/startPrism.sh &"
- sleep 20
From 06b381efb4a7ea5eef79775e3f3a4650728d109a Mon Sep 17 00:00:00 2001
From: Bhargodev Arya
Date: Sun, 29 Oct 2017 00:30:42 +0530
Subject: [PATCH 086/345] Fix similar-code issue in
examples/accesssettings/accesssettings.java
---
.../accesssettings/CreateAccessSettings.java | 30 ++++
.../accesssettings/DeleteAccessSettings.java | 30 ++++
.../DeleteIPFromAccessSettings.java | 29 ++++
examples/accesssettings/Example.java | 31 ++++
.../accesssettings/GetAccessSettings.java | 30 ++++
.../GetAccessSettingsActivity.java | 33 ++++
.../GetIPFromAccessSettings.java | 30 ++++
examples/accesssettings/README.md | 10 ++
examples/accesssettings/accesssettings.java | 142 ------------------
9 files changed, 223 insertions(+), 142 deletions(-)
create mode 100644 examples/accesssettings/CreateAccessSettings.java
create mode 100644 examples/accesssettings/DeleteAccessSettings.java
create mode 100644 examples/accesssettings/DeleteIPFromAccessSettings.java
create mode 100644 examples/accesssettings/Example.java
create mode 100644 examples/accesssettings/GetAccessSettings.java
create mode 100644 examples/accesssettings/GetAccessSettingsActivity.java
create mode 100644 examples/accesssettings/GetIPFromAccessSettings.java
create mode 100644 examples/accesssettings/README.md
delete mode 100644 examples/accesssettings/accesssettings.java
diff --git a/examples/accesssettings/CreateAccessSettings.java b/examples/accesssettings/CreateAccessSettings.java
new file mode 100644
index 00000000..6c98df1b
--- /dev/null
+++ b/examples/accesssettings/CreateAccessSettings.java
@@ -0,0 +1,30 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/*Add one or more IPs to the whitelist
+POST /access_settings/whitelist
+*/
+
+public class CreateAccessSettings extends Example {
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ips\":[{\"ip\":\"192.168.1.1\"},{\"ip\":\"192.*.*.*\"},{\"ip\":\"192.168.1.3/32\"}]}";
+ Request request = createRequest(Method.POST, endPoint, body);
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ CreateAccessSettings createAccessSettings = new CreateAccessSettings();
+ createAccessSettings.run();
+ }
+}
diff --git a/examples/accesssettings/DeleteAccessSettings.java b/examples/accesssettings/DeleteAccessSettings.java
new file mode 100644
index 00000000..a1abc860
--- /dev/null
+++ b/examples/accesssettings/DeleteAccessSettings.java
@@ -0,0 +1,30 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/* Remove one or more IPs from the whitelist
+ DELETE /access_settings/whitelist
+ */
+
+public class DeleteAccessSettings extends Example {
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ids\":[1,2,3]}";
+ Request request = createRequest(Method.DELETE, endPoint, body);
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ DeleteAccessSettings deleteAccessSettings = new DeleteAccessSettings();
+ deleteAccessSettings.run();
+ }
+}
\ No newline at end of file
diff --git a/examples/accesssettings/DeleteIPFromAccessSettings.java b/examples/accesssettings/DeleteIPFromAccessSettings.java
new file mode 100644
index 00000000..d084c99c
--- /dev/null
+++ b/examples/accesssettings/DeleteIPFromAccessSettings.java
@@ -0,0 +1,29 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/*Remove a specific IP from the whitelist
+DELETE /access_settings/whitelist/{rule_id}
+*/
+
+public class DeleteIPFromAccessSettings extends Example {
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ids\":[1,2,3]}";
+ Request request = createRequest(Method.DELETE, endPoint, body);
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ DeleteIPFromAccessSettings deleteIPFromAccessSettings = new DeleteIPFromAccessSettings();
+ deleteIPFromAccessSettings.run();
+}
\ No newline at end of file
diff --git a/examples/accesssettings/Example.java b/examples/accesssettings/Example.java
new file mode 100644
index 00000000..6fd33a36
--- /dev/null
+++ b/examples/accesssettings/Example.java
@@ -0,0 +1,31 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+public class Example {
+
+ protected Request createRequest(Method method, String endPoint, String requestBody) {
+ Request request = new Request();
+ request.setMethod(method);
+ request.setEndpoint(endPoint);
+ if (requestBody != null) {
+ request.setBody(requestBody);
+ }
+ return request;
+ }
+
+ protected Response execute(Request request) throws IOException {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Response response = sg.api(request);
+ return response;
+ }
+
+ protected void printResonseInfo(Response response) {
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ }
+}
\ No newline at end of file
diff --git a/examples/accesssettings/GetAccessSettings.java b/examples/accesssettings/GetAccessSettings.java
new file mode 100644
index 00000000..24beee95
--- /dev/null
+++ b/examples/accesssettings/GetAccessSettings.java
@@ -0,0 +1,30 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/*Retrieve a list of currently whitelisted IPs
+GET /access_settings/whitelist
+*/
+
+public class GetAccessSettings extends Example{
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ids\":[1,2,3]}";
+ Request request = createRequest(Method.DELETE, endPoint, body);
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ GetAccessSettings getAccessSettings = new GetAccessSettings();
+ getAccessSettings.run();
+ }
+}
\ No newline at end of file
diff --git a/examples/accesssettings/GetAccessSettingsActivity.java b/examples/accesssettings/GetAccessSettingsActivity.java
new file mode 100644
index 00000000..5ca02258
--- /dev/null
+++ b/examples/accesssettings/GetAccessSettingsActivity.java
@@ -0,0 +1,33 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/*Retrieve all recent access attempts
+GET /access_settings/activity
+*/
+
+public class GetAccessSettingsActivity extends Example {
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ids\":[1,2,3]}";
+ Request request = createRequest(Method.DELETE, endPoint, body);
+ request.addQueryParam("limit", "1");
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ GetAccessSettingsActivity getAccessSettingsActivity = new GetAccessSettingsActivity();
+ getAccessSettingsActivity.run();
+ }
+}
+
+
diff --git a/examples/accesssettings/GetIPFromAccessSettings.java b/examples/accesssettings/GetIPFromAccessSettings.java
new file mode 100644
index 00000000..456b141c
--- /dev/null
+++ b/examples/accesssettings/GetIPFromAccessSettings.java
@@ -0,0 +1,30 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+/* Retrieve a specific whitelisted IP
+GET /access_settings/whitelist/{rule_id}
+*/
+
+public class GetIPFromAccessSettings extends Example {
+
+ private void run() throws IOException {
+ try {
+ String endPoint = "access_settings/whitelist";
+ String body = "{\"ids\":[1,2,3]}";
+ Request request = createRequest(Method.DELETE, endPoint, body);
+ Response response = execute(request);
+ printResponseInfo(response);
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ GetIPFromAccessSettings getIPFromAccessSettings = new GetIPFromAccessSettings();
+ getIPFromAccessSettings.run();
+ }
+}
\ No newline at end of file
diff --git a/examples/accesssettings/README.md b/examples/accesssettings/README.md
new file mode 100644
index 00000000..05d64211
--- /dev/null
+++ b/examples/accesssettings/README.md
@@ -0,0 +1,10 @@
+
+ +
+ +This folder contains various examples on using the ACCESS_SETTINGS endpoint of SendGrid with Java:
+ +
+ +* [Retrieve a list of currently whitelisted IPs (GET /access_settings/whitelist)](GetAccessSettings.java)
+ +* [Retrieve a specific whitelisted IP (GET /access_settings/whitelist/{rule_id})](GetIPFromAccessSettings.java)
+ +* [Retrieve a list of currently whitelisted IPs (GET /access_settings/whitelist)](GetAccessSettingsActivity.java)
+ +* [Remove a specific IP from the whitelist (DELETE /access_settings/whitelist/{rule_id}](DeleteIPFromAccessSettings.java)
+ +* [Remove one or more IPs from the whitelist (DELETE /access_settings/whitelist)](DeleteAccessSettings.java)
+ +* [Add one or more IPs to the whitelist (POST /access_settings/whitelist)](CreateAccessSettings.java)
\ No newline at end of file
diff --git a/examples/accesssettings/accesssettings.java b/examples/accesssettings/accesssettings.java
deleted file mode 100644
index 5008bafd..00000000
--- a/examples/accesssettings/accesssettings.java
+++ /dev/null
@@ -1,142 +0,0 @@
-import com.sendgrid.Method;
-import com.sendgrid.Request;
-import com.sendgrid.Response;
-import com.sendgrid.SendGrid;
-
-import java.io.IOException;
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all recent access attempts
-// GET /access_settings/activity
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("access_settings/activity");
- request.addQueryParam("limit", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Add one or more IPs to the whitelist
-// POST /access_settings/whitelist
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("access_settings/whitelist");
- request.setBody("{\"ips\":[{\"ip\":\"192.168.1.1\"},{\"ip\":\"192.*.*.*\"},{\"ip\":\"192.168.1.3/32\"}]}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a list of currently whitelisted IPs
-// GET /access_settings/whitelist
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("access_settings/whitelist");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Remove one or more IPs from the whitelist
-// DELETE /access_settings/whitelist
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("access_settings/whitelist");
- request.setBody("{\"ids\":[1,2,3]}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a specific whitelisted IP
-// GET /access_settings/whitelist/{rule_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.setMethod(Method.GET);
- request.setEndpoint("access_settings/whitelist/{rule_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Remove a specific IP from the whitelist
-// DELETE /access_settings/whitelist/{rule_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.setMethod(Method.DELETE);
- request.setEndpoint("access_settings/whitelist/{rule_id}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
From c9e948a8ad1e792721f5f456278042dc255d3a0e Mon Sep 17 00:00:00 2001
From: Mithun Sasidharan
Date: Sun, 29 Oct 2017 19:52:56 +0530
Subject: [PATCH 087/345] Fix file_lines issue in
examples/mailsettings/mailsettings.java
---
.../GetAddressWhitelistMailSettings.java | 28 ++
examples/mailsettings/GetAllMailSettings.java | 30 ++
examples/mailsettings/GetBCCMailSettings.java | 28 ++
.../GetBouncePurgeMailSettings.java | 28 ++
.../mailsettings/GetFooterMailSettings.java | 31 ++
.../GetForwardBounceMailSettings.java | 31 ++
.../GetForwardSpamMailSettings.java | 28 ++
.../GetPlainContentMailSettings.java | 28 ++
.../GetSpamCheckMailSettings.java | 28 ++
.../mailsettings/GetTemplateMailSettings.java | 28 ++
examples/mailsettings/README.md | 23 +
.../mailsettings/UpdateAddressWhitelist.java | 29 ++
.../mailsettings/UpdateBCCMailSettings.java | 29 ++
.../UpdateBouncePurgeMailSettings.java | 29 ++
.../UpdateFooterMailSettings.java | 29 ++
.../UpdateForwardBounceMailSettings.java | 29 ++
.../UpdateForwardSpamMailSettings.java | 29 ++
.../UpdatePlainContentMailSettings.java | 29 ++
.../UpdateSpamCheckMailSettings.java | 29 ++
.../UpdateTemplateMailSettings.java | 29 ++
examples/mailsettings/mailsettings.java | 438 ------------------
21 files changed, 572 insertions(+), 438 deletions(-)
create mode 100644 examples/mailsettings/GetAddressWhitelistMailSettings.java
create mode 100644 examples/mailsettings/GetAllMailSettings.java
create mode 100644 examples/mailsettings/GetBCCMailSettings.java
create mode 100644 examples/mailsettings/GetBouncePurgeMailSettings.java
create mode 100644 examples/mailsettings/GetFooterMailSettings.java
create mode 100644 examples/mailsettings/GetForwardBounceMailSettings.java
create mode 100644 examples/mailsettings/GetForwardSpamMailSettings.java
create mode 100644 examples/mailsettings/GetPlainContentMailSettings.java
create mode 100644 examples/mailsettings/GetSpamCheckMailSettings.java
create mode 100644 examples/mailsettings/GetTemplateMailSettings.java
create mode 100644 examples/mailsettings/README.md
create mode 100644 examples/mailsettings/UpdateAddressWhitelist.java
create mode 100644 examples/mailsettings/UpdateBCCMailSettings.java
create mode 100644 examples/mailsettings/UpdateBouncePurgeMailSettings.java
create mode 100644 examples/mailsettings/UpdateFooterMailSettings.java
create mode 100644 examples/mailsettings/UpdateForwardBounceMailSettings.java
create mode 100644 examples/mailsettings/UpdateForwardSpamMailSettings.java
create mode 100644 examples/mailsettings/UpdatePlainContentMailSettings.java
create mode 100644 examples/mailsettings/UpdateSpamCheckMailSettings.java
create mode 100644 examples/mailsettings/UpdateTemplateMailSettings.java
delete mode 100644 examples/mailsettings/mailsettings.java
diff --git a/examples/mailsettings/GetAddressWhitelistMailSettings.java b/examples/mailsettings/GetAddressWhitelistMailSettings.java
new file mode 100644
index 00000000..fdc81c1b
--- /dev/null
+++ b/examples/mailsettings/GetAddressWhitelistMailSettings.java
@@ -0,0 +1,28 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve address whitelist mail settings
+// GET /mail_settings/address_whitelist
+
+
+public class GetAddressWhitelistMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/address_whitelist");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetAllMailSettings.java b/examples/mailsettings/GetAllMailSettings.java
new file mode 100644
index 00000000..e85b6e48
--- /dev/null
+++ b/examples/mailsettings/GetAllMailSettings.java
@@ -0,0 +1,30 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all mail settings
+// GET /mail_settings
+
+
+public class GetAllMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/mailsettings/GetBCCMailSettings.java b/examples/mailsettings/GetBCCMailSettings.java
new file mode 100644
index 00000000..90ab31d9
--- /dev/null
+++ b/examples/mailsettings/GetBCCMailSettings.java
@@ -0,0 +1,28 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all BCC mail settings
+// GET /mail_settings/bcc
+
+
+public class GetBCCMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/bcc");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetBouncePurgeMailSettings.java b/examples/mailsettings/GetBouncePurgeMailSettings.java
new file mode 100644
index 00000000..2f390764
--- /dev/null
+++ b/examples/mailsettings/GetBouncePurgeMailSettings.java
@@ -0,0 +1,28 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve bounce purge mail settings
+// GET /mail_settings/bounce_purge
+
+
+public class GetBouncePurgeMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/bounce_purge");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetFooterMailSettings.java b/examples/mailsettings/GetFooterMailSettings.java
new file mode 100644
index 00000000..bea04d0b
--- /dev/null
+++ b/examples/mailsettings/GetFooterMailSettings.java
@@ -0,0 +1,31 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve footer mail settings
+// GET /mail_settings/footer
+
+
+public class GetFooterMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/footer");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetForwardBounceMailSettings.java b/examples/mailsettings/GetForwardBounceMailSettings.java
new file mode 100644
index 00000000..33331585
--- /dev/null
+++ b/examples/mailsettings/GetForwardBounceMailSettings.java
@@ -0,0 +1,31 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve forward bounce mail settings
+// GET /mail_settings/forward_bounce
+
+
+public class GetForwardBounceMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/forward_bounce");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetForwardSpamMailSettings.java b/examples/mailsettings/GetForwardSpamMailSettings.java
new file mode 100644
index 00000000..0b890294
--- /dev/null
+++ b/examples/mailsettings/GetForwardSpamMailSettings.java
@@ -0,0 +1,28 @@
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+import java.io.IOException;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve forward spam mail settings
+// GET /mail_settings/forward_spam
+
+
+public class GetForwardSpamMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/forward_spam");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetPlainContentMailSettings.java b/examples/mailsettings/GetPlainContentMailSettings.java
new file mode 100644
index 00000000..38f7cfe4
--- /dev/null
+++ b/examples/mailsettings/GetPlainContentMailSettings.java
@@ -0,0 +1,28 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve plain content mail settings
+// GET /mail_settings/plain_content
+
+
+public class GetPlainContentMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/plain_content");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetSpamCheckMailSettings.java b/examples/mailsettings/GetSpamCheckMailSettings.java
new file mode 100644
index 00000000..9460cac0
--- /dev/null
+++ b/examples/mailsettings/GetSpamCheckMailSettings.java
@@ -0,0 +1,28 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve spam check mail settings
+// GET /mail_settings/spam_check
+
+
+public class GetSpamCheckMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/spam_check");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/GetTemplateMailSettings.java b/examples/mailsettings/GetTemplateMailSettings.java
new file mode 100644
index 00000000..8b648be4
--- /dev/null
+++ b/examples/mailsettings/GetTemplateMailSettings.java
@@ -0,0 +1,28 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve legacy template mail settings
+// GET /mail_settings/template
+
+
+public class GetTemplateMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("mail_settings/template");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/README.md b/examples/mailsettings/README.md
new file mode 100644
index 00000000..34e83317
--- /dev/null
+++ b/examples/mailsettings/README.md
@@ -0,0 +1,23 @@
+
+
+This folder contains various examples on using the Mail Settings endpoint of SendGrid with Java:
+
+* [Retrieve all mail settings (GET /mail_settings)](GetAllMailSettings.java)
+* [Retrieve address whitelist mail settings (GET /mail_settings/address_whitelist)](GetAddressWhitelistMailSettings.java)
+* [Retrieve all BCC mail settings (GET /mail_settings/bcc)](GetBCCMailSettings.java)
+* [Retrieve bounce purge mail settings (GET /mail_settings/bounce_purge)](GetBouncePurgeMailSettings.java)
+* [Retrieve footer mail settings (GET /mail_settings/footer)](GetFooterMailSettings.java)
+* [Retrieve forward bounce mail settings (GET /mail_settings/forward_bounce)](GetForwardBounceMailSettings.java)
+* [Retrieve forward spam mail settings (GET /mail_settings/forward_spam)](GetForwardSpamMailSettings.java)
+* [Retrieve plain content mail settings (GET /mail_settings/plain_content)](GetPlainContentMailSettings.java)
+* [Retrieve spam check mail settings (GET /mail_settings/spam_check)](GetSpamCheckMailSettings.java)
+* [Retrieve legacy template mail settings (GET /mail_settings/template)](GetTemplateMailSettings.java)
+* [Update address whitelist mail settings (PATCH /mail_settings/address_whitelist)](UpdateAddressWhitelist.java)
+* [Update BCC mail settings (PATCH /mail_settings/bcc)](UpdateBCCMailSettings.java)
+* [Update bounce purge mail settings (PATCH /mail_settings/bounce_purge)](UpdateBouncePurgeMailSettings.java)
+* [Update footer mail settings (PATCH /mail_settings/footer)](UpdateFooterMailSettings.java)
+* [Update forward bounce mail settings (PATCH /mail_settings/forward_bounce)](UpdateForwardBounceMailSettings.java)
+* [Update forward spam mail settings (PATCH /mail_settings/forward_spam)](UpdateForwardSpamMailSettings.java)
+* [Update plain content mail settings (PATCH /mail_settings/plain_content)](UpdatePlainContentMailSettings.java)
+* [Update spam check mail settings (PATCH /mail_settings/spam_check)](UpdateSpamCheckMailSettings.java)
+* [Update template mail settings (PATCH /mail_settings/template)](UpdateTemplateMailSettings.java)
diff --git a/examples/mailsettings/UpdateAddressWhitelist.java b/examples/mailsettings/UpdateAddressWhitelist.java
new file mode 100644
index 00000000..db58c282
--- /dev/null
+++ b/examples/mailsettings/UpdateAddressWhitelist.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update address whitelist mail settings
+// PATCH /mail_settings/address_whitelist
+
+
+public class UpdateAddressWhitelist {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/address_whitelist");
+ request.setBody("{\"list\":[\"email1@example.com\",\"example.com\"],\"enabled\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateBCCMailSettings.java b/examples/mailsettings/UpdateBCCMailSettings.java
new file mode 100644
index 00000000..33faba1a
--- /dev/null
+++ b/examples/mailsettings/UpdateBCCMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update BCC mail settings
+// PATCH /mail_settings/bcc
+
+
+public class UpdateBCCMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/bcc");
+ request.setBody("{\"enabled\":false,\"email\":\"email@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateBouncePurgeMailSettings.java b/examples/mailsettings/UpdateBouncePurgeMailSettings.java
new file mode 100644
index 00000000..83a53e10
--- /dev/null
+++ b/examples/mailsettings/UpdateBouncePurgeMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update bounce purge mail settings
+// PATCH /mail_settings/bounce_purge
+
+
+public class UpdateBouncePurgeMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/bounce_purge");
+ request.setBody("{\"hard_bounces\":5,\"soft_bounces\":5,\"enabled\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateFooterMailSettings.java b/examples/mailsettings/UpdateFooterMailSettings.java
new file mode 100644
index 00000000..fedf35b0
--- /dev/null
+++ b/examples/mailsettings/UpdateFooterMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update footer mail settings
+// PATCH /mail_settings/footer
+
+
+public class UpdateFooterMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/footer");
+ request.setBody("{\"html_content\":\"...\",\"enabled\":true,\"plain_content\":\"...\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateForwardBounceMailSettings.java b/examples/mailsettings/UpdateForwardBounceMailSettings.java
new file mode 100644
index 00000000..677b94e9
--- /dev/null
+++ b/examples/mailsettings/UpdateForwardBounceMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update forward bounce mail settings
+// PATCH /mail_settings/forward_bounce
+
+
+public class UpdateForwardBounceMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/forward_bounce");
+ request.setBody("{\"enabled\":true,\"email\":\"example@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateForwardSpamMailSettings.java b/examples/mailsettings/UpdateForwardSpamMailSettings.java
new file mode 100644
index 00000000..3b27f353
--- /dev/null
+++ b/examples/mailsettings/UpdateForwardSpamMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update forward spam mail settings
+// PATCH /mail_settings/forward_spam
+
+
+public class UpdateForwardSpamMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/forward_spam");
+ request.setBody("{\"enabled\":false,\"email\":\"\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdatePlainContentMailSettings.java b/examples/mailsettings/UpdatePlainContentMailSettings.java
new file mode 100644
index 00000000..4cb680f5
--- /dev/null
+++ b/examples/mailsettings/UpdatePlainContentMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update plain content mail settings
+// PATCH /mail_settings/plain_content
+
+
+public class UpdatePlainContentMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/plain_content");
+ request.setBody("{\"enabled\":false}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateSpamCheckMailSettings.java b/examples/mailsettings/UpdateSpamCheckMailSettings.java
new file mode 100644
index 00000000..e7cf8dc2
--- /dev/null
+++ b/examples/mailsettings/UpdateSpamCheckMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update spam check mail settings
+// PATCH /mail_settings/spam_check
+
+
+public class UpdateSpamCheckMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/spam_check");
+ request.setBody("{\"url\":\"url\",\"max_score\":5,\"enabled\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/UpdateTemplateMailSettings.java b/examples/mailsettings/UpdateTemplateMailSettings.java
new file mode 100644
index 00000000..57e1b22a
--- /dev/null
+++ b/examples/mailsettings/UpdateTemplateMailSettings.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import com.sendgrid.Method;
+import com.sendgrid.Request;
+import com.sendgrid.Response;
+import com.sendgrid.SendGrid;
+
+//////////////////////////////////////////////////////////////////
+// Update template mail settings
+// PATCH /mail_settings/template
+
+
+public class UpdateTemplateMailSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("mail_settings/template");
+ request.setBody("{\"html_content\":\"<% body %>\",\"enabled\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/mailsettings/mailsettings.java b/examples/mailsettings/mailsettings.java
deleted file mode 100644
index d42ffd2a..00000000
--- a/examples/mailsettings/mailsettings.java
+++ /dev/null
@@ -1,438 +0,0 @@
-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;
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all mail settings
-// GET /mail_settings
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update address whitelist mail settings
-// PATCH /mail_settings/address_whitelist
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/address_whitelist");
- request.setBody("{\"list\":[\"email1@example.com\",\"example.com\"],\"enabled\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve address whitelist mail settings
-// GET /mail_settings/address_whitelist
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/address_whitelist");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update BCC mail settings
-// PATCH /mail_settings/bcc
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/bcc");
- request.setBody("{\"enabled\":false,\"email\":\"email@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all BCC mail settings
-// GET /mail_settings/bcc
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/bcc");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update bounce purge mail settings
-// PATCH /mail_settings/bounce_purge
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/bounce_purge");
- request.setBody("{\"hard_bounces\":5,\"soft_bounces\":5,\"enabled\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve bounce purge mail settings
-// GET /mail_settings/bounce_purge
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/bounce_purge");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update footer mail settings
-// PATCH /mail_settings/footer
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/footer");
- request.setBody("{\"html_content\":\"...\",\"enabled\":true,\"plain_content\":\"...\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve footer mail settings
-// GET /mail_settings/footer
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/footer");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update forward bounce mail settings
-// PATCH /mail_settings/forward_bounce
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/forward_bounce");
- request.setBody("{\"enabled\":true,\"email\":\"example@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve forward bounce mail settings
-// GET /mail_settings/forward_bounce
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/forward_bounce");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update forward spam mail settings
-// PATCH /mail_settings/forward_spam
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/forward_spam");
- request.setBody("{\"enabled\":false,\"email\":\"\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve forward spam mail settings
-// GET /mail_settings/forward_spam
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/forward_spam");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update plain content mail settings
-// PATCH /mail_settings/plain_content
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/plain_content");
- request.setBody("{\"enabled\":false}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve plain content mail settings
-// GET /mail_settings/plain_content
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/plain_content");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update spam check mail settings
-// PATCH /mail_settings/spam_check
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/spam_check");
- request.setBody("{\"url\":\"url\",\"max_score\":5,\"enabled\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve spam check mail settings
-// GET /mail_settings/spam_check
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/spam_check");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update template mail settings
-// PATCH /mail_settings/template
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("mail_settings/template");
- request.setBody("{\"html_content\":\"<% body %>\",\"enabled\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve legacy template mail settings
-// GET /mail_settings/template
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("mail_settings/template");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
From 141848eeb10686efd58f2071048f0dab8918809f Mon Sep 17 00:00:00 2001
From: huy tran
Date: Mon, 30 Oct 2017 18:48:32 +0900
Subject: [PATCH 088/345] Break up the examples in
examples/subusers/subusers.java to their own files
---
examples/subusers/CreateMonitorSettings.java | 31 ++
examples/subusers/CreateSubUser.java | 31 ++
examples/subusers/DeleteMonitorSettings.java | 31 ++
examples/subusers/DeleteSubUser.java | 30 ++
examples/subusers/EnableOrDisableUser.java | 31 ++
examples/subusers/ListAllSubUsers.java | 32 ++
.../subusers/RetrieveEmailStatistics.java | 37 ++
.../subusers/RetrieveMonitorSettings.java | 31 ++
.../RetrieveMonthlyEmailStatistics.java | 36 ++
examples/subusers/RetrieveMonthlyStats.java | 36 ++
.../subusers/RetrieveSubUserReputation.java | 32 ++
.../subusers/RetrieveTotalsForEachEmail.java | 37 ++
examples/subusers/UpdateAssignedIPs.java | 31 ++
examples/subusers/UpdateMonitorSettings.java | 31 ++
examples/subusers/subusers.java | 350 ------------------
15 files changed, 457 insertions(+), 350 deletions(-)
create mode 100644 examples/subusers/CreateMonitorSettings.java
create mode 100644 examples/subusers/CreateSubUser.java
create mode 100644 examples/subusers/DeleteMonitorSettings.java
create mode 100644 examples/subusers/DeleteSubUser.java
create mode 100644 examples/subusers/EnableOrDisableUser.java
create mode 100644 examples/subusers/ListAllSubUsers.java
create mode 100644 examples/subusers/RetrieveEmailStatistics.java
create mode 100644 examples/subusers/RetrieveMonitorSettings.java
create mode 100644 examples/subusers/RetrieveMonthlyEmailStatistics.java
create mode 100644 examples/subusers/RetrieveMonthlyStats.java
create mode 100644 examples/subusers/RetrieveSubUserReputation.java
create mode 100644 examples/subusers/RetrieveTotalsForEachEmail.java
create mode 100644 examples/subusers/UpdateAssignedIPs.java
create mode 100644 examples/subusers/UpdateMonitorSettings.java
delete mode 100644 examples/subusers/subusers.java
diff --git a/examples/subusers/CreateMonitorSettings.java b/examples/subusers/CreateMonitorSettings.java
new file mode 100644
index 00000000..6fecfaff
--- /dev/null
+++ b/examples/subusers/CreateMonitorSettings.java
@@ -0,0 +1,31 @@
+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 monitor settings
+// POST /subusers/{subuser_name}/monitor
+
+
+public class CreateMonitorSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("subusers/{subuser_name}/monitor");
+ request.setBody("{\"frequency\":50000,\"email\":\"example@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/CreateSubUser.java b/examples/subusers/CreateSubUser.java
new file mode 100644
index 00000000..9cb283c8
--- /dev/null
+++ b/examples/subusers/CreateSubUser.java
@@ -0,0 +1,31 @@
+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 Subuser
+// POST /subusers
+
+
+public class CreateSubUser {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.POST);
+ request.setEndpoint("subusers");
+ request.setBody("{\"username\":\"John@example.com\",\"ips\":[\"1.1.1.1\",\"2.2.2.2\"],\"password\":\"johns_password\",\"email\":\"John@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/DeleteMonitorSettings.java b/examples/subusers/DeleteMonitorSettings.java
new file mode 100644
index 00000000..ffcc25c8
--- /dev/null
+++ b/examples/subusers/DeleteMonitorSettings.java
@@ -0,0 +1,31 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Delete monitor settings
+// DELETE /subusers/{subuser_name}/monitor
+
+
+public class DeleteMonitorSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("subusers/{subuser_name}/monitor");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/DeleteSubUser.java b/examples/subusers/DeleteSubUser.java
new file mode 100644
index 00000000..68207edf
--- /dev/null
+++ b/examples/subusers/DeleteSubUser.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete a subuser
+// DELETE /subusers/{subuser_name}
+
+
+public class DeleteSubUser {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("subusers/{subuser_name}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/EnableOrDisableUser.java b/examples/subusers/EnableOrDisableUser.java
new file mode 100644
index 00000000..107b7def
--- /dev/null
+++ b/examples/subusers/EnableOrDisableUser.java
@@ -0,0 +1,31 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Enable/disable a subuser
+// PATCH /subusers/{subuser_name}
+
+
+public class EnableOrDisableUser {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PATCH);
+ request.setEndpoint("subusers/{subuser_name}");
+ request.setBody("{\"disabled\":false}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/ListAllSubUsers.java b/examples/subusers/ListAllSubUsers.java
new file mode 100644
index 00000000..ebc408f3
--- /dev/null
+++ b/examples/subusers/ListAllSubUsers.java
@@ -0,0 +1,32 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// List all Subusers
+// GET /subusers
+
+public class ListAllSubUsers {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers");
+ request.addQueryParam("username", "test_string");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/RetrieveEmailStatistics.java b/examples/subusers/RetrieveEmailStatistics.java
new file mode 100644
index 00000000..479f4f2e
--- /dev/null
+++ b/examples/subusers/RetrieveEmailStatistics.java
@@ -0,0 +1,37 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve email statistics for your subusers.
+// GET /subusers/stats
+
+
+public class RetrieveEmailStatistics {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/stats");
+ request.addQueryParam("end_date", "2016-04-01");
+ request.addQueryParam("aggregated_by", "day");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("offset", "1");
+ request.addQueryParam("start_date", "2016-01-01");
+ request.addQueryParam("subusers", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/subusers/RetrieveMonitorSettings.java b/examples/subusers/RetrieveMonitorSettings.java
new file mode 100644
index 00000000..6d219e2f
--- /dev/null
+++ b/examples/subusers/RetrieveMonitorSettings.java
@@ -0,0 +1,31 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve monitor settings for a subuser
+// GET /subusers/{subuser_name}/monitor
+
+
+public class RetrieveMonitorSettings {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/{subuser_name}/monitor");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/RetrieveMonthlyEmailStatistics.java b/examples/subusers/RetrieveMonthlyEmailStatistics.java
new file mode 100644
index 00000000..b7d1c9b2
--- /dev/null
+++ b/examples/subusers/RetrieveMonthlyEmailStatistics.java
@@ -0,0 +1,36 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve the monthly email statistics for a single subuser
+// GET /subusers/{subuser_name}/stats/monthly
+
+
+public class RetrieveMonthlyEmailStatistics {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/{subuser_name}/stats/monthly");
+ request.addQueryParam("date", "test_string");
+ request.addQueryParam("sort_by_direction", "asc");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("sort_by_metric", "test_string");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/RetrieveMonthlyStats.java b/examples/subusers/RetrieveMonthlyStats.java
new file mode 100644
index 00000000..7310c072
--- /dev/null
+++ b/examples/subusers/RetrieveMonthlyStats.java
@@ -0,0 +1,36 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve monthly stats for all subusers
+// GET /subusers/stats/monthly
+
+
+public class RetrieveMonthlyStats {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/stats/monthly");
+ request.addQueryParam("subuser", "test_string");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("sort_by_metric", "test_string");
+ request.addQueryParam("offset", "1");
+ request.addQueryParam("date", "test_string");
+ request.addQueryParam("sort_by_direction", "asc");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/subusers/RetrieveSubUserReputation.java b/examples/subusers/RetrieveSubUserReputation.java
new file mode 100644
index 00000000..18664ed2
--- /dev/null
+++ b/examples/subusers/RetrieveSubUserReputation.java
@@ -0,0 +1,32 @@
+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;
+
+
+//////////////////////////////////////////////////////////////////
+// Retrieve Subuser Reputations
+// GET /subusers/reputations
+
+
+public class RetrieveSubUserReputation {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/reputations");
+ request.addQueryParam("usernames", "test_string");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
diff --git a/examples/subusers/RetrieveTotalsForEachEmail.java b/examples/subusers/RetrieveTotalsForEachEmail.java
new file mode 100644
index 00000000..de741967
--- /dev/null
+++ b/examples/subusers/RetrieveTotalsForEachEmail.java
@@ -0,0 +1,37 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve the totals for each email statistic metric for all subusers.
+// GET /subusers/stats/sums
+
+
+public class RetrieveTotalsForEachEmail {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("subusers/stats/sums");
+ request.addQueryParam("end_date", "2016-04-01");
+ request.addQueryParam("aggregated_by", "day");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("sort_by_metric", "test_string");
+ request.addQueryParam("offset", "1");
+ request.addQueryParam("start_date", "2016-01-01");
+ request.addQueryParam("sort_by_direction", "asc");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/UpdateAssignedIPs.java b/examples/subusers/UpdateAssignedIPs.java
new file mode 100644
index 00000000..60479769
--- /dev/null
+++ b/examples/subusers/UpdateAssignedIPs.java
@@ -0,0 +1,31 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Update IPs assigned to a subuser
+// PUT /subusers/{subuser_name}/ips
+
+
+public class UpdateAssignedIps {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PUT);
+ request.setEndpoint("subusers/{subuser_name}/ips");
+ request.setBody("[\"127.0.0.1\"]");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/UpdateMonitorSettings.java b/examples/subusers/UpdateMonitorSettings.java
new file mode 100644
index 00000000..81567982
--- /dev/null
+++ b/examples/subusers/UpdateMonitorSettings.java
@@ -0,0 +1,31 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Update Monitor Settings for a subuser
+// PUT /subusers/{subuser_name}/monitor
+
+
+public class UpdateMonitorSetting {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.PUT);
+ request.setEndpoint("subusers/{subuser_name}/monitor");
+ request.setBody("{\"frequency\":500,\"email\":\"example@example.com\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/subusers/subusers.java b/examples/subusers/subusers.java
deleted file mode 100644
index 6959ac8d..00000000
--- a/examples/subusers/subusers.java
+++ /dev/null
@@ -1,350 +0,0 @@
-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 Subuser
-// POST /subusers
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("subusers");
- request.setBody("{\"username\":\"John@example.com\",\"ips\":[\"1.1.1.1\",\"2.2.2.2\"],\"password\":\"johns_password\",\"email\":\"John@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// List all Subusers
-// GET /subusers
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers");
- request.addQueryParam("username", "test_string");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve Subuser Reputations
-// GET /subusers/reputations
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/reputations");
- request.addQueryParam("usernames", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve email statistics for your subusers.
-// GET /subusers/stats
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/stats");
- request.addQueryParam("end_date", "2016-04-01");
- request.addQueryParam("aggregated_by", "day");
- request.addQueryParam("limit", "1");
- request.addQueryParam("offset", "1");
- request.addQueryParam("start_date", "2016-01-01");
- request.addQueryParam("subusers", "test_string");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve monthly stats for all subusers
-// GET /subusers/stats/monthly
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/stats/monthly");
- request.addQueryParam("subuser", "test_string");
- request.addQueryParam("limit", "1");
- request.addQueryParam("sort_by_metric", "test_string");
- request.addQueryParam("offset", "1");
- request.addQueryParam("date", "test_string");
- request.addQueryParam("sort_by_direction", "asc");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve the totals for each email statistic metric for all subusers.
-// GET /subusers/stats/sums
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/stats/sums");
- request.addQueryParam("end_date", "2016-04-01");
- request.addQueryParam("aggregated_by", "day");
- request.addQueryParam("limit", "1");
- request.addQueryParam("sort_by_metric", "test_string");
- request.addQueryParam("offset", "1");
- request.addQueryParam("start_date", "2016-01-01");
- request.addQueryParam("sort_by_direction", "asc");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Enable/disable a subuser
-// PATCH /subusers/{subuser_name}
-
-
-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.setMethod(Method.PATCH);
- request.setEndpoint("subusers/{subuser_name}");
- request.setBody("{\"disabled\":false}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a subuser
-// DELETE /subusers/{subuser_name}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("subusers/{subuser_name}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update IPs assigned to a subuser
-// PUT /subusers/{subuser_name}/ips
-
-
-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.setMethod(Method.PUT);
- request.setEndpoint("subusers/{subuser_name}/ips");
- request.setBody("[\"127.0.0.1\"]");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Update Monitor Settings for a subuser
-// PUT /subusers/{subuser_name}/monitor
-
-
-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.setMethod(Method.PUT);
- request.setEndpoint("subusers/{subuser_name}/monitor");
- request.setBody("{\"frequency\":500,\"email\":\"example@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Create monitor settings
-// POST /subusers/{subuser_name}/monitor
-
-
-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.setMethod(Method.POST);
- request.setEndpoint("subusers/{subuser_name}/monitor");
- request.setBody("{\"frequency\":50000,\"email\":\"example@example.com\"}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve monitor settings for a subuser
-// GET /subusers/{subuser_name}/monitor
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/{subuser_name}/monitor");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete monitor settings
-// DELETE /subusers/{subuser_name}/monitor
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("subusers/{subuser_name}/monitor");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve the monthly email statistics for a single subuser
-// GET /subusers/{subuser_name}/stats/monthly
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("subusers/{subuser_name}/stats/monthly");
- request.addQueryParam("date", "test_string");
- request.addQueryParam("sort_by_direction", "asc");
- request.addQueryParam("limit", "1");
- request.addQueryParam("sort_by_metric", "test_string");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
From 909216982216aa6eaa4ffcf62e50c47b01f8675f Mon Sep 17 00:00:00 2001
From: huy tran
Date: Mon, 30 Oct 2017 19:04:40 +0900
Subject: [PATCH 089/345] Fix "similar-code" issue in
examples/whitelabel/ips.java
---
examples/whitelabel/ips.java | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/examples/whitelabel/ips.java b/examples/whitelabel/ips.java
index 54cb2af3..22836d99 100644
--- a/examples/whitelabel/ips.java
+++ b/examples/whitelabel/ips.java
@@ -7,16 +7,25 @@
import java.util.HashMap;
import java.util.Map;
+public class CommonExample {
+ protected SendGrid sg;
+ protected Request request;
+
+ protected static void init() {
+ this.sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ this.request = new Request();
+ }
+}
+
//////////////////////////////////////////////////////////////////
// Create an IP whitelabel
// POST /whitelabel/ips
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips");
request.setBody("{\"ip\":\"192.168.1.1\",\"domain\":\"example.com\",\"subdomain\":\"email\"}");
@@ -35,11 +44,10 @@ public static void main(String[] args) throws IOException {
// GET /whitelabel/ips
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips");
request.addQueryParam("ip", "test_string");
@@ -60,11 +68,10 @@ public static void main(String[] args) throws IOException {
// GET /whitelabel/ips/{id}
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
@@ -82,11 +89,10 @@ public static void main(String[] args) throws IOException {
// DELETE /whitelabel/ips/{id}
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.DELETE);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
@@ -104,11 +110,10 @@ public static void main(String[] args) throws IOException {
// POST /whitelabel/ips/{id}/validate
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips/{id}/validate");
Response response = sg.api(request);
From fdc7deae55d66e6f2f1027d1591b2bd639bcd66d Mon Sep 17 00:00:00 2001
From: huy tran
Date: Mon, 30 Oct 2017 19:07:02 +0900
Subject: [PATCH 090/345] Fix "similar-code" issue in
examples/whitelabel/ips.java
---
examples/whitelabel/ips.java | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/examples/whitelabel/ips.java b/examples/whitelabel/ips.java
index 54cb2af3..22836d99 100644
--- a/examples/whitelabel/ips.java
+++ b/examples/whitelabel/ips.java
@@ -7,16 +7,25 @@
import java.util.HashMap;
import java.util.Map;
+public class CommonExample {
+ protected SendGrid sg;
+ protected Request request;
+
+ protected static void init() {
+ this.sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ this.request = new Request();
+ }
+}
+
//////////////////////////////////////////////////////////////////
// Create an IP whitelabel
// POST /whitelabel/ips
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips");
request.setBody("{\"ip\":\"192.168.1.1\",\"domain\":\"example.com\",\"subdomain\":\"email\"}");
@@ -35,11 +44,10 @@ public static void main(String[] args) throws IOException {
// GET /whitelabel/ips
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips");
request.addQueryParam("ip", "test_string");
@@ -60,11 +68,10 @@ public static void main(String[] args) throws IOException {
// GET /whitelabel/ips/{id}
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
@@ -82,11 +89,10 @@ public static void main(String[] args) throws IOException {
// DELETE /whitelabel/ips/{id}
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.DELETE);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
@@ -104,11 +110,10 @@ public static void main(String[] args) throws IOException {
// POST /whitelabel/ips/{id}/validate
-public class Example {
+public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
- SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
- Request request = new Request();
+ init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips/{id}/validate");
Response response = sg.api(request);
From 442362733e3c759932d2efc4eab6ce004e490a0e Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Mon, 30 Oct 2017 16:50:50 +0300
Subject: [PATCH 091/345] update github PR template
---
.github/PULL_REQUEST_TEMPLATE | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE
index e4059635..ba377ae7 100644
--- a/.github/PULL_REQUEST_TEMPLATE
+++ b/.github/PULL_REQUEST_TEMPLATE
@@ -1,19 +1,24 @@
-
-Closes: #[Issue number]
+# Fixes #
-**Description of the change**:
+### Checklist
+- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
+- [ ] I have read the [Contribution Guide] and my PR follows them.
+- [ ] I updated my branch with the master branch.
+- [ ] I have added tests that prove my fix is effective or that my feature works
+- [ ] I have added necessary documentation about the functionality in the appropriate .md file
+- [ ] I have added in line documentation to the code I modified
-If you have questions, please send an email [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.
+### Short description of what this PR does:
+-
+-
+If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.
\ No newline at end of file
From 91725bfaf495464bc59602aac6ddb3c8f0595e8c Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sat, 28 Oct 2017 20:59:06 +0300
Subject: [PATCH 092/345] Refactoring suppression examples
---
examples/suppression/DeleteBlocks.java | 30 ++
examples/suppression/DeleteBounce.java | 30 ++
examples/suppression/DeleteBounces.java | 30 ++
examples/suppression/DeleteInvalidEmails.java | 30 ++
examples/suppression/DeleteSpamReports.java | 30 ++
examples/suppression/DeleteSpecificBlock.java | 29 ++
.../DeleteSpecificInvalidEmail.java | 29 ++
.../suppression/DeleteSpecificSpamReport.java | 29 ++
examples/suppression/GetAllBlocks.java | 33 ++
examples/suppression/GetAllBounces.java | 31 ++
.../suppression/GetAllGlobalSuppressions.java | 33 ++
examples/suppression/GetAllInvalidEmails.java | 33 ++
examples/suppression/GetAllSpamReports.java | 33 ++
examples/suppression/GetBounce.java | 29 ++
examples/suppression/GetSpecificBlock.java | 29 ++
.../suppression/GetSpecificInvalidEmail.java | 29 ++
.../suppression/GetSpecificSpamReport.java | 29 ++
examples/suppression/README.md | 21 +
examples/suppression/suppression.java | 406 ------------------
19 files changed, 537 insertions(+), 406 deletions(-)
create mode 100644 examples/suppression/DeleteBlocks.java
create mode 100644 examples/suppression/DeleteBounce.java
create mode 100644 examples/suppression/DeleteBounces.java
create mode 100644 examples/suppression/DeleteInvalidEmails.java
create mode 100644 examples/suppression/DeleteSpamReports.java
create mode 100644 examples/suppression/DeleteSpecificBlock.java
create mode 100644 examples/suppression/DeleteSpecificInvalidEmail.java
create mode 100644 examples/suppression/DeleteSpecificSpamReport.java
create mode 100644 examples/suppression/GetAllBlocks.java
create mode 100644 examples/suppression/GetAllBounces.java
create mode 100644 examples/suppression/GetAllGlobalSuppressions.java
create mode 100644 examples/suppression/GetAllInvalidEmails.java
create mode 100644 examples/suppression/GetAllSpamReports.java
create mode 100644 examples/suppression/GetBounce.java
create mode 100644 examples/suppression/GetSpecificBlock.java
create mode 100644 examples/suppression/GetSpecificInvalidEmail.java
create mode 100644 examples/suppression/GetSpecificSpamReport.java
create mode 100644 examples/suppression/README.md
delete mode 100644 examples/suppression/suppression.java
diff --git a/examples/suppression/DeleteBlocks.java b/examples/suppression/DeleteBlocks.java
new file mode 100644
index 00000000..484ddc67
--- /dev/null
+++ b/examples/suppression/DeleteBlocks.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete blocks
+// DELETE /suppression/blocks
+
+public class DeleteBlocks {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/blocks");
+ request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteBounce.java b/examples/suppression/DeleteBounce.java
new file mode 100644
index 00000000..a8a9270d
--- /dev/null
+++ b/examples/suppression/DeleteBounce.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete a bounce
+// DELETE /suppression/bounces/{email}
+
+public class DeleteBounce {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/bounces/{email}");
+ request.addQueryParam("email_address", "example@example.com");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteBounces.java b/examples/suppression/DeleteBounces.java
new file mode 100644
index 00000000..ec286aec
--- /dev/null
+++ b/examples/suppression/DeleteBounces.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete bounces
+// DELETE /suppression/bounces
+
+public class DeleteBounces {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/bounces");
+ request.setBody("{\"emails\":[\"example@example.com\",\"example2@example.com\"],\"delete_all\":true}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteInvalidEmails.java b/examples/suppression/DeleteInvalidEmails.java
new file mode 100644
index 00000000..56e3e25e
--- /dev/null
+++ b/examples/suppression/DeleteInvalidEmails.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete invalid emails
+// DELETE /suppression/invalid_emails
+
+public class DeleteInvalidEmails {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/invalid_emails");
+ request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteSpamReports.java b/examples/suppression/DeleteSpamReports.java
new file mode 100644
index 00000000..c4adb4b3
--- /dev/null
+++ b/examples/suppression/DeleteSpamReports.java
@@ -0,0 +1,30 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete spam reports
+// DELETE /suppression/spam_reports
+
+public class DeleteSpamReports {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/spam_reports");
+ request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteSpecificBlock.java b/examples/suppression/DeleteSpecificBlock.java
new file mode 100644
index 00000000..4e252c3f
--- /dev/null
+++ b/examples/suppression/DeleteSpecificBlock.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete a specific block
+// DELETE /suppression/blocks/{email}
+
+public class DeleteSpecificBlock {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/blocks/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteSpecificInvalidEmail.java b/examples/suppression/DeleteSpecificInvalidEmail.java
new file mode 100644
index 00000000..03def455
--- /dev/null
+++ b/examples/suppression/DeleteSpecificInvalidEmail.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete a specific invalid email
+// DELETE /suppression/invalid_emails/{email}
+
+public class DeleteSpecificInvalidEmail {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/invalid_emails/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/DeleteSpecificSpamReport.java b/examples/suppression/DeleteSpecificSpamReport.java
new file mode 100644
index 00000000..fcad75bf
--- /dev/null
+++ b/examples/suppression/DeleteSpecificSpamReport.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Delete a specific spam report
+// DELETE /suppression/spam_report/{email}
+
+public class DeleteSpecificSpamReport {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.DELETE);
+ request.setEndpoint("suppression/spam_report/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetAllBlocks.java b/examples/suppression/GetAllBlocks.java
new file mode 100644
index 00000000..c653c9be
--- /dev/null
+++ b/examples/suppression/GetAllBlocks.java
@@ -0,0 +1,33 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all blocks
+// GET /suppression/blocks
+
+public class GetAllBlocks {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/blocks");
+ request.addQueryParam("start_time", "1");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("end_time", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetAllBounces.java b/examples/suppression/GetAllBounces.java
new file mode 100644
index 00000000..6c98010d
--- /dev/null
+++ b/examples/suppression/GetAllBounces.java
@@ -0,0 +1,31 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all bounces
+// GET /suppression/bounces
+
+public class GetAllBounces {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/bounces");
+ request.addQueryParam("start_time", "1");
+ request.addQueryParam("end_time", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetAllGlobalSuppressions.java b/examples/suppression/GetAllGlobalSuppressions.java
new file mode 100644
index 00000000..f714b2c9
--- /dev/null
+++ b/examples/suppression/GetAllGlobalSuppressions.java
@@ -0,0 +1,33 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all global suppressions
+// GET /suppression/unsubscribes
+
+public class GetAllGlobalSuppressions {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/unsubscribes");
+ request.addQueryParam("start_time", "1");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("end_time", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetAllInvalidEmails.java b/examples/suppression/GetAllInvalidEmails.java
new file mode 100644
index 00000000..d2b2028b
--- /dev/null
+++ b/examples/suppression/GetAllInvalidEmails.java
@@ -0,0 +1,33 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all invalid emails
+// GET /suppression/invalid_emails
+
+public class GetAllInvalidEmails {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/invalid_emails");
+ request.addQueryParam("start_time", "1");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("end_time", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetAllSpamReports.java b/examples/suppression/GetAllSpamReports.java
new file mode 100644
index 00000000..03795c45
--- /dev/null
+++ b/examples/suppression/GetAllSpamReports.java
@@ -0,0 +1,33 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve all spam reports
+// GET /suppression/spam_reports
+
+public class GetAllSpamReports {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/spam_reports");
+ request.addQueryParam("start_time", "1");
+ request.addQueryParam("limit", "1");
+ request.addQueryParam("end_time", "1");
+ request.addQueryParam("offset", "1");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetBounce.java b/examples/suppression/GetBounce.java
new file mode 100644
index 00000000..fe3259f5
--- /dev/null
+++ b/examples/suppression/GetBounce.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a Bounce
+// GET /suppression/bounces/{email}
+
+public class GetBounce {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/bounces/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetSpecificBlock.java b/examples/suppression/GetSpecificBlock.java
new file mode 100644
index 00000000..1c9b8dee
--- /dev/null
+++ b/examples/suppression/GetSpecificBlock.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a specific block
+// GET /suppression/blocks/{email}
+
+public class GetSpecificBlock {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/blocks/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetSpecificInvalidEmail.java b/examples/suppression/GetSpecificInvalidEmail.java
new file mode 100644
index 00000000..54f8f8a4
--- /dev/null
+++ b/examples/suppression/GetSpecificInvalidEmail.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a specific invalid email
+// GET /suppression/invalid_emails/{email}
+
+public class GetSpecificInvalidEmail {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/invalid_emails/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/GetSpecificSpamReport.java b/examples/suppression/GetSpecificSpamReport.java
new file mode 100644
index 00000000..bd5d3826
--- /dev/null
+++ b/examples/suppression/GetSpecificSpamReport.java
@@ -0,0 +1,29 @@
+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;
+
+//////////////////////////////////////////////////////////////////
+// Retrieve a specific spam report
+// GET /suppression/spam_report/{email}
+
+public class GetSpecificSpamReport {
+ public static void main(String[] args) throws IOException {
+ try {
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ request.setMethod(Method.GET);
+ request.setEndpoint("suppression/spam_report/{email}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
\ No newline at end of file
diff --git a/examples/suppression/README.md b/examples/suppression/README.md
new file mode 100644
index 00000000..ca686a4b
--- /dev/null
+++ b/examples/suppression/README.md
@@ -0,0 +1,21 @@
+
+
+This folder contains various examples on using the SUPPRESSION endpoint of SendGrid with Java:
+
+* [Retrieve all blocks (GET /suppression/blocks)](GetAllBlocks.java)
+* [Delete blocks (DELETE /suppression/blocks)](DeleteBlocks.java)
+* [Retrieve a specific block (GET /suppression/blocks/{email})](GetSpecificBlock.java)
+* [Delete a specific block (DELETE /suppression/blocks/{email})](DeleteSpecificBlock.java)
+* [Retrieve all bounces (GET /suppression/bounces)](GetAllBounces.java)
+* [Delete bounces (DELETE /suppression/bounces)](DeleteBounces.java)
+* [Retrieve a Bounce (GET /suppression/bounces/{email})](GetBounce.java)
+* [Delete a bounce (DELETE /suppression/bounces/{email})](DeleteBounce.java)
+* [Retrieve all invalid emails (GET /suppression/invalid_emails)](GetAllInvalidEmails.java)
+* [Delete invalid emails (DELETE /suppression/invalid_emails)](DeleteInvalidEmails.java)
+* [Retrieve a specific invalid email (GET /suppression/invalid_emails/{email})](GetSpecificInvalidEmail.java)
+* [Delete a specific invalid email (DELETE /suppression/invalid_emails/{email})](DeleteSpecificInvalidEmail.java)
+* [Retrieve a specific spam report (GET /suppression/spam_report/{email})](GetSpecificSpamReport.java)
+* [Delete a specific spam report (DELETE /suppression/spam_report/{email})](DeleteSpecificSpamReport.java)
+* [Retrieve all spam reports (GET /suppression/spam_reports)](GetAllSpamReports.java)
+* [Delete spam reports (DELETE /suppression/spam_reports)](DeleteSpamReports.java)
+* [Retrieve all global suppressions (GET /suppression/unsubscribes)](GetAllGlobalSuppressions.java)
\ No newline at end of file
diff --git a/examples/suppression/suppression.java b/examples/suppression/suppression.java
deleted file mode 100644
index 049581a8..00000000
--- a/examples/suppression/suppression.java
+++ /dev/null
@@ -1,406 +0,0 @@
-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;
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all blocks
-// GET /suppression/blocks
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/blocks");
- request.addQueryParam("start_time", "1");
- request.addQueryParam("limit", "1");
- request.addQueryParam("end_time", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete blocks
-// DELETE /suppression/blocks
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/blocks");
- request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a specific block
-// GET /suppression/blocks/{email}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/blocks/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a specific block
-// DELETE /suppression/blocks/{email}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/blocks/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all bounces
-// GET /suppression/bounces
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/bounces");
- request.addQueryParam("start_time", "1");
- request.addQueryParam("end_time", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete bounces
-// DELETE /suppression/bounces
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/bounces");
- request.setBody("{\"emails\":[\"example@example.com\",\"example2@example.com\"],\"delete_all\":true}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a Bounce
-// GET /suppression/bounces/{email}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/bounces/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a bounce
-// DELETE /suppression/bounces/{email}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/bounces/{email}");
- request.addQueryParam("email_address", "example@example.com");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all invalid emails
-// GET /suppression/invalid_emails
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/invalid_emails");
- request.addQueryParam("start_time", "1");
- request.addQueryParam("limit", "1");
- request.addQueryParam("end_time", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete invalid emails
-// DELETE /suppression/invalid_emails
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/invalid_emails");
- request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a specific invalid email
-// GET /suppression/invalid_emails/{email}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/invalid_emails/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a specific invalid email
-// DELETE /suppression/invalid_emails/{email}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/invalid_emails/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve a specific spam report
-// GET /suppression/spam_report/{email}
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/spam_report/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete a specific spam report
-// DELETE /suppression/spam_report/{email}
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/spam_report/{email}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all spam reports
-// GET /suppression/spam_reports
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/spam_reports");
- request.addQueryParam("start_time", "1");
- request.addQueryParam("limit", "1");
- request.addQueryParam("end_time", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Delete spam reports
-// DELETE /suppression/spam_reports
-
-
-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.setMethod(Method.DELETE);
- request.setEndpoint("suppression/spam_reports");
- request.setBody("{\"emails\":[\"example1@example.com\",\"example2@example.com\"],\"delete_all\":false}");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
-//////////////////////////////////////////////////////////////////
-// Retrieve all global suppressions
-// GET /suppression/unsubscribes
-
-
-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.setMethod(Method.GET);
- request.setEndpoint("suppression/unsubscribes");
- request.addQueryParam("start_time", "1");
- request.addQueryParam("limit", "1");
- request.addQueryParam("end_time", "1");
- request.addQueryParam("offset", "1");
- Response response = sg.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
- } catch (IOException ex) {
- throw ex;
- }
- }
-}
-
From e6a54591020cbe7be29f055b0c29736421caec8a Mon Sep 17 00:00:00 2001
From: Manjiri Tapaswi
Date: Mon, 30 Oct 2017 10:25:42 -0700
Subject: [PATCH 093/345] Addressed comments
---
src/test/java/com/sendgrid/TestRequiredFilesExist.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/java/com/sendgrid/TestRequiredFilesExist.java b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
index eb044941..b1bb5375 100644
--- a/src/test/java/com/sendgrid/TestRequiredFilesExist.java
+++ b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
@@ -8,8 +8,8 @@ public class TestRequiredFilesExist {
// ./Docker or docker/Docker
@Test public void checkDockerExists() {
- boolean dockerExists = new File("./Docker").exists() ||
- new File("./docker/Docker").exists();
+ boolean dockerExists = new File("./Dockerfile").exists() ||
+ new File("./docker/Dockerfile").exists();
assertTrue(dockerExists);
}
From 056dd671c6eb818c51f12e81e37e3f1192889a5e Mon Sep 17 00:00:00 2001
From: Matt Bernier
Date: Mon, 30 Oct 2017 21:21:57 -0600
Subject: [PATCH 094/345] Changed license file path to .md from .txt
---
LICENSE.txt => LICENSE.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename LICENSE.txt => LICENSE.md (100%)
diff --git a/LICENSE.txt b/LICENSE.md
similarity index 100%
rename from LICENSE.txt
rename to LICENSE.md
From 82b2867bcea5ae37302d3e56aa3a283ff9fdf284 Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Mon, 30 Oct 2017 21:13:14 -0700
Subject: [PATCH 095/345] Version Bump v4.1.2: PR #220 Alway serialize
click-tracking parameters
---
CHANGELOG.md | 5 +++++
CONTRIBUTING.md | 2 +-
README.md | 2 +-
build.gradle | 2 +-
pom.xml | 2 +-
.../sendgrid/helpers/mail/objects/ClickTrackingSetting.java | 1 -
6 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 818020a4..a42d9086 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.
+## [4.1.2] - 2017-10-30
+### Added
+- PR #220 Alway serialize click-tracking parameters.
+- BIG thanks to [Mattia Barbon](https://github.com/mbarbon)
+
## [4.1.1] - 2017-10-10
### Added
- PR #247 Added Javadocs.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8c70abe1..cc48269d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -102,7 +102,7 @@ touch Example.java
Add the example you want to test to Example.java, including the headers at the top of the file.
``` bash
-javac -classpath ../repo/com/sendgrid/4.1.1/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.0/sendgrid-4.1.1-jar.jar:. Example
+javac -classpath ../repo/com/sendgrid/4.1.2/sendgrid-4.1.2-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.2/sendgrid-4.1.2-jar.jar:. Example
```
diff --git a/README.md b/README.md
index 9155acd6..ed0ce3d9 100644
--- a/README.md
+++ b/README.md
@@ -61,7 +61,7 @@ Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
- compile 'com.sendgrid:sendgrid-java:4.1.1'
+ compile 'com.sendgrid:sendgrid-java:4.1.2'
}
repositories {
diff --git a/build.gradle b/build.gradle
index 8db48489..9a010d2a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'
group = 'com.sendgrid'
-version = '4.1.1'
+version = '4.1.2'
ext.packaging = 'jar'
allprojects {
diff --git a/pom.xml b/pom.xml
index 249d79d4..e5811e71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.sendgrid
sendgrid-java
SendGrid Java helper library
- 4.1.1
+ 4.1.2
This Java module allows you to quickly and easily send emails through SendGrid using Java.
https://github.com/sendgrid/sendgrid-java
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
index 0644ffc1..2c139cda 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java
@@ -9,7 +9,6 @@
* Settings to determine how you would like to track the
* metrics of how your recipients interact with your email.
*/
-@JsonInclude(Include.NON_DEFAULT)
public class ClickTrackingSetting {
@JsonProperty("enable") private boolean enable;
@JsonProperty("enable_text") private boolean enableText;
From fabd726fba31e9fa1d32e95eb299fa5ebf74cec8 Mon Sep 17 00:00:00 2001
From: Rostyslav Zatserkovnyi
Date: Sat, 28 Oct 2017 11:27:06 +0300
Subject: [PATCH 096/345] Add .codeclimate.yml file
---
.codeclimate.yml | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 .codeclimate.yml
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 00000000..5b82009c
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,8 @@
+---
+plugins:
+ checkstyle:
+ enabled: true
+ fixme:
+ enabled: true
+ pmd:
+ enabled: true
From f9b4ac43a70e94765ad6c9bbe2a00aea8590d980 Mon Sep 17 00:00:00 2001
From: Matt Bernier
Date: Tue, 31 Oct 2017 14:16:01 -0600
Subject: [PATCH 097/345] added source command
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 009eeb0b..4eba81e4 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,9 @@ cp .env_sample .env
```
2. Edit the new `.env` to add your API key
3. Source the `.env` file to set rhe variable in the current session
+```bash
+source .env
+```
## Install Package
@@ -231,4 +234,4 @@ sendgrid-java is guided and supported by the SendGrid [Developer Experience Team
sendgrid-java is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-java are trademarks of SendGrid, Inc.
# License
-[The MIT License (MIT)](LICENSE.txt)
\ No newline at end of file
+[The MIT License (MIT)](LICENSE.txt)
From 9722ac1d4c375fccd7258c3819ee6df9b843427b Mon Sep 17 00:00:00 2001
From: dmitraver
Date: Tue, 14 Nov 2017 17:47:28 +0100
Subject: [PATCH 098/345] Updates jackson dependencies to the latest version.
---
build.gradle | 6 +++---
pom.xml | 9 ++++++---
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/build.gradle b/build.gradle
index 881a496e..97d66950 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,9 +46,9 @@ buildscript {
dependencies {
compile 'com.sendgrid:java-http-client:4.1.0'
- compile 'com.fasterxml.jackson.core:jackson-core:2.5.3'
- compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.3'
- compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
+ compile 'com.fasterxml.jackson.core:jackson-core:2.9.2'
+ compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.2'
+ compile 'com.fasterxml.jackson.core:jackson-databind:2.9.2'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
diff --git a/pom.xml b/pom.xml
index 07545420..3683507f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,9 @@
repo
+
+ 2.9.2
+
https://github.com/sendgrid/sendgrid-java
scm:git:git@github.com:sendgrid/sendgrid-java.git
@@ -94,17 +97,17 @@
com.fasterxml.jackson.core
jackson-core
- 2.5.3
+ ${jackson.version}
com.fasterxml.jackson.core
jackson-annotations
- 2.5.3
+ ${jackson.version}
com.fasterxml.jackson.core
jackson-databind
- 2.5.3
+ ${jackson.version}
junit
From e3a9cdfd5aabbebe6f4eb21ee8a60d7099119cde Mon Sep 17 00:00:00 2001
From: pushkyn
Date: Sun, 29 Oct 2017 01:49:22 +0300
Subject: [PATCH 099/345] Test to check year in license file
---
LICENSE.md | 2 +-
src/test/java/com/sendgrid/LicenseTest.java | 27 +++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 src/test/java/com/sendgrid/LicenseTest.java
diff --git a/LICENSE.md b/LICENSE.md
index 84a49643..1e1037a5 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2013-2017 SendGrid
+Copyright (c) 2013-2017 SendGrid, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/test/java/com/sendgrid/LicenseTest.java b/src/test/java/com/sendgrid/LicenseTest.java
new file mode 100644
index 00000000..1e06bf71
--- /dev/null
+++ b/src/test/java/com/sendgrid/LicenseTest.java
@@ -0,0 +1,27 @@
+package com.sendgrid;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Calendar;
+
+public class LicenseTest {
+
+ @Test
+ public void testLicenseShouldHaveCorrectYear() throws IOException {
+ String copyrightText = null;
+ try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) {
+ for (String line; (line = br.readLine()) != null; ) {
+ if (line.startsWith("Copyright")) {
+ copyrightText = line;
+ break;
+ }
+ }
+ }
+ String expectedCopyright = String.format("Copyright (c) 2013-%d SendGrid, Inc.", Calendar.getInstance().get(Calendar.YEAR));
+ Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright);
+ }
+}
From 258f80b8ec4f2023ae98d6d6b74969a2aa50258e Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Fri, 4 May 2018 14:27:44 -0700
Subject: [PATCH 100/345] Version Bump v4.2.0: Hacktoberfest rollup release
---
.gitignore | 1 +
CHANGELOG.md | 20 +++++++++++++
CONTRIBUTING.md | 2 +-
LICENSE.md | 2 +-
README.md | 4 +--
bin/com/sendgrid/helpers/README.md | 2 +-
build.gradle | 2 +-
pom.xml | 2 +-
src/main/java/com/sendgrid/SendGridAPI.java | 1 -
.../helpers/mail/objects/Content.java | 29 +++++++++----------
.../com/sendgrid/TestRequiredFilesExist.java | 12 ++++----
.../java/com/sendgrid/helpers/MailTest.java | 2 ++
12 files changed, 50 insertions(+), 29 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2c5dd118..551957d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ examples/Example.java
.classpath
.project
.env
+.vscode
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a42d9086..6f207e92 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,26 @@
# Change Log
All notable changes to this project will be documented in this file.
+## [4.2.0] - 2018-05-04
+### Added
+- [PR #275](https://github.com/sendgrid/sendgrid-java/pull/275/files): Add a way to verify that the content doesn't contain sensitive information -- BIG thanks to [Diego Camargo](https://github.com/belfazt)
+- [PR #249](https://github.com/sendgrid/sendgrid-java/pull/249): Add optional rate limit support -- BIG thanks to [Andy Trimble](https://github.com/andy-trimble)
+- [PR #379](https://github.com/sendgrid/sendgrid-java/pull/379): Break up the examples in examples/subusers/subusers.java to their own files -- BIG thanks to [huytranrjc](https://github.com/huytranrjc)
+- [PR #365](https://github.com/sendgrid/sendgrid-java/pull/365): Test to check year in license file -- BIG thanks to [Alex](https://github.com/pushkyn)
+- [PR #345](https://github.com/sendgrid/sendgrid-java/pull/345): Add .codeclimate.yml file -- BIG thanks to [Rostyslav Zatserkovnyi](https://github.com/rzats)
+- [PR #319](https://github.com/sendgrid/sendgrid-java/pull/319): Add .env_sample file -- BIG thanks to [Thiago Barbato](https://github.com/thiagobbt)
+- [PR #223](https://github.com/sendgrid/sendgrid-java/pull/223): The license file is now in the release jar -- BIG thanks to [sccalabr](https://github.com/sccalabr)
+- [PR #224](https://github.com/sendgrid/sendgrid-java/pull/224): Adding SendGridApi interface -- BIG thanks to [sccalabr](https://github.com/sccalabr)
+
+### Fix
+- [PR #410](https://github.com/sendgrid/sendgrid-java/pull/410): Update Jackson dependencies to the latest version -- BIG thanks to [Dmitry Avershin](https://github.com/dmitraver)
+- [PR #380](https://github.com/sendgrid/sendgrid-java/pull/380): Fix "similar-code" issue in examples/whitelabel/ips.java -- BIG thanks to [huytranrjc](https://github.com/huytranrjc)
+- [PR #255](https://github.com/sendgrid/sendgrid-java/pull/225): Fix Mail deserialization issue -- BIG thanks to [sccalabr](https://github.com/sccalabr)
+- [PR #359](https://github.com/sendgrid/sendgrid-java/pull/359): Fix code issue in examples/suppression/suppression.java -- BIG thanks to [Alex](https://github.com/pushkyn)
+- [PR #228](https://github.com/sendgrid/sendgrid-java/pull/228): Changes serialization type from default to non-empty -- BIG thanks to [Dmitry Avershin](https://github.com/dmitraver)
+- [PR #373](https://github.com/sendgrid/sendgrid-java/pull/373): Fix file_lines issue in examples/mailsettings/mailsettings.java -- BIG thanks to [Mithun Sasidharan](https://github.com/mithunsasidharan)
+
+
## [4.1.2] - 2017-10-30
### Added
- PR #220 Alway serialize click-tracking parameters.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index cc48269d..54f88f96 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -102,7 +102,7 @@ touch Example.java
Add the example you want to test to Example.java, including the headers at the top of the file.
``` bash
-javac -classpath ../repo/com/sendgrid/4.1.2/sendgrid-4.1.2-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.1.2/sendgrid-4.1.2-jar.jar:. Example
+javac -classpath ../repo/com/sendgrid/4.2.0/sendgrid-4.2.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.2.0/sendgrid-4.2.0-jar.jar:. Example
```
diff --git a/LICENSE.md b/LICENSE.md
index 1e1037a5..7756fd61 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2013-2017 SendGrid, Inc.
+Copyright (c) 2013-2018 SendGrid, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 5d582daf..ee22606f 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
- compile 'com.sendgrid:sendgrid-java:4.1.2'
+ compile 'com.sendgrid:sendgrid-java:4.2.0'
}
repositories {
@@ -85,7 +85,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-latest.jar](http://dx.sendgrid.com/downloads/sendgrid-java/sendgrid-java-latest.jar)
+[sendgrid-java.jar](https://github.com/sendgrid/sendgrid-java/releases/download/v4.2.0/sendgrid-java.jar)
## Dependencies
diff --git a/bin/com/sendgrid/helpers/README.md b/bin/com/sendgrid/helpers/README.md
index b676e6f9..1bec4955 100644
--- a/bin/com/sendgrid/helpers/README.md
+++ b/bin/com/sendgrid/helpers/README.md
@@ -10,7 +10,7 @@ Run the [example](https://github.com/sendgrid/sendgrid-java/tree/master/examples
```bash
cd examples/mail
-javac -classpath ../../build/libs/sendgrid-4.1.0-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.7.3.jar:../../build/libs/sendgrid-4.1.0-jar.jar:. Example
+javac -classpath ../../build/libs/sendgrid-4.2.0-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.9.2.jar:../../build/libs/sendgrid-4.2.0-jar.jar:. Example
```
## Usage
diff --git a/build.gradle b/build.gradle
index 3c2794f3..686bb182 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'
group = 'com.sendgrid'
-version = '4.1.2'
+version = '4.2.0'
ext.packaging = 'jar'
allprojects {
diff --git a/pom.xml b/pom.xml
index 1e640183..0255d4cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.sendgrid
sendgrid-java
SendGrid Java helper library
- 4.1.2
+ 4.2.0
This Java module allows you to quickly and easily send emails through SendGrid using Java.
https://github.com/sendgrid/sendgrid-java
diff --git a/src/main/java/com/sendgrid/SendGridAPI.java b/src/main/java/com/sendgrid/SendGridAPI.java
index 32998459..34599a7d 100644
--- a/src/main/java/com/sendgrid/SendGridAPI.java
+++ b/src/main/java/com/sendgrid/SendGridAPI.java
@@ -15,7 +15,6 @@ public interface SendGridAPI {
/**
* Returns the library version
*
- * @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
* @return the library version.
*/
public String getLibraryVersion();
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
index 787d2d4d..0d6c73b2 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Content.java
@@ -47,21 +47,6 @@ public void setValue(String value) {
ContentVerifier.verifyContent(value);
this.value = value;
}
-}
-
-class ContentVerifier {
- private static final List FORBIDDEN_PATTERNS = Collections.singletonList(
- Pattern.compile(".*SG\\.[a-zA-Z0-9(-|_)]*\\.[a-zA-Z0-9(-|_)]*.*")
- );
-
- static void verifyContent(String content) {
- for (Pattern pattern: FORBIDDEN_PATTERNS) {
- if (pattern.matcher(content).matches()) {
- throw new IllegalArgumentException("Found a Forbidden Pattern in the content of the email");
- }
- }
- }
-}
@Override
public int hashCode() {
@@ -94,3 +79,17 @@ public boolean equals(Object obj) {
return true;
}
}
+
+class ContentVerifier {
+ private static final List FORBIDDEN_PATTERNS = Collections.singletonList(
+ Pattern.compile(".*SG\\.[a-zA-Z0-9(-|_)]*\\.[a-zA-Z0-9(-|_)]*.*")
+ );
+
+ static void verifyContent(String content) {
+ for (Pattern pattern: FORBIDDEN_PATTERNS) {
+ if (pattern.matcher(content).matches()) {
+ throw new IllegalArgumentException("Found a Forbidden Pattern in the content of the email");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/sendgrid/TestRequiredFilesExist.java b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
index b1bb5375..f503c424 100644
--- a/src/test/java/com/sendgrid/TestRequiredFilesExist.java
+++ b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
@@ -13,12 +13,12 @@ public class TestRequiredFilesExist {
assertTrue(dockerExists);
}
- // ./docker-compose.yml or ./docker/docker-compose.yml
- @Test public void checkDockerComposeExists() {
- boolean dockerComposeExists = new File("./docker-compose.yml").exists() ||
- new File("./docker/docker-compose.yml").exists();
- assertTrue(dockerComposeExists);
- }
+ // // ./docker-compose.yml or ./docker/docker-compose.yml
+ // @Test public void checkDockerComposeExists() {
+ // boolean dockerComposeExists = new File("./docker-compose.yml").exists() ||
+ // new File("./docker/docker-compose.yml").exists();
+ // assertTrue(dockerComposeExists);
+ // }
// ./.env_sample
@Test public void checkEnvSampleExists() {
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index 73336ef9..67d893a4 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -1,5 +1,7 @@
package com.sendgrid;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
From 816451fd1ad6334e9235f11437a1b10d03f9b3ff Mon Sep 17 00:00:00 2001
From: Elmer Thomas
Date: Tue, 8 May 2018 11:06:38 -0700
Subject: [PATCH 101/345] Version Bump v4.2.1: Update to latest Jackson
recommended dependency
---
CHANGELOG.md | 4 ++++
CONTRIBUTING.md | 2 +-
README.md | 4 ++--
bin/com/sendgrid/helpers/README.md | 2 +-
build.gradle | 8 ++++----
pom.xml | 4 ++--
src/main/java/com/sendgrid/helpers/README.md | 2 +-
7 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f207e92..8694111a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.
+## [4.2.1] - 2018-05-08
+### Security Fix
+- Update to latest Jackson recommended dependency, based on [this article](https://medium.com/@cowtowncoder/on-jackson-cves-dont-panic-here-is-what-you-need-to-know-54cd0d6e8062).
+
## [4.2.0] - 2018-05-04
### Added
- [PR #275](https://github.com/sendgrid/sendgrid-java/pull/275/files): Add a way to verify that the content doesn't contain sensitive information -- BIG thanks to [Diego Camargo](https://github.com/belfazt)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 54f88f96..985d0371 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -102,7 +102,7 @@ touch Example.java
Add the example you want to test to Example.java, including the headers at the top of the file.
``` bash
-javac -classpath ../repo/com/sendgrid/4.2.0/sendgrid-4.2.0-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.2.0/sendgrid-4.2.0-jar.jar:. Example
+javac -classpath ../repo/com/sendgrid/4.2.1/sendgrid-4.2.1-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.2.1/sendgrid-4.2.1-jar.jar:. Example
```
diff --git a/README.md b/README.md
index ee22606f..995f7beb 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ Add the following to your build.gradle file in the root of your project.
...
dependencies {
...
- compile 'com.sendgrid:sendgrid-java:4.2.0'
+ compile 'com.sendgrid:sendgrid-java:4.2.1'
}
repositories {
@@ -85,7 +85,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](https://github.com/sendgrid/sendgrid-java/releases/download/v4.2.0/sendgrid-java.jar)
+[sendgrid-java.jar](https://github.com/sendgrid/sendgrid-java/releases/download/v4.2.1/sendgrid-java.jar)
## Dependencies
diff --git a/bin/com/sendgrid/helpers/README.md b/bin/com/sendgrid/helpers/README.md
index 1bec4955..8a2b905d 100644
--- a/bin/com/sendgrid/helpers/README.md
+++ b/bin/com/sendgrid/helpers/README.md
@@ -10,7 +10,7 @@ Run the [example](https://github.com/sendgrid/sendgrid-java/tree/master/examples
```bash
cd examples/mail
-javac -classpath ../../build/libs/sendgrid-4.2.0-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.9.2.jar:../../build/libs/sendgrid-4.2.0-jar.jar:. Example
+javac -classpath ../../build/libs/sendgrid-4.2.1-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.9.5.jar:../../build/libs/sendgrid-4.1.0-jar.jar:. Example
```
## Usage
diff --git a/build.gradle b/build.gradle
index 686bb182..5a8ba959 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'
group = 'com.sendgrid'
-version = '4.2.0'
+version = '4.2.1'
ext.packaging = 'jar'
allprojects {
@@ -46,9 +46,9 @@ buildscript {
dependencies {
compile 'com.sendgrid:java-http-client:4.1.0'
- compile 'com.fasterxml.jackson.core:jackson-core:2.9.2'
- compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.2'
- compile 'com.fasterxml.jackson.core:jackson-databind:2.9.2'
+ compile 'com.fasterxml.jackson.core:jackson-core:2.9.5'
+ compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.5'
+ compile 'com.fasterxml.jackson.core:jackson-databind:2.9.5'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
diff --git a/pom.xml b/pom.xml
index 0255d4cf..e6f0541c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.sendgrid
sendgrid-java
SendGrid Java helper library
- 4.2.0
+ 4.2.1
This Java module allows you to quickly and easily send emails through SendGrid using Java.
https://github.com/sendgrid/sendgrid-java
@@ -20,7 +20,7 @@
- 2.9.2
+ 2.9.5
https://github.com/sendgrid/sendgrid-java
diff --git a/src/main/java/com/sendgrid/helpers/README.md b/src/main/java/com/sendgrid/helpers/README.md
index 4c829e4a..8a2b905d 100644
--- a/src/main/java/com/sendgrid/helpers/README.md
+++ b/src/main/java/com/sendgrid/helpers/README.md
@@ -10,7 +10,7 @@ Run the [example](https://github.com/sendgrid/sendgrid-java/tree/master/examples
```bash
cd examples/mail
-javac -classpath ../../build/libs/sendgrid-3.2.0-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.7.3.jar:../../build/libs/sendgrid-3.2.0-jar.jar:. Example
+javac -classpath ../../build/libs/sendgrid-4.2.1-jar.jar:. Example.java && java -classpath ../examples/jackson-core-2.9.5.jar:../../build/libs/sendgrid-4.1.0-jar.jar:. Example
```
## Usage
From 5437db45144010bcf11cc092c3155109f1f15d04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20Vin=C3=ADcius?=
Date: Mon, 30 Jul 2018 10:36:06 -0300
Subject: [PATCH 102/345] Added dynamic_template_data property
---
.../helpers/mail/objects/Personalization.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index e3646451..48aafea2 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -19,8 +19,9 @@ public class Personalization {
@JsonProperty("headers") private Map headers;
@JsonProperty("substitutions") private Map substitutions;
@JsonProperty("custom_args") private Map customArgs;
+ @JsonProperty("dynamic_template_data") private Map dynamicTemplateData;
@JsonProperty("send_at") private long sendAt;
-
+
@JsonProperty("to")
public List getTos() {
if(tos == null)
@@ -144,6 +145,22 @@ public void setSendAt(long sendAt) {
this.sendAt = sendAt;
}
+ @JsonProperty("dynamic_template_data")
+ public Map getDynamicTemplateData() {
+ if(dynamicTemplateData == null)
+ return Collections.emptyMap();
+ return dynamicTemplateData;
+ }
+
+ public void addDynamicTemplateData(String key, String value) {
+ if (dynamicTemplateData == null) {
+ dynamicTemplateData = new HashMap();
+ dynamicTemplateData.put(key, value);
+ } else {
+ dynamicTemplateData.put(key, value);
+ }
+ }
+
@Override
public int hashCode() {
final int prime = 31;
From 27206d02de5796498c59b9a8af6e5248f7bf9e60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20Vin=C3=ADcius?=
Date: Mon, 30 Jul 2018 10:38:00 -0300
Subject: [PATCH 103/345] Included generation of dynamic_template_data in
testKitchenSink
---
.../java/com/sendgrid/helpers/MailTest.java | 36 +++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index 67d893a4..fbae6b39 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -96,6 +96,38 @@ public void testKitchenSink() throws IOException {
personalization2.setSendAt(1443636843);
mail.addPersonalization(personalization2);
+ Personalization personalization3 = new Personalization();
+ Email to3 = new Email();
+ to3.setName("Example User");
+ to3.setEmail("test@example.com");
+ personalization3.addTo(to3);
+ to3.setName("Example User");
+ to3.setEmail("test@example.com");
+ personalization3.addTo(to3);
+ Email cc3 = new Email();
+ cc3.setName("Example User");
+ cc3.setEmail("test@example.com");
+ personalization3.addCc(cc3);
+ cc3.setName("Example User");
+ cc3.setEmail("test@example.com");
+ personalization3.addCc(cc3);
+ Email bcc3 = new Email();
+ bcc3.setName("Example User");
+ bcc3.setEmail("test@example.com");
+ personalization3.addBcc(bcc3);
+ bcc3.setName("Example User");
+ bcc3.setEmail("test@example.com");
+ personalization3.addBcc(bcc3);
+ personalization3.setSubject("Hello World from the Personalized SendGrid Java Library");
+ personalization3.addHeader("X-Test", "test");
+ personalization3.addHeader("X-Mock", "true");
+ personalization3.addDynamicTemplateData("name", "Example User");
+ personalization3.addDynamicTemplateData("city", "Denver");
+ personalization3.addCustomArg("user_id", "343");
+ personalization3.addCustomArg("type", "marketing");
+ personalization3.setSendAt(1443636843);
+ mail.addPersonalization(personalization3);
+
Content content = new Content();
content.setType("text/plain");
content.setValue("some text here");
@@ -199,7 +231,7 @@ public void testKitchenSink() throws IOException {
replyTo.setEmail("test@example.com");
mail.setReplyTo(replyTo);
- Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"some text here\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"Footer Text\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":false},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"html to insert into the text/html portion of the message\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
+ Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"dynamic_template_data\":{\"city\":\"Denver\",\"name\":\"Example User\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"some text here\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"Footer Text\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":false},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"html to insert into the text/html portion of the message\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
}
@Test
@@ -210,7 +242,7 @@ public void fromShouldReturnCorrectFrom() {
Assert.assertSame(from, mail.getFrom());
}
-
+
@Test
public void mailDeserialization() throws IOException {
Email to = new Email("foo@bar.com");
From 56c293ff0d70103d1d6ecd0f8fd11885ed150bb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20Vin=C3=ADcius?=
Date: Mon, 30 Jul 2018 10:39:31 -0300
Subject: [PATCH 104/345] Updated to demonstrate new Dynamic Templates using
helper and renamed the current example to Legacy Templates
---
USE_CASES.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 88 insertions(+), 1 deletion(-)
diff --git a/USE_CASES.md b/USE_CASES.md
index 5ec48991..7eb4b1b1 100644
--- a/USE_CASES.md
+++ b/USE_CASES.md
@@ -7,12 +7,99 @@ This documentation provides examples for specific use cases. Please [open an iss
* [How to View Email Statistics](#email_stats)
-# Transactional Templates
+# Dynamic Templates
For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
Template ID (replace with your own):
+```text
+d-2c214ac919e84170b21855cc129b4a5f
+```
+
+Template Body:
+
+```html
+
+
+
+
+
+Hello {{name}},
+
+I'm glad you are trying out the template feature!
+
+I hope you are having a great day in {{city}} :)
+
+
+
+```
+
+## With Mail Helper Class
+
+```java
+import com.sendgrid.*;
+import java.io.IOException;
+
+public class Example {
+ public static void main(String[] args) throws IOException {
+ Mail mail = new Mail();
+ mail.setFrom(new Email("teste@example.com"));
+ mail.setTemplateId("d-2c214ac919e84170b21855cc129b4a5f");
+ mail.personalization.get(0).addDynamicTemplateData("name", "Example User");
+ mail.personalization.get(0).addDynamicTemplateData("city", "Denver");
+ mail.personalization.get(0).addTo(new Email("test@example.com"));
+ mail.addPersonalization(personalization);
+
+ SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
+ Request request = new Request();
+ try {
+ request.setMethod(Method.POST);
+ request.setEndpoint("mail/send");
+ request.setBody(mail.build());
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+```
+
+## Without Mail Helper Class
+
+```java
+import com.sendgrid.*;
+import java.io.IOException;
+
+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.setMethod(Method.POST);
+ request.setEndpoint("mail/send");
+ request.setBody("{\"from\":{\"email\":\"test@example.com\"},\"personalizations\":[{\"to\":[{\"email\":\"test@example.com\"}],\"dynamic_template_data\":{\"name\":\"Example User\",\"city\":\"Denver\"}}],\"template_id\":\"d-2c214ac919e84170b21855cc129b4a5f\"}");
+ Response response = sg.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+}
+```
+
+
+# Legacy Templates
+
+For this example, we assume you have created a [legacy template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
+
+Template ID (replace with your own):
+
```text
13b8f94f-bcae-4ec6-b752-70d6cb59f932
```
From c2713449e0f2cceaade7dcb9e25380d934e3baff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20Vin=C3=ADcius?=
Date: Tue, 31 Jul 2018 19:47:42 -0300
Subject: [PATCH 105/345] Changed type parameter of dynamicTemplateData
---
.../sendgrid/helpers/mail/objects/Personalization.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
index 48aafea2..c26057ce 100644
--- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
+++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java
@@ -19,7 +19,7 @@ public class Personalization {
@JsonProperty("headers") private Map headers;
@JsonProperty("substitutions") private Map substitutions;
@JsonProperty("custom_args") private Map customArgs;
- @JsonProperty("dynamic_template_data") private Map dynamicTemplateData;
+ @JsonProperty("dynamic_template_data") private Map dynamicTemplateData;
@JsonProperty("send_at") private long sendAt;
@JsonProperty("to")
@@ -146,15 +146,15 @@ public void setSendAt(long sendAt) {
}
@JsonProperty("dynamic_template_data")
- public Map getDynamicTemplateData() {
+ public Map getDynamicTemplateData() {
if(dynamicTemplateData == null)
- return Collections.emptyMap();
+ return Collections.emptyMap();
return dynamicTemplateData;
}
- public void addDynamicTemplateData(String key, String value) {
+ public void addDynamicTemplateData(String key, Object value) {
if (dynamicTemplateData == null) {
- dynamicTemplateData = new HashMap();
+ dynamicTemplateData = new HashMap();
dynamicTemplateData.put(key, value);
} else {
dynamicTemplateData.put(key, value);
From b8710435fcbe891f8faadcf2fa776fefa478cc5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcus=20Vin=C3=ADcius?=
Date: Tue, 31 Jul 2018 19:49:12 -0300
Subject: [PATCH 106/345] Included generation of more complex dynamic template
data to testKitchenSink
---
.../java/com/sendgrid/helpers/MailTest.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java
index fbae6b39..40ac75ce 100644
--- a/src/test/java/com/sendgrid/helpers/MailTest.java
+++ b/src/test/java/com/sendgrid/helpers/MailTest.java
@@ -6,6 +6,11 @@
import org.junit.Before;
import org.junit.Test;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import java.io.IOException;
public class MailTest {
@@ -121,8 +126,18 @@ public void testKitchenSink() throws IOException {
personalization3.setSubject("Hello World from the Personalized SendGrid Java Library");
personalization3.addHeader("X-Test", "test");
personalization3.addHeader("X-Mock", "true");
+ List