Skip to content

Commit

Permalink
Merge pull request #196 from BiKi05/branch-fieldsEvent
Browse files Browse the repository at this point in the history
Event: missing/deprecated fields
  • Loading branch information
DumbergerL authored Jan 15, 2024
2 parents f9d9ae1 + ab1ae4d commit 717d580
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fix GroupHierarchie ([PR192](https://github.com/5pm-HDH/churchtools-api/pull/192))
- Fix action dependency ([PR195](https://github.com/5pm-HDH/churchtools-api/pull/195))
- Fix GroupHierarchie test, Fix DB-Fields test ([PR192](https://github.com/5pm-HDH/churchtools-api/pull/192), [PR194](https://github.com/5pm-HDH/churchtools-api/pull/194))
- Fix breaking changes Event-API ([PR196](https://github.com/5pm-HDH/churchtools-api/pull/196))

## [2.0.0]

Expand Down
14 changes: 12 additions & 2 deletions docs/out/EventAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -59,6 +66,9 @@
var_dump( $christmasService->getEventServices());
// Output: []

var_dump( $christmasService->getAdminIds());
// Output: []


/**
* Update Attachments -> see FileAPI
Expand Down
85 changes: 74 additions & 11 deletions src/Models/Events/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ 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;
protected ?array $eventServices = [];
protected ?array $adminIds = [];

protected function fillArrayType(string $key, array $data): void
{
Expand All @@ -38,10 +45,13 @@ 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;
case "adminIds":
$this->setAdminIds($data);
break;
default:
$this->fillDefault($key, $data);
}
Expand Down Expand Up @@ -123,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
*/
Expand All @@ -143,6 +175,7 @@ public function setName(?string $name): Event

/**
* @return string|null
* @deprecated use "note" instead
*/
public function getDescription(): ?string
{
Expand All @@ -152,13 +185,32 @@ public function getDescription(): ?string
/**
* @param string|null $description
* @return Event
* @deprecated use "note" instead
*/
public function setDescription(?string $description): Event
{
$this->description = $description;
return $this;
}

/**
* @return string|null
*/
public function getNote(): ?string
{
return $this->note;
}

/**
* @param string|null $note
* @return Event
*/
public function setNote(?string $note): Event
{
$this->note = $note;
return $this;
}

/**
* @return string|null
*/
Expand Down Expand Up @@ -195,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;
Expand Down Expand Up @@ -284,4 +329,22 @@ public function setEventServices(?array $eventServices): Event
$this->eventServices = $eventServices;
return $this;
}

/**
* @return array|null
*/
public function getAdminIds(): ?array
{
return $this->adminIds;
}

/**
* @param array|null $adminIds
* @return Event
*/
public function setAdminIds(?array $adminIds): Event
{
$this->adminIds = $adminIds;
return $this;
}
}
8 changes: 6 additions & 2 deletions tests/Unit/Docs/EventRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions tests/Unit/HttpMock/data/api_events.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/HttpMock/data/api_events_21.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 717d580

Please sign in to comment.