Skip to content

Commit

Permalink
Merge branch 'test-license-date-range' of https://github.com/pushkyn/…
Browse files Browse the repository at this point in the history
…sendgrid-java into test-license-date-range
  • Loading branch information
mbernier committed Nov 11, 2017
2 parents c7b2a32 + 15455d9 commit aec5a54
Show file tree
Hide file tree
Showing 30 changed files with 666 additions and 445 deletions.
28 changes: 28 additions & 0 deletions examples/mailsettings/GetAddressWhitelistMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
30 changes: 30 additions & 0 deletions examples/mailsettings/GetAllMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetBCCMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetBouncePurgeMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
31 changes: 31 additions & 0 deletions examples/mailsettings/GetFooterMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
31 changes: 31 additions & 0 deletions examples/mailsettings/GetForwardBounceMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetForwardSpamMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetPlainContentMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetSpamCheckMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 28 additions & 0 deletions examples/mailsettings/GetTemplateMailSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
23 changes: 23 additions & 0 deletions examples/mailsettings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

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)
29 changes: 29 additions & 0 deletions examples/mailsettings/UpdateAddressWhitelist.java
Original file line number Diff line number Diff line change
@@ -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\":[\"[email protected]\",\"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;
}
}
}
29 changes: 29 additions & 0 deletions examples/mailsettings/UpdateBCCMailSettings.java
Original file line number Diff line number Diff line change
@@ -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 protected]\"}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
Loading

0 comments on commit aec5a54

Please sign in to comment.