public class Sendgrid
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Sendgrid.SendgridHTTP |
static class |
Sendgrid.SendGridReqResp |
static interface |
Sendgrid.WarningListener
Invoked when a warning is returned from the server that
isn't critical
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
domain |
protected java.lang.String |
endpoint |
protected java.lang.String |
password |
protected java.lang.String |
token |
protected java.lang.Boolean |
use_headers |
protected java.lang.String |
username |
Constructor and Description |
---|
Sendgrid(java.lang.String username,
java.lang.String password,
java.lang.String token) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
_arrayToUrlPart(java.util.ArrayList<java.lang.String> array,
java.lang.String token)
_arrayToUrlPart - Converts an ArrayList to a url friendly string
|
protected java.util.Map<java.lang.String,java.lang.String> |
_prepMessageData()
_prepMessageData - Takes the mail message and returns a url friendly querystring
|
Sendgrid |
addCategory(java.lang.String category)
addCategory - Append a category to the list of categories
|
Sendgrid |
addFilterSetting(java.lang.String filter_name,
java.lang.String parameter_name,
java.lang.String parameter_value)
addFilterSetting - Append a filter setting to the list of filter settings
|
Sendgrid |
addSection(java.lang.String from_value,
java.lang.String to_value)
addSection - append a section value to the list of section values
|
Sendgrid |
addSubstitution(java.lang.String from_value,
java.lang.String[] to_values) |
Sendgrid |
addTo(java.lang.String email)
addTo - Make the second parameter("name") of "addTo" method optional
|
Sendgrid |
addTo(java.lang.String email,
java.lang.String name)
addTo - Append an email address to the existing list of addresses
Preserve previous recipient 'to' data.
|
Sendgrid |
addUniqueArgument(java.lang.String key,
java.lang.String value)
addUniqueArgument - Set a key/value pair of unique arguments, to be used for tracking purposes
|
java.util.ArrayList<java.lang.String> |
getBccs()
getBccs - return the list of Blind Carbon Copy recipients
|
java.util.ArrayList<java.lang.String> |
getCcs()
getCcs - return the list of Carbon Copy recipients
|
java.lang.String |
getFrom()
getFrom - Get the from email address
|
java.lang.String |
getFromName()
getFromName - Get the from name
|
JsonObject |
getHeaders()
getHeaders - return the list of headers
|
java.lang.String |
getHtml()
getHtml - Get the HTML part of the email
|
java.lang.String |
getReplyTo()
getReplyTo - Get reply to address
|
java.lang.String |
getServerResponse()
getServerResponse - Get the server response message
|
java.lang.String |
getSubject()
getSubject - Get the email subject
|
java.lang.String |
getText()
getText - Get the plain text part of the email
|
java.util.ArrayList<java.lang.String> |
getToNames()
getTos - Return the list of names for recipients
|
java.util.ArrayList<java.lang.String> |
getTos()
getTos - Return the list of recipients
|
void |
send()
send - Send an email
|
void |
send(Sendgrid.WarningListener w)
send - Send an email
|
Sendgrid |
setBcc(java.lang.String email)
setBcc - Initialize the list of Carbon Copy recipients
destroy previous recipient Blind Carbon Copy data
|
Sendgrid |
setCategories(java.lang.String[] category_list) |
Sendgrid |
setCategory(java.lang.String category)
setCategory - Clears the category list and adds the given category
|
Sendgrid |
setCc(java.lang.String email)
setCc - Initialize the list of Carbon Copy recipients
destroy previous recipient Carbon Copy data
|
Sendgrid |
setFilterSettings(JsonObject filter_settings)
setFilterSettings - Set filter/app settings
|
Sendgrid |
setFrom(java.lang.String email)
setFrom - Set the from email
|
Sendgrid |
setFromName(java.lang.String name)
setFromName - Set the from name
|
Sendgrid |
setHeaders(JsonObject key_value_pairs)
setHeaders - Sets the list headers
destroys previous header data
|
Sendgrid |
setHtml(java.lang.String html)
setHTML - Set the HTML part of the email
|
Sendgrid |
setReplyTo(java.lang.String email)
setReplyTo - set the reply-to address
|
Sendgrid |
setSections(JsonObject key_value_pairs)
setSection - Set a list of section values
|
Sendgrid |
setSubject(java.lang.String subject)
setSubject - Set the email subject
|
Sendgrid |
setSubstitutions(JsonObject key_value_pairs)
setSubstitutions - Substitute a value for list of values, where each value corresponds
to the list emails in a one to one relationship.
|
Sendgrid |
setText(java.lang.String text)
setText - Set the plain text part of the email
|
Sendgrid |
setTo(java.lang.String email)
setTo - Initialize a single email for the recipient 'to' field
Destroy previous recipient 'to' data.
|
Sendgrid |
setTransport(Sendgrid.SendgridHTTP sgTransport)
setTo - Initialize a single email for the recipient 'to' field
Destroy previous recipient 'to' data.
|
Sendgrid |
setUniqueArguments(JsonObject key_value_pairs)
setUniqueArguments - Set a list of unique arguments, to be used for tracking purposes
|
protected java.lang.Boolean use_headers
protected java.lang.String domain
protected java.lang.String endpoint
protected java.lang.String username
protected java.lang.String token
protected java.lang.String password
public Sendgrid(java.lang.String username, java.lang.String password, java.lang.String token)
public Sendgrid setTransport(Sendgrid.SendgridHTTP sgTransport)
sgTransport
- The pluggable interface we use to send the requestpublic java.util.ArrayList<java.lang.String> getTos()
public Sendgrid setTo(java.lang.String email)
email
- A list of email addressespublic Sendgrid addTo(java.lang.String email, java.lang.String name)
email
- Recipient email addressname
- Recipient namepublic Sendgrid addTo(java.lang.String email)
email
- A single email addresspublic java.util.ArrayList<java.lang.String> getToNames()
public java.lang.String getFrom()
public Sendgrid setFrom(java.lang.String email)
email
- An email addresspublic java.lang.String getFromName()
public Sendgrid setFromName(java.lang.String name)
name
- The namepublic java.lang.String getReplyTo()
public Sendgrid setReplyTo(java.lang.String email)
email
- the email to reply topublic java.util.ArrayList<java.lang.String> getBccs()
public Sendgrid setBcc(java.lang.String email) throws java.lang.Exception
email
- an email addressjava.lang.Exception
public java.util.ArrayList<java.lang.String> getCcs()
public Sendgrid setCc(java.lang.String email) throws java.lang.Exception
email
- an email addressjava.lang.Exception
public java.lang.String getSubject()
public Sendgrid setSubject(java.lang.String subject)
subject
- The email subjectpublic java.lang.String getText()
public Sendgrid setText(java.lang.String text)
text
- The plain text of the emailpublic java.lang.String getHtml()
public Sendgrid setHtml(java.lang.String html)
html
- The HTML part of the emailpublic Sendgrid setCategories(java.lang.String[] category_list) throws java.lang.Exception
java.lang.Exception
public Sendgrid setCategory(java.lang.String category) throws java.lang.Exception
category
- the new category to appendjava.lang.Exception
public Sendgrid addCategory(java.lang.String category) throws java.lang.Exception
category
- the new category to appendjava.lang.Exception
public Sendgrid setSubstitutions(JsonObject key_value_pairs)
key_value_pairs
- key/value pairs where the value is an array of valuespublic Sendgrid addSubstitution(java.lang.String from_value, java.lang.String[] to_values) throws java.lang.Exception
java.lang.Exception
public Sendgrid setSections(JsonObject key_value_pairs) throws java.lang.Exception
key_value_pairs
- key/value pairsjava.lang.Exception
public Sendgrid addSection(java.lang.String from_value, java.lang.String to_value) throws java.lang.Exception
from_value
- the value to be replacedto_value
- the value to replacejava.lang.Exception
public Sendgrid setUniqueArguments(JsonObject key_value_pairs)
key_value_pairs
- - list of unique argumentspublic Sendgrid addUniqueArgument(java.lang.String key, java.lang.String value)
key
- the keyvalue
- the valuepublic Sendgrid setFilterSettings(JsonObject filter_settings)
filter_settings
- - JsonObject of fiter settingspublic Sendgrid addFilterSetting(java.lang.String filter_name, java.lang.String parameter_name, java.lang.String parameter_value) throws java.lang.Exception
filter_name
- filter nameparameter_name
- parameter nameparameter_value
- setting valuejava.lang.Exception
public JsonObject getHeaders()
public Sendgrid setHeaders(JsonObject key_value_pairs)
key_value_pairs
- the list of header datapublic java.lang.String getServerResponse()
protected java.lang.String _arrayToUrlPart(java.util.ArrayList<java.lang.String> array, java.lang.String token)
array
- the array to converttoken
- the name of parameterprotected java.util.Map<java.lang.String,java.lang.String> _prepMessageData() throws java.lang.Exception
java.lang.Exception
public void send() throws java.lang.Exception
java.lang.Exception
public void send(Sendgrid.WarningListener w) throws java.lang.Exception
w
- callback that will receive warningsjava.lang.Exception