@@ -26,6 +26,11 @@ class ZoomApiService
2626 */
2727 protected array $ settings ;
2828
29+ /**
30+ * @var VariableFrontend
31+ */
32+ protected $ requestsCache ;
33+
2934 /**
3035 * @throws Exception
3136 */
@@ -62,10 +67,19 @@ private function generateJwt(string $zoomApiKey, string $zoomApiSecret): string
6267 */
6368 public function getUpcomingMeetings (): array
6469 {
65- return $ this ->fetchData (
70+ $ cacheEntryIdentifier = 'upcomingMeetings ' ;
71+
72+ /** @var array|bool $upcomingMeetings */
73+ if (($ upcomingMeetings = $ this ->requestsCache ->get ($ cacheEntryIdentifier )) !== false ) {
74+ return $ upcomingMeetings ;
75+ }
76+
77+ $ upcomingMeetings = $ this ->fetchData (
6678 "users/me/meetings?type=upcoming " ,
6779 'meetings '
6880 );
81+ $ this ->requestsCache ->set ($ cacheEntryIdentifier , $ upcomingMeetings );
82+ return $ upcomingMeetings ;
6983 }
7084
7185 /**
@@ -78,6 +92,13 @@ public function getUpcomingMeetings(): array
7892 */
7993 public function getRecordings ($ from , $ to ): array
8094 {
95+ $ cacheEntryIdentifier = sprintf ('recordings_%s_%s ' , $ from , $ to );
96+
97+ /** @var array|bool $recordings */
98+ if (($ recordings = $ this ->requestsCache ->get ($ cacheEntryIdentifier )) !== false ) {
99+ return $ recordings ;
100+ }
101+
81102 if (is_string ($ from )) {
82103 $ from = new DateTimeImmutable ($ from );
83104 } elseIf ($ from instanceof DateTime) {
@@ -94,7 +115,9 @@ public function getRecordings($from, $to): array
94115 throw new \InvalidArgumentException ('The from date must be after the to date ' );
95116 }
96117
97- return $ this ->fetchDataForDateRange ($ from , $ to );
118+ $ recordings = $ this ->fetchDataForDateRange ($ from , $ to );
119+ $ this ->requestsCache ->set ($ cacheEntryIdentifier , $ recordings );
120+ return $ recordings ;
98121 }
99122
100123 private function fetchDataForDateRange (DateTimeImmutable $ from , DateTimeImmutable $ to ): array
0 commit comments