forked from sendgrid/sendgrid-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategories.java
More file actions
97 lines (85 loc) · 3.19 KB
/
categories.java
File metadata and controls
97 lines (85 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sendgrid.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
//////////////////////////////////////////////////////////////////
// Retrieve all categories
// GET /categories
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.method = Method.GET;
request.endpoint = "categories";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("category", "test_string");
queryParams.put("limit", "1");
queryParams.put("offset", "1");
request.queryParams = queryParams;
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;
}
}
}
//////////////////////////////////////////////////////////////////
// Retrieve Email Statistics for Categories
// GET /categories/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.method = Method.GET;
request.endpoint = "categories/stats";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("end_date", "2016-04-01");
queryParams.put("aggregated_by", "day");
queryParams.put("limit", "1");
queryParams.put("offset", "1");
queryParams.put("start_date", "2016-01-01");
queryParams.put("categories", "test_string");
request.queryParams = queryParams;
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;
}
}
}
//////////////////////////////////////////////////////////////////
// Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?]
// GET /categories/stats/sums
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.method = Method.GET;
request.endpoint = "categories/stats/sums";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("end_date", "2016-04-01");
queryParams.put("aggregated_by", "day");
queryParams.put("limit", "1");
queryParams.put("sort_by_metric", "test_string");
queryParams.put("offset", "1");
queryParams.put("start_date", "2016-01-01");
queryParams.put("sort_by_direction", "asc");
request.queryParams = queryParams;
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;
}
}
}