Skip to content

Commit ff8b683

Browse files
committed
Add email admin delta messages
1 parent 9ecd3d8 commit ff8b683

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/AdminResources/Emails.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
class Emails extends MsGraphAdmin
99
{
10+
private ?bool $delta = null;
11+
1012
private string $userId = '';
1113

1214
private string $top = '';
1315

1416
private string $skip = '';
1517

18+
private string $search = '';
19+
1620
private string $subject = '';
1721

1822
private string $body = '';
@@ -106,6 +110,13 @@ public function attachments(array $attachments): static
106110
return $this;
107111
}
108112

113+
public function delta(?bool $delta = true): static
114+
{
115+
$this->delta = $delta;
116+
117+
return $this;
118+
}
119+
109120
/**
110121
* @throws Exception
111122
*/
@@ -117,6 +128,11 @@ public function get(array $params = []): array
117128

118129
$top = request('top', $this->top);
119130
$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+
}
120136

121137
if ($params == []) {
122138
$params = http_build_query([
@@ -130,7 +146,8 @@ public function get(array $params = []): array
130146
}
131147

132148
// 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);
134151

135152
$data = MsGraphAdmin::getPagination($emails, $top, $skip);
136153

0 commit comments

Comments
 (0)