-
Notifications
You must be signed in to change notification settings - Fork 410
Refactoring, correct package and fluent interface #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c68b6e7
Refactoring, correct package and fluent interface
richardcsantana 5b88db2
Improve readme
richardcsantana 99b945a
Fix #134. Adds an attachment builder class that supports passing cont…
dmitraver 7b86f34
Version Bump v3.2.0: #160 Adds an attachment builder that supports In…
thinkingserious 290ef82
Update CLA process
4459c9b
Refactoring, correct package and fluent interface
richardcsantana 24a1074
Fix #134. Adds an attachment builder class that supports passing cont…
dmitraver 1e98e9a
Simplified `makeCall()` method.
rafalwrzeszcz d63abb5
Version Bump v3.2.1: #175 Simplified method.
thinkingserious a80fac9
Refactoring, correct package and fluent interface
richardcsantana 21757f1
Fix #134. Adds an attachment builder class that supports passing cont…
dmitraver dff5c06
Merge branch 'master' into master
richardcsantana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,10 @@ The following is the minimum needed code to send an email with the [/mail/send H | |
|
||
```java | ||
import com.sendgrid.*; | ||
import java.io.IOException; | ||
import com.sendgrid.helpers.mail.Mail; | ||
import com.sendgrid.helpers.mail.objects.Content; | ||
import com.sendgrid.helpers.mail.objects.Email; | ||
import com.sendgrid.helpers.mail.objects.Personalization; | ||
|
||
public class Example { | ||
public static void main(String[] args) throws IOException { | ||
|
@@ -126,6 +129,40 @@ public class Example { | |
} | ||
``` | ||
|
||
or using fluence interface | ||
|
||
```java | ||
import com.sendgrid.*; | ||
import com.sendgrid.helpers.mail.Mail; | ||
import com.sendgrid.helpers.mail.objects.Content; | ||
import com.sendgrid.helpers.mail.objects.Email; | ||
import com.sendgrid.helpers.mail.objects.Personalization; | ||
|
||
public class Example { | ||
public static void main(String[] args) throws IOException { | ||
Mail mail = new Mail() | ||
.setFrom(new Email("[email protected]")) | ||
.setSubject("Hello World from the SendGrid Java Library!") | ||
.addPersonalization(new Personalization() | ||
.addTo(new Email("[email protected]"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation is off here |
||
.addContent(new Content("text/plain", "Hello, Email!")); | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
try { | ||
request.method = Method.POST; | ||
request.endpoint = "mail/send"; | ||
request.body = mail.build(); | ||
Response response = sg.api(request); | ||
System.out.println(response.statusCode); | ||
System.out.println(response.body); | ||
System.out.println(response.headers); | ||
} catch (IOException ex) { | ||
throw ex; | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The `Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](https://github.com/sendgrid/sendgrid-java/blob/master/examples/helpers/mail/Example.java#L221) is an example of how to add to it. | ||
|
||
### Without Mail Helper Class | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*fluent