Skip to content

Commit

Permalink
Merge pull request #188 from stollr/feature/group_type
Browse files Browse the repository at this point in the history
Added group type model, request and request builder
  • Loading branch information
DumbergerL authored Jan 9, 2024
2 parents f95a10a + 9e84836 commit 3cb801e
Show file tree
Hide file tree
Showing 12 changed files with 545 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added
- Retrieve, create and delete SongArrangement comments ([PR187](https://github.com/5pm-HDH/churchtools-api/pull/187))
- Get GroupTypes ([PR188](https://github.com/5pm-HDH/churchtools-api/pull/188))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
![integarion-test workflow](https://github.com/5pm-HDH/churchtools-api/actions/workflows/integration-tests.yml/badge.svg)

The ChurchTools-API Client is a PHP-based wrapper for the ChurchTools API and has been tested with ChurchTools
version <version>3.104.0</version>.
version <version>3.104.3</version>.

> [!NOTE]
> Version 2 has been launched, featuring a restructured code base and numerous new features. If you're upgrading from version 1 to 2, please consult the [Upgrade Guide](https://github.com/5pm-HDH/churchtools-api/blob/master/CHANGELOG.md#upgrade-guide---upgrading-from-v1-to-v2).
Expand Down
58 changes: 58 additions & 0 deletions docs/out/GroupAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,62 @@
// Output: []


```

## Group-Types

```php
use CTApi\Models\Groups\Group\GroupType;
use CTApi\Models\Groups\Group\GroupTypeRequest;

$groupTypes = GroupTypeRequest::all();

$groupTypeNames = array_map(function (GroupType $groupType) {
return $groupType->getName();
}, $groupTypes);

$groupTypeNameList = implode("/", $groupTypeNames);
var_dump( $groupTypeNameList);
// Output: "Dienst/Kleingruppe/Maßnahme/Merkmal"


```

```php
use CTApi\Models\Groups\Group\GroupType;
use CTApi\Models\Groups\Group\GroupTypeRequest;

$groupType = GroupTypeRequest::find(2);

var_dump( $groupType?->getName());
// Output: "Dienst"

var_dump( $groupType?->getNameTranslated());
// Output: "Dienst"

var_dump( $groupType?->getNamePlural());
// Output: "Dienste"

var_dump( $groupType?->getNamePluralTranslated());
// Output: "Dienste"

var_dump( $groupType?->getShorty());
// Output: "DT"

var_dump( $groupType?->getDescription());
// Output: ""

var_dump( $groupType?->getIsLeaderNecessary());
// Output: false

var_dump( $groupType?->getAvailableForNewPerson());
// Output: false

var_dump( $groupType?->getPermissionDepth());
// Output: 1

var_dump( $groupType?->getSortKey());
// Output: 0


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

## GroupMemberFields

{{ \CTApi\Test\Unit\Docs\GroupMemberFieldsTest.testGetFields }}
{{ \CTApi\Test\Unit\Docs\GroupMemberFieldsTest.testGetFields }}

## Group-Types

{{ \CTApi\Test\Unit\Docs\GroupTypeRequestTest.testGetAll }}

{{ \CTApi\Test\Unit\Docs\GroupTypeRequestTest.testFind }}
144 changes: 144 additions & 0 deletions src/Models/Groups/Group/GroupType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php

namespace CTApi\Models\Groups\Group;

use CTApi\Models\AbstractModel;
use CTApi\Traits\Model\FillWithData;
use CTApi\Traits\Model\MetaAttribute;

class GroupType extends AbstractModel
{
use FillWithData, MetaAttribute;


protected ?bool $availableForNewPerson = null;
protected ?bool $isLeaderNecessary = null;
protected ?string $name = null;
protected ?string $namePlural = null;
protected ?string $namePluralTranslated = null;
protected ?string $nameTranslated = null;
protected ?int $permissionDepth = null;
protected ?string $shorty = null;
protected ?int $sortKey = null;
protected ?string $description = null;

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

public function getAvailableForNewPerson(): ?bool
{
return $this->availableForNewPerson;
}

public function setAvailableForNewPerson(?bool $availableForNewPerson): static
{
$this->availableForNewPerson = $availableForNewPerson;
return $this;
}

public function getIsLeaderNecessary(): ?bool
{
return $this->isLeaderNecessary;
}

public function setIsLeaderNecessary(?bool $isLeaderNecessary): static
{
$this->isLeaderNecessary = $isLeaderNecessary;
return $this;
}

public function getName(): ?string
{
return $this->name;
}

public function setName(?string $name): static
{
$this->name = $name;
return $this;
}

public function getNamePlural(): ?string
{
return $this->namePlural;
}

public function setNamePlural(?string $namePlural): static
{
$this->namePlural = $namePlural;
return $this;
}

public function getNamePluralTranslated(): ?string
{
return $this->namePluralTranslated;
}

public function setNamePluralTranslated(?string $namePluralTranslated): static
{
$this->namePluralTranslated = $namePluralTranslated;
return $this;
}

public function getNameTranslated(): ?string
{
return $this->nameTranslated;
}

public function setNameTranslated(?string $nameTranslated): static
{
$this->nameTranslated = $nameTranslated;
return $this;
}

public function getPermissionDepth(): ?int
{
return $this->permissionDepth;
}

public function setPermissionDepth(?int $permissionDepth): static
{
$this->permissionDepth = $permissionDepth;
return $this;
}

public function getShorty(): ?string
{
return $this->shorty;
}

public function setShorty(?string $shorty): static
{
$this->shorty = $shorty;
return $this;
}

public function getSortKey(): ?int
{
return $this->sortKey;
}

public function setSortKey(?int $sortKey): static
{
$this->sortKey = $sortKey;
return $this;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): GroupType
{
$this->description = $description;
return $this;
}
}
33 changes: 33 additions & 0 deletions src/Models/Groups/Group/GroupTypeRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace CTApi\Models\Groups\Group;


class GroupTypeRequest
{
public static function all(): array
{
return (new GroupTypeRequestBuilder())->all();
}

public static function where(string $key, $value): GroupTypeRequestBuilder
{
return (new GroupTypeRequestBuilder())->where($key, $value);
}

public static function orderBy(string $key, $orderAscending = true): GroupTypeRequestBuilder
{
return (new GroupTypeRequestBuilder())->orderBy($key, $orderAscending);
}

public static function findOrFail(int $id): GroupType
{
return (new GroupTypeRequestBuilder())->findOrFail($id);
}

public static function find(int $id): ?GroupType
{
return (new GroupTypeRequestBuilder())->find($id);
}

}
18 changes: 18 additions & 0 deletions src/Models/Groups/Group/GroupTypeRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace CTApi\Models\Groups\Group;

use CTApi\Models\AbstractRequestBuilder;

class GroupTypeRequestBuilder extends AbstractRequestBuilder
{
protected function getApiEndpoint(): string
{
return '/api/group/grouptypes';
}

protected function getModelClass(): string
{
return GroupType::class;
}
}
Loading

0 comments on commit 3cb801e

Please sign in to comment.