Skip to content

Commit

Permalink
Merge pull request #130 from 5pm-HDH/group-meetings
Browse files Browse the repository at this point in the history
feat(group-meetings): add group meetings api
  • Loading branch information
DumbergerL authored Nov 11, 2022
2 parents 31bb54a + d49b4ff commit 31546ae
Show file tree
Hide file tree
Showing 15 changed files with 791 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Update GroupMembers ([PR124](https://github.com/5pm-HDH/churchtools-api/pull/124))
- CCLI-Request Lyrics and Chordsheet ([PR127](https://github.com/5pm-HDH/churchtools-api/pull/127))
- Extended exception handling of invalid or empty email addresses passed to the person API ([PR125](https://github.com/5pm-HDH/churchtools-api/pull/125))
- Group-Meetings Request ([PR130](https://github.com/5pm-HDH/churchtools-api/pull/130))

### Changed

Expand Down
82 changes: 81 additions & 1 deletion docs/out/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,84 @@
// Delete Group-Membership
GroupMemberRequest::removeMember($groupId, $personId);

```
```

## Group-Meetings

```php
use CTApi\CTConfig;
use CTApi\Models\Group;
use CTApi\Requests\GroupMeetingRequest;
use CTApi\Requests\GroupRequest;

$meetings = $this->group->requestGroupMeetings()
?->where("start_date", "2022-11-01")
->where("end_date", "2022-11-15")
->get();

$meeting = $meetings[0];

var_dump( $meeting->getId());
// Output: 2652

var_dump( $meeting->getGroupId());
// Output: 21

var_dump( $meeting->getDateFrom());
// Output: "2022-11-09T18:30:00Z"

var_dump( $meeting->getDateTo());
// Output: "2022-11-09T18:30:00Z"

var_dump( $meeting->getIsCompleted());
// Output: true

var_dump( $meeting->getIsCanceled());
// Output: false

var_dump( $meeting->getHasEditingStarted());
// Output: true

var_dump( $meeting->getNumGuests());
// Output: 5

var_dump( $meeting->getComment());
// Output: "Hello World"


var_dump( $meeting?->getStatistics()->getPresent());
// Output: 2

var_dump( $meeting?->getStatistics()->getAbsent());
// Output: 1

var_dump( $meeting?->getStatistics()->getUnsure());
// Output: 0


```

```php
use CTApi\CTConfig;
use CTApi\Models\Group;
use CTApi\Requests\GroupMeetingRequest;
use CTApi\Requests\GroupRequest;

CTConfig::enableDebugging();
$meetings = GroupMeetingRequest::forGroup(21)->get();
$meeting = $meetings[0];

$meetingMembers = $meeting->requestMembers()->get();
$meetingMember = $meetingMembers[0];

var_dump( $meetingMember->getIsCheckedIn());
// Output: true

var_dump( $meetingMember->getStatus());
// Output: "present"


$groupMember = $meetingMember->getMember();
// see GroupMember-Model

```
8 changes: 7 additions & 1 deletion docs/src/ressources/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@

## Add, remove and update group-members:

{{ \Tests\Unit\Docs\GroupMemberUpdateRequestTest.testAddGroupMember }}
{{ \Tests\Unit\Docs\GroupMemberUpdateRequestTest.testAddGroupMember }}

## Group-Meetings

{{ \Tests\Unit\Docs\GroupMeetingRequestTest.testRetrieveGroupRequest }}

{{ \Tests\Unit\Docs\GroupMeetingRequestTest.testRetrieveGroupMemberRequest }}
9 changes: 9 additions & 0 deletions src/Models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use CTApi\Requests\FileRequestBuilder;
use CTApi\Requests\GroupHierarchieChildrenRequest;
use CTApi\Requests\GroupHierarchieParentsRequest;
use CTApi\Requests\GroupMeetingRequestBuilder;
use CTApi\Requests\GroupMemberRequestBuilder;

class Group extends AbstractModel
Expand Down Expand Up @@ -92,6 +93,14 @@ public function requestGroupImage(): ?FileRequestBuilder
return null;
}

public function requestGroupMeetings(): ?GroupMeetingRequestBuilder
{
if (!is_null($this->getId())) {
return new GroupMeetingRequestBuilder($this->getIdAsInteger());
}
return null;
}

/**
* @param string|null $id
* @return Group
Expand Down
237 changes: 237 additions & 0 deletions src/Models/GroupMeeting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<?php


namespace CTApi\Models;


use CTApi\Models\Traits\FillWithData;
use CTApi\Models\Traits\MetaAttribute;
use CTApi\Requests\GroupMeetingMemberRequestBuilder;

class GroupMeeting extends AbstractModel
{
use FillWithData, MetaAttribute;

protected ?int $groupId = null;
protected ?string $dateFrom = null;
protected ?string $dateTo = null;
protected ?bool $isCompleted = null;
protected ?bool $isCanceled = null;
protected ?bool $hasEditingStarted = null;
protected ?int $numGuests = null;
protected ?string $comment = null;
protected ?string $pollResult = null;
protected ?GroupMeetingStatistics $statistics = null;

protected function fillArrayType(string $key, array $data): void
{
switch ($key) {
case "statistics":
$this->statistics = GroupMeetingStatistics::createModelFromData($data);
break;
case "meta":
$this->meta = Meta::createModelFromData($data);
break;
default:
$this->fillDefault($key, $data);
}
}

public function requestMembers(): ?GroupMeetingMemberRequestBuilder
{
if (!is_null($this->getId()) && !is_null($this->groupId)) {
return new GroupMeetingMemberRequestBuilder($this->groupId, $this->getIdAsInteger());
}
return null;
}

/**
* @param string|null $id
* @return GroupMeeting
*/
public function setId(?string $id): GroupMeeting
{
$this->id = $id;
return $this;
}

/**
* @return int|null
*/
public function getGroupId(): ?int
{
return $this->groupId;
}

/**
* @param int|null $groupId
* @return GroupMeeting
*/
public function setGroupId(?int $groupId): GroupMeeting
{
$this->groupId = $groupId;
return $this;
}

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

/**
* @param string|null $dateFrom
* @return GroupMeeting
*/
public function setDateFrom(?string $dateFrom): GroupMeeting
{
$this->dateFrom = $dateFrom;
return $this;
}

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

/**
* @param string|null $dateTo
* @return GroupMeeting
*/
public function setDateTo(?string $dateTo): GroupMeeting
{
$this->dateTo = $dateTo;
return $this;
}

/**
* @return bool|null
*/
public function getIsCompleted(): ?bool
{
return $this->isCompleted;
}

/**
* @param bool|null $isCompleted
* @return GroupMeeting
*/
public function setIsCompleted(?bool $isCompleted): GroupMeeting
{
$this->isCompleted = $isCompleted;
return $this;
}

/**
* @return bool|null
*/
public function getIsCanceled(): ?bool
{
return $this->isCanceled;
}

/**
* @param bool|null $isCanceled
* @return GroupMeeting
*/
public function setIsCanceled(?bool $isCanceled): GroupMeeting
{
$this->isCanceled = $isCanceled;
return $this;
}

/**
* @return bool|null
*/
public function getHasEditingStarted(): ?bool
{
return $this->hasEditingStarted;
}

/**
* @param bool|null $hasEditingStarted
* @return GroupMeeting
*/
public function setHasEditingStarted(?bool $hasEditingStarted): GroupMeeting
{
$this->hasEditingStarted = $hasEditingStarted;
return $this;
}

/**
* @return int|null
*/
public function getNumGuests(): ?int
{
return $this->numGuests;
}

/**
* @param int|null $numGuests
* @return GroupMeeting
*/
public function setNumGuests(?int $numGuests): GroupMeeting
{
$this->numGuests = $numGuests;
return $this;
}

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

/**
* @param string|null $comment
* @return GroupMeeting
*/
public function setComment(?string $comment): GroupMeeting
{
$this->comment = $comment;
return $this;
}

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

/**
* @param string|null $pollResult
* @return GroupMeeting
*/
public function setPollResult(?string $pollResult): GroupMeeting
{
$this->pollResult = $pollResult;
return $this;
}

/**
* @return GroupMeetingStatistics|null
*/
public function getStatistics(): ?GroupMeetingStatistics
{
return $this->statistics;
}

/**
* @param GroupMeetingStatistics|null $statistics
* @return GroupMeeting
*/
public function setStatistics(?GroupMeetingStatistics $statistics): GroupMeeting
{
$this->statistics = $statistics;
return $this;
}
}
Loading

0 comments on commit 31546ae

Please sign in to comment.