7
7
8
8
class Emails extends MsGraphAdmin
9
9
{
10
+ private ?bool $ delta = null ;
11
+
10
12
private string $ userId = '' ;
11
13
12
14
private string $ top = '' ;
13
15
14
16
private string $ skip = '' ;
15
17
18
+ private string $ search = '' ;
19
+
16
20
private string $ subject = '' ;
17
21
18
22
private string $ body = '' ;
@@ -106,6 +110,13 @@ public function attachments(array $attachments): static
106
110
return $ this ;
107
111
}
108
112
113
+ public function delta (?bool $ delta = true ): static
114
+ {
115
+ $ this ->delta = $ delta ;
116
+
117
+ return $ this ;
118
+ }
119
+
109
120
/**
110
121
* @throws Exception
111
122
*/
@@ -117,6 +128,11 @@ public function get(array $params = []): array
117
128
118
129
$ top = request ('top ' , $ this ->top );
119
130
$ skip = request ('skip ' , $ this ->skip );
131
+ $ search = request ('search ' , $ this ->search );
132
+
133
+ if (filled ($ search ) && $ this ->delta ) {
134
+ throw new Exception ('Search is not supported in delta queries. ' );
135
+ }
120
136
121
137
if ($ params == []) {
122
138
$ params = http_build_query ([
@@ -130,7 +146,8 @@ public function get(array $params = []): array
130
146
}
131
147
132
148
// get messages from folderId
133
- $ emails = MsGraphAdmin::get ('users/ ' .$ this ->userId .'/messages? ' .$ params );
149
+ $ messages = $ this ->delta ? 'messages/delta ' : 'messages ' ;
150
+ $ emails = MsGraphAdmin::get ('users/ ' .$ this ->userId .'/ ' .$ messages .'? ' .$ params );
134
151
135
152
$ data = MsGraphAdmin::getPagination ($ emails , $ top , $ skip );
136
153
0 commit comments