Skip to content

Commit 195a658

Browse files
authored
docs: breakup examples to their own files in examples/user/user.java (#370)
1 parent 417be23 commit 195a658

27 files changed

Lines changed: 591 additions & 575 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Create a parse setting
3+
// POST /user/webhooks/parse/settings
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.POST);
12+
request.setEndpoint("user/webhooks/parse/settings");
13+
request.setBody("{\"url\":\"http://email.myhosthame.com\",\"send_raw\":false,\"hostname\":\"myhostname.com\",\"spam_check\":true}");
14+
Response response = sg.api(request);
15+
System.out.println(response.getStatusCode());
16+
System.out.println(response.getBody());
17+
System.out.println(response.getHeaders());
18+
} catch (IOException ex) {
19+
throw ex;
20+
}
21+
}
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Delete a cancellation or pause of a scheduled send
3+
// DELETE /user/scheduled_sends/{batch_id}
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.DELETE);
12+
request.setEndpoint("user/scheduled_sends/{batch_id}");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Delete a parse setting
3+
// DELETE /user/webhooks/parse/settings/{hostname}
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.DELETE);
12+
request.setEndpoint("user/webhooks/parse/settings/{hostname}");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Retrieve your credit balance
3+
// GET /user/credits
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/credits");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

examples/user/GetEmailAddress.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Retrieve your account email address
3+
// GET /user/email
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/email");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

examples/user/GetEnforedTLS.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Retrieve current Enforced TLS settings.
3+
// GET /user/settings/enforced_tls
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/settings/enforced_tls");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

examples/user/GetProfile.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Get a user's profile
3+
// GET /user/profile
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/profile");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

examples/user/GetScheduleSend.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Retrieve all scheduled sends
3+
// GET /user/scheduled_sends
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/scheduled_sends");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Retrieve scheduled send
3+
// GET /user/scheduled_sends/{batch_id}
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/scheduled_sends/{batch_id}");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

examples/user/GetUserInfo.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//////////////////////////////////////////////////////////////////
2+
// Get a user's account information.
3+
// GET /user/account
4+
5+
6+
public class Example {
7+
public static void main(String[] args) throws IOException {
8+
try {
9+
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
10+
Request request = new Request();
11+
request.setMethod(Method.GET);
12+
request.setEndpoint("user/account");
13+
Response response = sg.api(request);
14+
System.out.println(response.getStatusCode());
15+
System.out.println(response.getBody());
16+
System.out.println(response.getHeaders());
17+
} catch (IOException ex) {
18+
throw ex;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)