Skip to content

Commit

Permalink
Merge pull request #64 from 5pm-HDH/feat/group-information
Browse files Browse the repository at this point in the history
GroupInformation
  • Loading branch information
DumbergerL authored Feb 11, 2022
2 parents d3c8150 + 024bcca commit ba789d8
Show file tree
Hide file tree
Showing 13 changed files with 637 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [1.3.1] - 2022-02-11

### Fixed

- add TargetGroup, GroupPlace to [Group-Information](https://github.com/5pm-HDH/churchtools-api/pull/64)
- generate Registration-Link in [PublicGroup](https://github.com/5pm-HDH/churchtools-api/pull/64)

## [1.3.0] - 2022-02-11

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ the Requests retrieve. More informations can be found in the documentation.
All APIs with examples:
* [Person-API](/docs/PersonAPI.md)
* [Group-API](/docs/GroupAPI.md)
* [PublicGroup-API](/docs/PublicGroupAPI.md)
* [Event-API](/docs/EventAPI.md)
* [Song-API](/docs/SongAPI.md)
* [Service-API](/docs/ServiceAPI.md)
Expand Down
69 changes: 63 additions & 6 deletions docs/PublicGroupAPI.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Public-Group API

Load Data of Group Homepage with Hash-String. This route is public, so no authentication of the CTConfig is necessary.

```php
use \CTApi\Requests\PublicGroupRequest;

$groupHomepage = PublicGroupRequest::get("SOME_HASH_STRING");
$groupHomepage = PublicGroupRequest::get("wryawBH318GLHasgm27awB0c241aj");

$groupHomepage->getId();
$groupHomepage->getIsEnabled();
Expand All @@ -14,12 +16,67 @@ $groupHomepage->getDefaultView();
$groupHomepage->getSortBy();
$groupHomepage->getOrderDirection();

$groupHomepage->getRandomUrl();
// RandomUrl = "SOME_HASH_STRING"
$hash = $groupHomepage->getRandomUrl();
echo ("Hash: ".$hash);
// OUTPUT: Hash: wryawBH318GLHasgm27awB0c241aj

$groupHomepage->getMeta();

// Array of PublicGroups:
$groups = $groupHomepage->getGroups();
// Array of PublicGroups
// PublicGroup is a subtype of Group

```
```

The PublicGroup-Model is a Subtype of Group. So all methods of Group will be available in
PublicGroup: [GroupAPI](GroupAPI.md)

Further the PublicGroup-Model contains the following Methods:

```php
use \CTApi\Requests\PublicGroupRequest;

$groupHomepage = PublicGroupRequest::get("wryawBH318GLHasgm27awB0c241aj");
$group = $groupHomepage->getGroups()[0];

echo ("Id: ". $group->getId());
// OUTPUT: Id: 221
echo ("Headline: ". $group->getSignUpHeadline());
// OUTPUT: Headline: Teilnahme beantragen
echo ("Max. Teilnehmer: ". $group->getMaxMemberCount());
// OUTPUT: Max. Teilnehmer: 42
echo ("Akt. Teilnehmer: ". $group->getCurrentMemberCount());
// OUTPUT: Akt. Teilnehmer: 30
echo ("Name: ". $group->getName());
// OUTPUT: Name: Jugendwoche Kraftberg

// GroupInformation
echo ("Termin: ".$group->getInformation()?->getMeetingTime());
// OUTPUT: Termin: Freitag, 01.03. um 16h bis Sonntag 03.03. um 24h
echo ("Kategorie: ".$group->getInformation()?->getGroupCategory()?->getNameTranslated());
// OUTPUT: Kategorie: Freizeit
echo ("Zielgruppe: ".$group->getInformation()?->getTargetGroup()?->getNameTranslated());
// OUTPUT: Zielgruppe: Jugendliche
echo ("Beschreibung: ".$group->getInformation()?->getNote());
// OUTPUT: Beschreibung: Eine spannende Freizeit erwartet dich!
echo ("Bild-Url: ".$group->getInformation()?->getImageUrl());
// OUTPUT: Bild-Url: https://test.church.tools/images/9281/2928912ioha8921ns891bs9

echo ("Location: ".$group->getInformation()?->getGroupPlaces()[0]->getName());
// OUTPUT: Location: Freizeitheim Rosenberg
echo ("Stadt: ".$group->getInformation()?->getGroupPlaces()[0]->getCity());
// OUTPUT: Stadt: Heilbronn
echo ("GeoLat: ".$group->getInformation()?->getGroupPlaces()[0]->getGeoLat());
// OUTPUT: GeoLat: 92.2912
echo ("GeoLng: ".$group->getInformation()?->getGroupPlaces()[0]->getGeoLng());
// OUTPUT: GeoLng: 2.291

```

For More-Informations on the Attributes have a look at the SourceCode:

- [Group](../src/Models/Group.php)
- [PublicGroup](../src/Models/PublicGroup.php)
- [GroupInformation](../src/Models/GroupInformation.php)
- [TargetGroup](../src/Models/TargetGroup.php)
- [GroupCategory](../src/Models/GroupCategory.php)
- [GroupPlace](../src/Models/GroupPlace.php)
2 changes: 2 additions & 0 deletions docs/src/DocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ private static function parseResourceToDocName(string $resource): string

private static function processResourceContent(string $resource): string
{
\CTApi\CTLog::enableConsoleLog();
\CTApi\CTLog::getLog()->emergency("GenerateDocs of: ".$resource);
$content = file_get_contents(self::$RESOURCES_DIR . $resource);

$contentParts = explode('```', $content);
Expand Down
53 changes: 47 additions & 6 deletions docs/src/ressources/PublicGroupAPI.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Public-Group API

Load Data of Group Homepage with Hash-String. This route is public, so no authentication of the CTConfig is necessary.

```php
use \CTApi\Requests\PublicGroupRequest;

$groupHomepage = PublicGroupRequest::get("SOME_HASH_STRING");
$groupHomepage = PublicGroupRequest::get("wryawBH318GLHasgm27awB0c241aj");

$groupHomepage->getId();
$groupHomepage->getIsEnabled();
Expand All @@ -14,11 +16,50 @@ $groupHomepage->getDefaultView();
$groupHomepage->getSortBy();
$groupHomepage->getOrderDirection();

$groupHomepage->getRandomUrl();
// RandomUrl = "SOME_HASH_STRING"
$hash = $groupHomepage->getRandomUrl();
dd("Hash: ".$hash);

$groupHomepage->getMeta();

// Array of PublicGroups:
$groups = $groupHomepage->getGroups();
// Array of PublicGroups
// PublicGroup is a subtype of Group
```
```

The PublicGroup-Model is a Subtype of Group. So all methods of Group will be available in
PublicGroup: [GroupAPI](GroupAPI.md)

Further the PublicGroup-Model contains the following Methods:

```php
use \CTApi\Requests\PublicGroupRequest;

$groupHomepage = PublicGroupRequest::get("wryawBH318GLHasgm27awB0c241aj");
$group = $groupHomepage->getGroups()[0];

dd("Id: ". $group->getId());
dd("Headline: ". $group->getSignUpHeadline());
dd("Max. Teilnehmer: ". $group->getMaxMemberCount());
dd("Akt. Teilnehmer: ". $group->getCurrentMemberCount());
dd("Name: ". $group->getName());

// GroupInformation
dd("Termin: ".$group->getInformation()?->getMeetingTime());
dd("Kategorie: ".$group->getInformation()?->getGroupCategory()?->getNameTranslated());
dd("Zielgruppe: ".$group->getInformation()?->getTargetGroup()?->getNameTranslated());
dd("Beschreibung: ".$group->getInformation()?->getNote());
dd("Bild-Url: ".$group->getInformation()?->getImageUrl());

dd("Location: ".$group->getInformation()?->getGroupPlaces()[0]->getName());
dd("Stadt: ".$group->getInformation()?->getGroupPlaces()[0]->getCity());
dd("GeoLat: ".$group->getInformation()?->getGroupPlaces()[0]->getGeoLat());
dd("GeoLng: ".$group->getInformation()?->getGroupPlaces()[0]->getGeoLng());
```

For More-Informations on the Attributes have a look at the SourceCode:

- [Group](../src/Models/Group.php)
- [PublicGroup](../src/Models/PublicGroup.php)
- [GroupInformation](../src/Models/GroupInformation.php)
- [TargetGroup](../src/Models/TargetGroup.php)
- [GroupCategory](../src/Models/GroupCategory.php)
- [GroupPlace](../src/Models/GroupPlace.php)
89 changes: 89 additions & 0 deletions src/Models/GroupCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php


namespace CTApi\Models;


use CTApi\Models\Traits\FillWithData;

class GroupCategory
{
use FillWithData;

protected ?string $id = null;
protected ?string $name = null;
protected ?string $nameTranslated = null;
protected ?string $sortKey = null;

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

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

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

/**
* @param string|null $name
* @return GroupCategory
*/
public function setName(?string $name): GroupCategory
{
$this->name = $name;
return $this;
}

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

/**
* @param string|null $nameTranslated
* @return GroupCategory
*/
public function setNameTranslated(?string $nameTranslated): GroupCategory
{
$this->nameTranslated = $nameTranslated;
return $this;
}

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

/**
* @param string|null $sortKey
* @return GroupCategory
*/
public function setSortKey(?string $sortKey): GroupCategory
{
$this->sortKey = $sortKey;
return $this;
}
}
54 changes: 45 additions & 9 deletions src/Models/GroupInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,29 @@ class GroupInformation

protected ?string $meetingTime = null;
protected ?array $weekday = [];
protected ?array $groupCategory = [];
protected ?GroupCategory $groupCategory = null;
protected ?array $ageGroups = [];
protected ?array $targetGroup = [];
protected ?TargetGroup $targetGroup = null;
protected ?string $note = null;
protected ?string $imageUrl = null;
protected ?array $groupPlaces = null;

protected function fillArrayType(string $key, array $data): void
{
switch ($key) {
case "groupCategory":
$this->groupCategory = GroupCategory::createModelFromData($data);
break;
case "targetGroup":
$this->targetGroup = TargetGroup::createModelFromData($data);
break;
case "groupPlaces":
$this->groupPlaces = GroupPlace::createModelsFromArray($data);
break;
default:
$this->{$key} = $data;
}
}

/**
* @return string|null
Expand Down Expand Up @@ -57,16 +75,34 @@ public function setWeekday(?array $weekday): GroupInformation
/**
* @return array|null
*/
public function getGroupCategory(): ?array
public function getGroupPlaces(): ?array
{
return $this->groupPlaces;
}

/**
* @param array|null $groupPlaces
* @return GroupInformation
*/
public function setGroupPlaces(?array $groupPlaces): GroupInformation
{
$this->groupPlaces = $groupPlaces;
return $this;
}

/**
* @return GroupCategory|null
*/
public function getGroupCategory(): ?GroupCategory
{
return $this->groupCategory;
}

/**
* @param array|null $groupCategory
* @param GroupCategory|null $groupCategory
* @return GroupInformation
*/
public function setGroupCategory(?array $groupCategory): GroupInformation
public function setGroupCategory(?GroupCategory $groupCategory): GroupInformation
{
$this->groupCategory = $groupCategory;
return $this;
Expand All @@ -91,18 +127,18 @@ public function setAgeGroups(?array $ageGroups): GroupInformation
}

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

/**
* @param array|null $targetGroup
* @param TargetGroup|null $targetGroup
* @return GroupInformation
*/
public function setTargetGroup(?array $targetGroup): GroupInformation
public function setTargetGroup(?TargetGroup $targetGroup): GroupInformation
{
$this->targetGroup = $targetGroup;
return $this;
Expand Down
Loading

0 comments on commit ba789d8

Please sign in to comment.