This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
MeSnippets.java
127 lines (114 loc) · 5.7 KB
/
MeSnippets.java
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
* See LICENSE in the project root for license information.
*/
package com.microsoft.office365.msgraphsnippetapp.snippet;
import com.microsoft.office365.msgraphapiservices.MSGraphMeService;
import com.microsoft.office365.msgraphsnippetapp.R;
import com.microsoft.office365.msgraphsnippetapp.application.SnippetApp;
import okhttp3.ResponseBody;
import retrofit2.Callback;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me_direct_reports;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me_group_membership;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me_manager;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me_photo;
import static com.microsoft.office365.msgraphsnippetapp.R.array.get_me_responsibilities;
public abstract class MeSnippets<Result> extends AbstractSnippet<MSGraphMeService, Result> {
/**
* Snippet constructor
*
* @param descriptionArray The String array for the specified snippet
*/
public MeSnippets(Integer descriptionArray) {
super(SnippetCategory.meSnippetCategory, descriptionArray);
}
static MeSnippets[] getMeSnippets() {
return new MeSnippets[]{
// Marker element
new MeSnippets(null) {
@Override
public void request(MSGraphMeService service, Callback callback) {
// Not implemented
}
},
// Snippets
/* Get information about signed in user
* HTTP GET https://graph.microsoft.com/{version}/me
* @see https://graph.microsoft.io/docs/api-reference/v1.0/api/user_get
*/
new MeSnippets<ResponseBody>(get_me) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMe(getVersion()).enqueue(callback);
}
},
/* Get responsibilities of signed in user
* HTTP GET https://graph.microsoft.com/{version}/me?$select=AboutMe,Responsibilities,Tags
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<ResponseBody>(get_me_responsibilities) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMeResponsibilities(
getVersion(),
SnippetApp.getApp().getString(R.string.meResponsibility)
).enqueue(callback);
}
},
/* Get the user's manager
* HTTP GET https://graph.microsoft.com/{version}/me/manager
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<ResponseBody>(get_me_manager) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMeEntities(
getVersion(),
SnippetApp.getApp().getString(R.string.manager)
).enqueue(callback);
}
},
/* Get the user's direct reports
* HTTP GET https://graph.microsoft.com/{version}/me/directReports
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<ResponseBody>(get_me_direct_reports) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMeEntities(getVersion(),
SnippetApp.getApp().getString(R.string.directReports)
).enqueue(callback);
}
},
/* Get the group membership of the user
* HTTP GET https://graph.microsoft.com/{version}/me/memberOf
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<ResponseBody>(get_me_group_membership) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMeEntities(
getVersion(),
SnippetApp.getApp().getString(R.string.memberOf)
).enqueue(callback);
}
},
/* Get the photo of the user
* HTTP GET https://graph.microsoft.com/{version}/me/userPhoto
* @see https://graph.microsoft.io/docs/api-reference/v1.0/resources/user
*/
new MeSnippets<ResponseBody>(get_me_photo) {
@Override
public void request(MSGraphMeService service, Callback<ResponseBody> callback) {
service.getMeEntities(
getVersion(),
SnippetApp.getApp().getString(R.string.userPhoto)
).enqueue(callback);
}
}
};
}
@Override
public abstract void request(MSGraphMeService service, Callback<Result> callback);
}