Skip to content

Commit e76e7c2

Browse files
Version Bump v3.0.3: Update docs, unit tests and examples to include Sender ID
1 parent 48f5cbc commit e76e7c2

8 files changed

Lines changed: 417 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.0.3] - 2016-07-12
5+
### Added
6+
- Update docs, unit tests and examples to include Sender ID
7+
48
## [3.0.2] - 2016-07-05
59
### Updated
610
- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Add the following to your build.gradle file in the root of your project.
4848
...
4949
dependencies {
5050
...
51-
compile 'com.sendgrid:sendgrid-java:3.0.2'
51+
compile 'com.sendgrid:sendgrid-java:3.0.3'
5252
}
5353
5454
repositories {
@@ -73,7 +73,7 @@ mvn install
7373

7474
You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.
7575

76-
[sendgrid-java.jar](http://repo1.maven.org/maven2/com/sendgrid/sendgrid-java/3.0.2/sendgrid-java-3.0.2-jar.jar)
76+
[sendgrid-java.jar](http://repo1.maven.org/maven2/com/sendgrid/sendgrid-java/3.0.3/sendgrid-java-3.0.3-jar.jar)
7777

7878
```java
7979
import com.sendgrid.*;

USAGE.md

Lines changed: 149 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class Example {
3939
* [MAILBOX PROVIDERS](#mailbox_providers)
4040
* [PARTNER SETTINGS](#partner_settings)
4141
* [SCOPES](#scopes)
42+
* [SENDERS](#senders)
4243
* [STATS](#stats)
4344
* [SUBUSERS](#subusers)
4445
* [SUPPRESSION](#suppression)
@@ -1931,8 +1932,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
19311932
request.method = Method.GET;
19321933
request.endpoint = "contactdb/recipients/search";
19331934
Map<String,String> queryParams = new HashMap<String, String>();
1934-
queryParams.put("%7Bfield_name%7D", "test_string");
1935-
queryParams.put("{field_name}", "test_string");
1935+
queryParams.put("{field_name}", "test_string");
19361936
request.queryParams = queryParams;
19371937
Response response = sg.api(request);
19381938
System.out.println(response.statusCode);
@@ -3398,6 +3398,153 @@ API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://s
33983398
throw ex;
33993399
}
34003400
```
3401+
<a name="senders"></a>
3402+
# SENDERS
3403+
3404+
## Create a Sender Identity
3405+
3406+
**This endpoint allows you to create a new sender identity.**
3407+
3408+
*You may create up to 100 unique sender identities.*
3409+
3410+
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`.
3411+
3412+
### POST /senders
3413+
3414+
3415+
```java
3416+
try {
3417+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3418+
Request request = new Request();
3419+
request.method = Method.POST;
3420+
request.endpoint = "senders";
3421+
request.body = "{\"city\":\"Denver\",\"from\":{\"email\":\"from@example.com\",\"name\":\"Example INC\"},\"zip\":\"80202\",\"country\":\"United States\",\"state\":\"Colorado\",\"address_2\":\"Apt. 456\",\"address\":\"123 Elm St.\",\"reply_to\":{\"email\":\"replyto@example.com\",\"name\":\"Example INC\"},\"nickname\":\"My Sender ID\"}";
3422+
Response response = sg.api(request);
3423+
System.out.println(response.statusCode);
3424+
System.out.println(response.body);
3425+
System.out.println(response.headers);
3426+
} catch (IOException ex) {
3427+
throw ex;
3428+
}
3429+
```
3430+
## Get all Sender Identities
3431+
3432+
**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.**
3433+
3434+
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`.
3435+
3436+
### GET /senders
3437+
3438+
3439+
```java
3440+
try {
3441+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3442+
Request request = new Request();
3443+
request.method = Method.GET;
3444+
request.endpoint = "senders";
3445+
Response response = sg.api(request);
3446+
System.out.println(response.statusCode);
3447+
System.out.println(response.body);
3448+
System.out.println(response.headers);
3449+
} catch (IOException ex) {
3450+
throw ex;
3451+
}
3452+
```
3453+
## Update a Sender Identity
3454+
3455+
**This endpoint allows you to update a sender identity.**
3456+
3457+
Updates to `from.email` require re-verification. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`.
3458+
3459+
Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request.
3460+
3461+
### PATCH /senders/{sender_id}
3462+
3463+
3464+
```java
3465+
try {
3466+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3467+
Request request = new Request();
3468+
request.method = Method.PATCH;
3469+
request.endpoint = "senders/{sender_id}";
3470+
request.body = "{\"city\":\"Denver\",\"from\":{\"email\":\"from@example.com\",\"name\":\"Example INC\"},\"zip\":\"80202\",\"country\":\"United States\",\"state\":\"Colorado\",\"address_2\":\"Apt. 456\",\"address\":\"123 Elm St.\",\"reply_to\":{\"email\":\"replyto@example.com\",\"name\":\"Example INC\"},\"nickname\":\"My Sender ID\"}";
3471+
Response response = sg.api(request);
3472+
System.out.println(response.statusCode);
3473+
System.out.println(response.body);
3474+
System.out.println(response.headers);
3475+
} catch (IOException ex) {
3476+
throw ex;
3477+
}
3478+
```
3479+
## View a Sender Identity
3480+
3481+
**This endpoint allows you to retrieve a specific sender identity.**
3482+
3483+
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`.
3484+
3485+
### GET /senders/{sender_id}
3486+
3487+
3488+
```java
3489+
try {
3490+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3491+
Request request = new Request();
3492+
request.method = Method.GET;
3493+
request.endpoint = "senders/{sender_id}";
3494+
Response response = sg.api(request);
3495+
System.out.println(response.statusCode);
3496+
System.out.println(response.body);
3497+
System.out.println(response.headers);
3498+
} catch (IOException ex) {
3499+
throw ex;
3500+
}
3501+
```
3502+
## Delete a Sender Identity
3503+
3504+
**This endoint allows you to delete one of your sender identities.**
3505+
3506+
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`.
3507+
3508+
### DELETE /senders/{sender_id}
3509+
3510+
3511+
```java
3512+
try {
3513+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3514+
Request request = new Request();
3515+
request.method = Method.DELETE;
3516+
request.endpoint = "senders/{sender_id}";
3517+
Response response = sg.api(request);
3518+
System.out.println(response.statusCode);
3519+
System.out.println(response.body);
3520+
System.out.println(response.headers);
3521+
} catch (IOException ex) {
3522+
throw ex;
3523+
}
3524+
```
3525+
## Resend Sender Identity Verification
3526+
3527+
**This enpdoint allows you to resend a sender identity verification email.**
3528+
3529+
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`.
3530+
3531+
### POST /senders/{sender_id}/resend_verification
3532+
3533+
3534+
```java
3535+
try {
3536+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
3537+
Request request = new Request();
3538+
request.method = Method.POST;
3539+
request.endpoint = "senders/{sender_id}/resend_verification";
3540+
Response response = sg.api(request);
3541+
System.out.println(response.statusCode);
3542+
System.out.println(response.body);
3543+
System.out.println(response.headers);
3544+
} catch (IOException ex) {
3545+
throw ex;
3546+
}
3547+
```
34013548
<a name="stats"></a>
34023549
# STATS
34033550

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apply plugin: 'maven'
1717
apply plugin: 'signing'
1818

1919
group = 'com.sendgrid'
20-
version = '3.0.2'
20+
version = '3.0.3'
2121
ext.packaging = 'jar'
2222

2323
allprojects {

examples/contactdb/contactdb.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public static void main(String[] args) throws IOException {
490490
request.method = Method.GET;
491491
request.endpoint = "contactdb/recipients/search";
492492
Map<String,String> queryParams = new HashMap<String, String>();
493-
queryParams.put("%7Bfield_name%7D", "test_string");
494493
queryParams.put("{field_name}", "test_string");
495494
request.queryParams = queryParams;
496495
Response response = sg.api(request);

examples/senders/senders.java

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import com.fasterxml.jackson.databind.JsonNode;
2+
import com.fasterxml.jackson.databind.ObjectMapper;
3+
4+
import com.sendgrid.*;
5+
6+
import java.io.IOException;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
//////////////////////////////////////////////////////////////////
11+
// Create a Sender Identity
12+
// POST /senders
13+
14+
15+
public class Example {
16+
public static void main(String[] args) throws IOException {
17+
try {
18+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
19+
Request request = new Request();
20+
request.method = Method.POST;
21+
request.endpoint = "senders";
22+
request.body = "{\"city\":\"Denver\",\"from\":{\"email\":\"from@example.com\",\"name\":\"Example INC\"},\"zip\":\"80202\",\"country\":\"United States\",\"state\":\"Colorado\",\"address_2\":\"Apt. 456\",\"address\":\"123 Elm St.\",\"reply_to\":{\"email\":\"replyto@example.com\",\"name\":\"Example INC\"},\"nickname\":\"My Sender ID\"}";
23+
Response response = sg.api(request);
24+
System.out.println(response.statusCode);
25+
System.out.println(response.body);
26+
System.out.println(response.headers);
27+
} catch (IOException ex) {
28+
throw ex;
29+
}
30+
}
31+
}
32+
33+
//////////////////////////////////////////////////////////////////
34+
// Get all Sender Identities
35+
// GET /senders
36+
37+
38+
public class Example {
39+
public static void main(String[] args) throws IOException {
40+
try {
41+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
42+
Request request = new Request();
43+
request.method = Method.GET;
44+
request.endpoint = "senders";
45+
Response response = sg.api(request);
46+
System.out.println(response.statusCode);
47+
System.out.println(response.body);
48+
System.out.println(response.headers);
49+
} catch (IOException ex) {
50+
throw ex;
51+
}
52+
}
53+
}
54+
55+
//////////////////////////////////////////////////////////////////
56+
// Update a Sender Identity
57+
// PATCH /senders/{sender_id}
58+
59+
60+
public class Example {
61+
public static void main(String[] args) throws IOException {
62+
try {
63+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
64+
Request request = new Request();
65+
request.method = Method.PATCH;
66+
request.endpoint = "senders/{sender_id}";
67+
request.body = "{\"city\":\"Denver\",\"from\":{\"email\":\"from@example.com\",\"name\":\"Example INC\"},\"zip\":\"80202\",\"country\":\"United States\",\"state\":\"Colorado\",\"address_2\":\"Apt. 456\",\"address\":\"123 Elm St.\",\"reply_to\":{\"email\":\"replyto@example.com\",\"name\":\"Example INC\"},\"nickname\":\"My Sender ID\"}";
68+
Response response = sg.api(request);
69+
System.out.println(response.statusCode);
70+
System.out.println(response.body);
71+
System.out.println(response.headers);
72+
} catch (IOException ex) {
73+
throw ex;
74+
}
75+
}
76+
}
77+
78+
//////////////////////////////////////////////////////////////////
79+
// View a Sender Identity
80+
// GET /senders/{sender_id}
81+
82+
83+
public class Example {
84+
public static void main(String[] args) throws IOException {
85+
try {
86+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
87+
Request request = new Request();
88+
request.method = Method.GET;
89+
request.endpoint = "senders/{sender_id}";
90+
Response response = sg.api(request);
91+
System.out.println(response.statusCode);
92+
System.out.println(response.body);
93+
System.out.println(response.headers);
94+
} catch (IOException ex) {
95+
throw ex;
96+
}
97+
}
98+
}
99+
100+
//////////////////////////////////////////////////////////////////
101+
// Delete a Sender Identity
102+
// DELETE /senders/{sender_id}
103+
104+
105+
public class Example {
106+
public static void main(String[] args) throws IOException {
107+
try {
108+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
109+
Request request = new Request();
110+
request.method = Method.DELETE;
111+
request.endpoint = "senders/{sender_id}";
112+
Response response = sg.api(request);
113+
System.out.println(response.statusCode);
114+
System.out.println(response.body);
115+
System.out.println(response.headers);
116+
} catch (IOException ex) {
117+
throw ex;
118+
}
119+
}
120+
}
121+
122+
//////////////////////////////////////////////////////////////////
123+
// Resend Sender Identity Verification
124+
// POST /senders/{sender_id}/resend_verification
125+
126+
127+
public class Example {
128+
public static void main(String[] args) throws IOException {
129+
try {
130+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
131+
Request request = new Request();
132+
request.method = Method.POST;
133+
request.endpoint = "senders/{sender_id}/resend_verification";
134+
Response response = sg.api(request);
135+
System.out.println(response.statusCode);
136+
System.out.println(response.body);
137+
System.out.println(response.headers);
138+
} catch (IOException ex) {
139+
throw ex;
140+
}
141+
}
142+
}
143+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>com.sendgrid</groupId>
1010
<artifactId>sendgrid-java</artifactId>
1111
<name>SendGrid Java helper library</name>
12-
<version>3.0.2</version>
12+
<version>3.0.3</version>
1313
<description>This Java module allows you to quickly and easily send emails through SendGrid using Java.</description>
1414
<url>https://github.com/sendgrid/sendgrid-java</url>
1515
<licenses>

0 commit comments

Comments
 (0)