File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,14 @@ public function get($folderId = null, $params = [])
93
93
$ top = request ('top ' , $ this ->top );
94
94
$ skip = request ('skip ' , $ this ->skip );
95
95
96
+ if ($ top === null ) {
97
+ $ top = 100 ;
98
+ }
99
+
100
+ if ($ skip === null ) {
101
+ $ skip = 0 ;
102
+ }
103
+
96
104
if ($ params == []) {
97
105
$ params = http_build_query ([
98
106
'$top ' => $ top ,
@@ -108,20 +116,15 @@ public function get($folderId = null, $params = [])
108
116
//get inbox from folders list
109
117
$ folder = MsGraph::get ("me/mailFolders? \$filter=startswith(displayName,' $ folder') " );
110
118
111
- //folder id
112
- $ folderId = $ folder ['value ' ][0 ]['id ' ];
119
+ if (isset ($ folder ['value ' ][0 ])) {
120
+ //folder id
121
+ $ folderId = $ folder ['value ' ][0 ]['id ' ];
113
122
114
- //get messages from folderId
115
- $ emails = MsGraph::get ("me/mailFolders/ $ folderId/messages? " .$ params );
116
-
117
- $ data = MsGraph::getPagination ($ emails , $ top , $ skip );
118
-
119
- return [
120
- 'emails ' => $ emails ,
121
- 'total ' => $ data ['total ' ],
122
- 'top ' => $ data ['top ' ],
123
- 'skip ' => $ data ['skip ' ],
124
- ];
123
+ //get messages from folderId
124
+ return MsGraph::get ("me/mailFolders/ $ folderId/messages? " .$ params );
125
+ } else {
126
+ return throw new Exception ('email folder not found ' );
127
+ }
125
128
}
126
129
127
130
public function find ($ id )
You can’t perform that action at this time.
0 commit comments