-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
57 lines (47 loc) · 1.96 KB
/
Copy pathUser.java
File metadata and controls
57 lines (47 loc) · 1.96 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
package javaxt.azure.graph;
import java.util.*;
import javaxt.json.*;
public class User extends Node {
//**************************************************************************
//** Constructor
//**************************************************************************
public User(JSONObject json, Connection conn){
super(json, conn);
}
//**************************************************************************
//** getEmail
//**************************************************************************
public String getEmail(){
return get("mail").toString();
}
//**************************************************************************
//** getCalendars
//**************************************************************************
public ArrayList<Calendar> getCalendars() throws Exception {
ArrayList<Calendar> calendars = new ArrayList<>();
String userID = getID();
String email = getEmail();
String url = "/users/" + userID + "/calendars";
JSONObject json = conn.getResponse(url);
for (JSONValue v : json.get("value").toJSONArray()){
Calendar calendar = new Calendar(v.toJSONObject(), userID, conn);
String owner = calendar.get("owner").get("address").toString();
if (owner.equalsIgnoreCase(email)){
calendars.add(calendar);
}
}
return calendars;
}
//**************************************************************************
//** getUsers
//**************************************************************************
public static ArrayList<User> getUsers(Connection conn) throws Exception {
ArrayList<User> users = new ArrayList<>();
JSONObject json = conn.getResponse("/users");
for (JSONValue v : json.get("value").toJSONArray()){
JSONObject user = v.toJSONObject();
users.add(new User(user, conn));
}
return users;
}
}