From 2d8fcdc1f696012b01c4bfb04d1aa8c30cb8735f Mon Sep 17 00:00:00 2001 From: DumbergerL Date: Mon, 15 Jan 2024 09:41:45 +0100 Subject: [PATCH] update docs update unit-test --- docs/out/EventAPI.md | 14 +++++- src/Models/Events/Event/Event.php | 54 ++++++++++++++------- tests/Unit/Docs/EventRequestTest.php | 8 ++- tests/Unit/HttpMock/data/api_events.json | 12 +++-- tests/Unit/HttpMock/data/api_events_21.json | 6 ++- 5 files changed, 69 insertions(+), 25 deletions(-) diff --git a/docs/out/EventAPI.md b/docs/out/EventAPI.md index 8670a555..a744932c 100644 --- a/docs/out/EventAPI.md +++ b/docs/out/EventAPI.md @@ -32,9 +32,16 @@ var_dump( $christmasService->getName()); // Output: "Sunday Service" - var_dump( $christmasService->getDescription()); + // getDescription is deprecated. Use getNote instead. + var_dump( $christmasService->getNote()); // Output: "Service Description" + var_dump( $christmasService->getAppointmentId()); + // Output: "221" + + var_dump( $christmasService->getIsCanceled()); + // Output: false + var_dump( $christmasService->getStartDate()); // Output: "2021-09-02 20:15:00" @@ -48,7 +55,7 @@ // Output: "2021-09-02 22:00:00" var_dump( $christmasService->getChatStatus()); - // Output: false + // Output: "NOT_STARTED" var_dump( $christmasService->getPermissions()); // Output: null @@ -59,6 +66,9 @@ var_dump( $christmasService->getEventServices()); // Output: [] + var_dump( $christmasService->getAdminIds()); + // Output: [] + /** * Update Attachments -> see FileAPI diff --git a/src/Models/Events/Event/Event.php b/src/Models/Events/Event/Event.php index 610fc708..8f0f84e8 100644 --- a/src/Models/Events/Event/Event.php +++ b/src/Models/Events/Event/Event.php @@ -16,11 +16,16 @@ class Event extends AbstractModel protected ?string $guid = null; protected ?string $name = null; + /** + * @deprecated use note instead + */ protected ?string $description = null; + protected ?string $appointmentId = null; protected ?string $note = null; protected ?string $startDate = null; protected ?string $endDate = null; - protected ?bool $chatStatus = null; + protected ?bool $isCanceled = null; + protected ?string $chatStatus = null; protected ?array $permissions = null; protected ?DomainAttributeModel $calendar = null; protected ?EventAgenda $agenda = null; @@ -40,7 +45,7 @@ protected function fillArrayType(string $key, array $data): void $this->setCalendar(DomainAttributeModel::createModelFromData($data)); break; case "domainAttributes": - if(key_exists("startDate", $data)) { + if (key_exists("startDate", $data)) { $this->setStartDate($data["startDate"]); } break; @@ -128,6 +133,28 @@ public function setGuid(?string $guid): Event return $this; } + public function getAppointmentId(): ?string + { + return $this->appointmentId; + } + + public function setAppointmentId(?string $appointmentId): Event + { + $this->appointmentId = $appointmentId; + return $this; + } + + public function getIsCanceled(): ?bool + { + return $this->isCanceled; + } + + public function setIsCanceled(?bool $isCanceled): Event + { + $this->isCanceled = $isCanceled; + return $this; + } + /** * @return string|null */ @@ -147,8 +174,8 @@ public function setName(?string $name): Event } /** - * @deprecated use "note" * @return string|null + * @deprecated use "note" instead */ public function getDescription(): ?string { @@ -156,16 +183,16 @@ public function getDescription(): ?string } /** - * @deprecated use "note" * @param string|null $description * @return Event + * @deprecated use "note" instead */ public function setDescription(?string $description): Event { $this->description = $description; return $this; } - + /** * @return string|null */ @@ -173,7 +200,7 @@ public function getNote(): ?string { return $this->note; } - + /** * @param string|null $note * @return Event @@ -220,19 +247,12 @@ public function setEndDate(?string $endDate): Event return $this; } - /** - * @return bool|null - */ - public function getChatStatus(): ?bool + public function getChatStatus(): ?string { return $this->chatStatus; } - /** - * @param bool|null $chatStatus - * @return Event - */ - public function setChatStatus(?bool $chatStatus): Event + public function setChatStatus(?string $chatStatus): Event { $this->chatStatus = $chatStatus; return $this; @@ -309,7 +329,7 @@ public function setEventServices(?array $eventServices): Event $this->eventServices = $eventServices; return $this; } - + /** * @return array|null */ @@ -317,7 +337,7 @@ public function getAdminIds(): ?array { return $this->adminIds; } - + /** * @param array|null $adminIds * @return Event diff --git a/tests/Unit/Docs/EventRequestTest.php b/tests/Unit/Docs/EventRequestTest.php index f7e9eb0a..c8e8b2d5 100644 --- a/tests/Unit/Docs/EventRequestTest.php +++ b/tests/Unit/Docs/EventRequestTest.php @@ -31,15 +31,19 @@ public function testEventRequestDocExample() $this->assertEquals(21, $christmasService->getId()); $this->assertEquals("guid21", $christmasService->getGuid()); $this->assertEquals("Sunday Service", $christmasService->getName()); - $this->assertEquals("Service Description", $christmasService->getDescription()); + // getDescription is deprecated. Use getNote instead. + $this->assertEquals("Service Description", $christmasService->getNote()); + $this->assertEquals("221", $christmasService->getAppointmentId()); + $this->assertEquals(false, $christmasService->getIsCanceled()); $this->assertEquals("2021-09-02 20:15:00", $christmasService->getStartDate()); $this->assertEquals("2021-09-02 22:00:00", $christmasService->getEndDate()); $this->assertEquals("2021-09-02 20:15:00", $christmasService->getStartDateAsDateTime()?->format("Y-m-d H:i:s")); $this->assertEquals("2021-09-02 22:00:00", $christmasService->getEndDateAsDateTime()?->format("Y-m-d H:i:s")); - $this->assertEquals(false, $christmasService->getChatStatus()); + $this->assertEquals("NOT_STARTED", $christmasService->getChatStatus()); $this->assertEquals(null, $christmasService->getPermissions()); $this->assertEquals(null, $christmasService->getCalendar()); $this->assertEquals([], $christmasService->getEventServices()); + $this->assertEquals([], $christmasService->getAdminIds()); /** * Update Attachments -> see FileAPI diff --git a/tests/Unit/HttpMock/data/api_events.json b/tests/Unit/HttpMock/data/api_events.json index fe80186f..445dead6 100644 --- a/tests/Unit/HttpMock/data/api_events.json +++ b/tests/Unit/HttpMock/data/api_events.json @@ -2,30 +2,36 @@ "data": [ { "id": 21, + "appointmentId": 221, "guid": "guid21", "name": "Sunday Service", "description": "Service Description", + "note": "Service Description", "startDate": "2021-09-02 20:15:00", "endDate": "2021-09-02 22:00:00", - "chatStatus": false + "chatStatus": "NOT_STARTED" }, { "id": 22, + "appointmentId": 222, "guid": "guid22", "name": "Sunday Service", "description": "Service Description", + "note": "Service Description", "startDate": "2021-09-08 20:15:00", "endDate": "2021-09-08 22:00:00", - "chatStatus": true + "chatStatus": "NOT_STARTED" }, { "id": 23, + "appointmentId": 223, "guid": "guid23", "name": "Sunday Service", "description": "Service Description", + "note": "Service Description", "startDate": "2021-09-21 20:15:00", "endDate": "2021-09-21 22:00:00", - "chatStatus": false + "chatStatus": "NOT_STARTED" } ], "meta": { diff --git a/tests/Unit/HttpMock/data/api_events_21.json b/tests/Unit/HttpMock/data/api_events_21.json index 6f5174db..e7700490 100644 --- a/tests/Unit/HttpMock/data/api_events_21.json +++ b/tests/Unit/HttpMock/data/api_events_21.json @@ -4,9 +4,13 @@ "guid": "guid21", "name": "Sunday Service", "description": "Service Description", + "note": "Service Description", + "appointmentId": 1, "startDate": "2021-09-02 20:15:00", "endDate": "2021-09-02 22:00:00", - "chatStatus": "false", + "chatStatus": "NOT_STARTED", + "isCanceled": false, + "adminIds": [], "permissions": [], "calendar": [], "agenda": {