Skip to content

Commit

Permalink
docs: breakup examples to their own files in examples/user/user.java (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsau authored Jul 29, 2020
1 parent 417be23 commit 195a658
Show file tree
Hide file tree
Showing 27 changed files with 591 additions and 575 deletions.
22 changes: 22 additions & 0 deletions examples/user/CreateWebhookParseSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//////////////////////////////////////////////////////////////////
// Create a parse setting
// POST /user/webhooks/parse/settings


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.POST);
request.setEndpoint("user/webhooks/parse/settings");
request.setBody("{\"url\":\"http://email.myhosthame.com\",\"send_raw\":false,\"hostname\":\"myhostname.com\",\"spam_check\":true}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/DeleteScheduleSend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Delete a cancellation or pause of a scheduled send
// DELETE /user/scheduled_sends/{batch_id}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.DELETE);
request.setEndpoint("user/scheduled_sends/{batch_id}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/DeleteWebhookParseSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Delete a parse setting
// DELETE /user/webhooks/parse/settings/{hostname}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.DELETE);
request.setEndpoint("user/webhooks/parse/settings/{hostname}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetCreditBalance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve your credit balance
// GET /user/credits


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/credits");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetEmailAddress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve your account email address
// GET /user/email


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/email");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetEnforedTLS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve current Enforced TLS settings.
// GET /user/settings/enforced_tls


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/settings/enforced_tls");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetProfile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Get a user's profile
// GET /user/profile


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/profile");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetScheduleSend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve all scheduled sends
// GET /user/scheduled_sends


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/scheduled_sends");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetScheduleSendByBatchId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve scheduled send
// GET /user/scheduled_sends/{batch_id}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/scheduled_sends/{batch_id}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetUserInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Get a user's account information.
// GET /user/account


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/account");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetUsername.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve your username
// GET /user/username


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/username");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetWebhookEventSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve Event Webhook settings
// GET /user/webhooks/event/settings


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/webhooks/event/settings");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetWebhookParseSettingByHostname.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve a specific parse setting
// GET /user/webhooks/parse/settings/{hostname}


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/webhooks/parse/settings/{hostname}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
21 changes: 21 additions & 0 deletions examples/user/GetWebhookParseSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//////////////////////////////////////////////////////////////////
// Retrieve all parse settings
// GET /user/webhooks/parse/settings


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/webhooks/parse/settings");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
26 changes: 26 additions & 0 deletions examples/user/GetWebhookParseStatistics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//////////////////////////////////////////////////////////////////
// Retrieves Inbound Parse Webhook statistics.
// GET /user/webhooks/parse/stats


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.GET);
request.setEndpoint("user/webhooks/parse/stats");
request.addQueryParam("aggregated_by", "day");
request.addQueryParam("limit", "test_string");
request.addQueryParam("start_date", "2016-01-01");
request.addQueryParam("end_date", "2016-04-01");
request.addQueryParam("offset", "test_string");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
22 changes: 22 additions & 0 deletions examples/user/PauseScheduleSend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//////////////////////////////////////////////////////////////////
// Cancel or pause a scheduled send
// POST /user/scheduled_sends


public class Example {
public static void main(String[] args) throws IOException {
try {
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
Request request = new Request();
request.setMethod(Method.POST);
request.setEndpoint("user/scheduled_sends");
request.setBody("{\"batch_id\":\"YOUR_BATCH_ID\",\"status\":\"pause\"}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
Loading

0 comments on commit 195a658

Please sign in to comment.