Skip to content

Commit

Permalink
Factor out batch push code for reuse on app side (#18)
Browse files Browse the repository at this point in the history
* Factor out batch push code for reuse on app side

* Add parameter description

* Clean up

---------

Co-authored-by: Scott Kim <[email protected]>
  • Loading branch information
scottyks and Scott Kim authored Mar 11, 2024
1 parent 920af43 commit f157b49
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ public function getInstancesCollection(string $id, ?InstancesRequestBuilderGetQu
* @throws \Exception|\Throwable
*/
public function push(array $params = [], array $args = []): void
{
$eventsToWrite = $this->getLocalEvents();
$this->batchPush($eventsToWrite, $params, $args);
}

/**
* @param Event[] $eventsToWrite
* @param array<string, string> $params
* @param array<string, mixed> $args
* @throws \JsonException
* @throws \Exception|\Throwable
*/
protected function batchPush(array $eventsToWrite, array $params = [], array $args = []): void
{
$this->logger?->info('Pushing batch events to outlook ...', [
'params' => http_build_query($params)
Expand All @@ -246,7 +259,6 @@ public function push(array $params = [], array $args = []): void

$batchRequestConfiguration = $this->getEventPostBatchRequestConfiguration();

$eventsToWrite = $this->getLocalEvents();
$chunks = array_chunk($eventsToWrite, static::BATCH_BY);

foreach ($chunks as $chunk) {
Expand Down

0 comments on commit f157b49

Please sign in to comment.