From 7e075d9ae0b026f0ad76ab2157237b003ca7a0bc Mon Sep 17 00:00:00 2001 From: Adam Whittingham Date: Tue, 18 May 2021 17:59:01 +0100 Subject: [PATCH] Add recurrence option to upsertEvent --- CHANGELOG.md | 6 +++++- dev-smoke-test.php | 19 ++++++++++++++++++- src/Cronofy.php | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f50f5e8..cf6f263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.4.0] +* add support for `recurrence` key on upsertEvent + ## [1.3.0] * add AvailablePeriod create, read, delete and bulkDelete [#105] [#106] * add support for empty descriptions [#103] @@ -80,7 +83,8 @@ [1.1.9]: https://github.com/cronofy/cronofy-php/releases/tag/v1.1.9 [1.1.10]: https://github.com/cronofy/cronofy-php/releases/tag/v1.1.10 [1.2.0]: https://github.com/cronofy/cronofy-php/releases/tag/v1.2.0 -[1.2.0]: https://github.com/cronofy/cronofy-php/releases/tag/v1.3.0 +[1.3.0]: https://github.com/cronofy/cronofy-php/releases/tag/v1.3.0 +[1.4.0]: https://github.com/cronofy/cronofy-php/releases/tag/v1.4.0 [#32]: https://github.com/cronofy/cronofy-php/pull/76 [#33]: https://github.com/cronofy/cronofy-php/pull/74 diff --git a/dev-smoke-test.php b/dev-smoke-test.php index a665607..34bfeda 100644 --- a/dev-smoke-test.php +++ b/dev-smoke-test.php @@ -23,7 +23,7 @@ $testEventId = 'php-smoke-test-001'; $testEventData = [ - 'calendar_id' => 'calendarID', + 'calendar_id' => $calendarId, 'event_id' => $testEventId, 'summary' => 'PHP SDK test event 001', 'description' => 'Just checking this thing is on!', @@ -100,3 +100,20 @@ foreach($periods->each() as $available_period){ print_r($available_period); } + +echo "\n"; +echo "Creating event with recurrence\n"; + +$recurrenceEventParams = $testEventData; +$recurrenceEventParams['recurrence'] = [ + "rules" => [ + [ + "frequency" => "daily", + "interval" => 2, + "count" => 3, + ], + ], +]; + +$cronofy->upsertEvent($recurrenceEventParams); + diff --git a/src/Cronofy.php b/src/Cronofy.php index 76766c7..475d0d5 100644 --- a/src/Cronofy.php +++ b/src/Cronofy.php @@ -561,6 +561,9 @@ private function baseUpsertEvent($postFields, $params) if (!empty($params['subscriptions'])) { $postFields['subscriptions'] = $params['subscriptions']; } + if (!empty($params['recurrence'])) { + $postFields['recurrence'] = $params['recurrence']; + } return $this->httpPost("/" . self::API_VERSION . "/calendars/" . $params['calendar_id'] . "/events", $postFields); }