Skip to content

Commit f3b3b7e

Browse files
committed
Verion bump 0.0.6 - adds setFromName
1 parent 7d0b938 commit f3b3b7e

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories {
3434
}
3535
dependencies {
3636
...
37-
compile 'com.github.scottmotte:sendgrid:0.0.5'
37+
compile 'com.github.scottmotte:sendgrid:0.0.6'
3838
}
3939
4040
...
@@ -116,6 +116,16 @@ sendgrid.addTo("[email protected]");
116116
sendgrid.setFrom("[email protected]");
117117
```
118118

119+
### From Name
120+
121+
```java
122+
SendGrid sendgrid = new SendGrid("sendgrid_username", "sendgrid_password");
123+
sendgrid.addTo("[email protected]");
124+
...
125+
sendgrid.setFrom("[email protected]");
126+
sendgrid.setFromName("Other Dude");
127+
```
128+
119129
### Subject
120130

121131
```java

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: 'fatjar'
22

3-
version = "0.0.5"
3+
version = "0.0.6"
44

55
buildscript {
66
dependencies {
Binary file not shown.

src/main/java/com/github/scottmotte/sendgrid/Sendgrid.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class SendGrid {
1313
private static final String PARAM_TONAMES = "toname[]";
1414
private static final String PARAM_BCC = "bcc";
1515
private static final String PARAM_FROM = "from";
16+
private static final String PARAM_FROMNAME = "fromname";
1617
private static final String PARAM_SUBJECT = "subject";
1718
private static final String PARAM_HTML = "html";
1819
private static final String PARAM_TEXT = "text";
@@ -25,6 +26,7 @@ public class SendGrid {
2526
private ArrayList<String> tonames = new ArrayList<String>();
2627
private String bcc;
2728
private String from;
29+
private String fromname;
2830
private String subject;
2931
private String text;
3032
private String html;
@@ -52,6 +54,7 @@ public String web() {
5254
request.part(PARAM_TONAMES, toname);
5355
}
5456
request.part(PARAM_FROM, this.getFrom());
57+
request.part(PARAM_FROMNAME, this.getFromName());
5558
request.part(PARAM_SUBJECT, this.getSubject());
5659

5760
if (text != null) {
@@ -89,6 +92,10 @@ public String getFrom() {
8992
return this.from;
9093
}
9194

95+
public String getFromName() {
96+
return this.fromname;
97+
}
98+
9299
public String getSubject() {
93100
return this.subject;
94101
}
@@ -124,6 +131,11 @@ public SendGrid setFrom(String email) {
124131
return this;
125132
}
126133

134+
public SendGrid setFromName(String name) {
135+
this.fromname = name;
136+
return this;
137+
}
138+
127139
public SendGrid setBcc(String bcc) {
128140
this.bcc = bcc;
129141
return this;

src/test/java/com/github/scottmotte/sendgrid/SendgridTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class SendGridTest {
1919
sendgrid.addTo(email);
2020
sendgrid.addToName("Name Guy");
2121
sendgrid.setFrom(email);
22+
sendgrid.setFromName("Some Name");
2223
sendgrid.setSubject("Subject");
2324
sendgrid.setText("Text");
2425
sendgrid.setHtml("Html");
@@ -68,6 +69,16 @@ public void testSetFrom() {
6869
assertEquals(sendgrid.getFrom(), email);
6970
}
7071

72+
@Test
73+
public void testSetFromName() {
74+
SendGrid sendgrid = new SendGrid(USERNAME, PASSWORD);
75+
76+
String name = "Example Guy";
77+
sendgrid.setFromName(name);
78+
79+
assertEquals(sendgrid.getFromName(), name);
80+
}
81+
7182
@Test
7283
public void testSetSubject() {
7384
SendGrid sendgrid = new SendGrid(USERNAME, PASSWORD);

0 commit comments

Comments
 (0)