forked from sendgrid/sendgrid-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevices.java
More file actions
38 lines (32 loc) · 1.16 KB
/
devices.java
File metadata and controls
38 lines (32 loc) · 1.16 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
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 email statistics by device type.
// GET /devices/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 = "devices/stats";
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("aggregated_by", "day");
queryParams.put("limit", "1");
queryParams.put("start_date", "2016-01-01");
queryParams.put("end_date", "2016-04-01");
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;
}
}
}