From 8e8b4ff04bb7bf797a904dbd537917d0e88396bc Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 14:17:35 +0100 Subject: [PATCH 1/7] feat(target-group): add TargetGroup-Model to GroupInformation #62 --- src/Models/GroupCategory.php | 89 +++++++++++++++++++ src/Models/GroupInformation.php | 34 ++++--- src/Models/TargetGroup.php | 89 +++++++++++++++++++ .../Requests/PublicGroupRequestTest.php | 12 +++ 4 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 src/Models/GroupCategory.php create mode 100644 src/Models/TargetGroup.php diff --git a/src/Models/GroupCategory.php b/src/Models/GroupCategory.php new file mode 100644 index 00000000..c8f5d7db --- /dev/null +++ b/src/Models/GroupCategory.php @@ -0,0 +1,89 @@ +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; + } +} \ No newline at end of file diff --git a/src/Models/GroupInformation.php b/src/Models/GroupInformation.php index 48b2f681..ed2124b6 100644 --- a/src/Models/GroupInformation.php +++ b/src/Models/GroupInformation.php @@ -12,12 +12,26 @@ 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 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; + default: + $this->{$key} = $data; + } + } + /** * @return string|null */ @@ -55,18 +69,18 @@ public function setWeekday(?array $weekday): GroupInformation } /** - * @return array|null + * @return GroupCategory|null */ - public function getGroupCategory(): ?array + 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; @@ -91,18 +105,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; diff --git a/src/Models/TargetGroup.php b/src/Models/TargetGroup.php new file mode 100644 index 00000000..7ad60a45 --- /dev/null +++ b/src/Models/TargetGroup.php @@ -0,0 +1,89 @@ +id; + } + + /** + * @param string|null $id + * @return TargetGroup + */ + public function setId(?string $id): TargetGroup + { + $this->id = $id; + return $this; + } + + /** + * @return string|null + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param string|null $name + * @return TargetGroup + */ + public function setName(?string $name): TargetGroup + { + $this->name = $name; + return $this; + } + + /** + * @return string|null + */ + public function getNameTranslated(): ?string + { + return $this->nameTranslated; + } + + /** + * @param string|null $nameTranslated + * @return TargetGroup + */ + public function setNameTranslated(?string $nameTranslated): TargetGroup + { + $this->nameTranslated = $nameTranslated; + return $this; + } + + /** + * @return string|null + */ + public function getSortKey(): ?string + { + return $this->sortKey; + } + + /** + * @param string|null $sortKey + * @return TargetGroup + */ + public function setSortKey(?string $sortKey): TargetGroup + { + $this->sortKey = $sortKey; + return $this; + } +} \ No newline at end of file diff --git a/tests/integration/Requests/PublicGroupRequestTest.php b/tests/integration/Requests/PublicGroupRequestTest.php index c01d83d9..e5bd10db 100644 --- a/tests/integration/Requests/PublicGroupRequestTest.php +++ b/tests/integration/Requests/PublicGroupRequestTest.php @@ -4,6 +4,9 @@ namespace Tests\Integration\Requests; +use CTApi\Models\GroupCategory; +use CTApi\Models\GroupInformation; +use CTApi\Models\TargetGroup; use CTApi\Requests\PublicGroupRequest; use Tests\Integration\TestCaseAuthenticated; use Tests\Integration\TestData; @@ -41,6 +44,15 @@ public function testGetPublicGroup() $this->assertNotNull($foundGroup); $this->assertEquals($this->groupName, $foundGroup->getName()); + + $this->assertNotNull($foundGroup->getInformation()); + $this->assertInstanceOf(GroupInformation::class, $foundGroup->getInformation()); + + $this->assertNotNull($foundGroup->getInformation()->getGroupCategory()); + $this->assertInstanceOf(GroupCategory::class, $foundGroup->getInformation()->getGroupCategory()); + + $this->assertNotNull($foundGroup->getInformation()->getTargetGroup()); + $this->assertInstanceOf(TargetGroup::class, $foundGroup->getInformation()->getTargetGroup()); } } \ No newline at end of file From 9fda4ef78d69519f5ac1c0631de964064543250d Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 14:29:22 +0100 Subject: [PATCH 2/7] feat(group-places): add GroupPlaces-Model #61 --- src/Models/GroupInformation.php | 22 ++ src/Models/GroupPlaces.php | 196 ++++++++++++++++++ .../Requests/PublicGroupRequestTest.php | 5 + 3 files changed, 223 insertions(+) create mode 100644 src/Models/GroupPlaces.php diff --git a/src/Models/GroupInformation.php b/src/Models/GroupInformation.php index ed2124b6..bed97673 100644 --- a/src/Models/GroupInformation.php +++ b/src/Models/GroupInformation.php @@ -17,6 +17,7 @@ class GroupInformation protected ?TargetGroup $targetGroup = null; protected ?string $note = null; protected ?string $imageUrl = null; + protected ?GroupPlaces $groupPlaces = null; protected function fillArrayType(string $key, array $data): void { @@ -27,6 +28,9 @@ protected function fillArrayType(string $key, array $data): void case "targetGroup": $this->targetGroup = TargetGroup::createModelFromData($data); break; + case "groupPlaces": + $this->groupPlaces = GroupPlaces::createModelFromData($data); + break; default: $this->{$key} = $data; } @@ -68,6 +72,24 @@ public function setWeekday(?array $weekday): GroupInformation return $this; } + /** + * @return GroupPlaces|null + */ + public function getGroupPlaces(): ?GroupPlaces + { + return $this->groupPlaces; + } + + /** + * @param GroupPlaces|null $groupPlaces + * @return GroupInformation + */ + public function setGroupPlaces(?GroupPlaces $groupPlaces): GroupInformation + { + $this->groupPlaces = $groupPlaces; + return $this; + } + /** * @return GroupCategory|null */ diff --git a/src/Models/GroupPlaces.php b/src/Models/GroupPlaces.php new file mode 100644 index 00000000..2f6fb424 --- /dev/null +++ b/src/Models/GroupPlaces.php @@ -0,0 +1,196 @@ +createdPerson = Person::createModelFromData($data); + break; + default: + $this->{$key} = $data; + } + } + + /** + * @return string|null + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param string|null $name + * @return GroupPlaces + */ + public function setName(?string $name): GroupPlaces + { + $this->name = $name; + return $this; + } + + /** + * @return string|null + */ + public function getDistrict(): ?string + { + return $this->district; + } + + /** + * @param string|null $district + * @return GroupPlaces + */ + public function setDistrict(?string $district): GroupPlaces + { + $this->district = $district; + return $this; + } + + /** + * @return string|null + */ + public function getPostalcode(): ?string + { + return $this->postalcode; + } + + /** + * @param string|null $postalcode + * @return GroupPlaces + */ + public function setPostalcode(?string $postalcode): GroupPlaces + { + $this->postalcode = $postalcode; + return $this; + } + + /** + * @return string|null + */ + public function getCity(): ?string + { + return $this->city; + } + + /** + * @param string|null $city + * @return GroupPlaces + */ + public function setCity(?string $city): GroupPlaces + { + $this->city = $city; + return $this; + } + + /** + * @return string|null + */ + public function getMarkerUrl(): ?string + { + return $this->markerUrl; + } + + /** + * @param string|null $markerUrl + * @return GroupPlaces + */ + public function setMarkerUrl(?string $markerUrl): GroupPlaces + { + $this->markerUrl = $markerUrl; + return $this; + } + + /** + * @return string|null + */ + public function getGeoLat(): ?string + { + return $this->geoLat; + } + + /** + * @param string|null $geoLat + * @return GroupPlaces + */ + public function setGeoLat(?string $geoLat): GroupPlaces + { + $this->geoLat = $geoLat; + return $this; + } + + /** + * @return string|null + */ + public function getGeoLng(): ?string + { + return $this->geoLng; + } + + /** + * @param string|null $geoLng + * @return GroupPlaces + */ + public function setGeoLng(?string $geoLng): GroupPlaces + { + $this->geoLng = $geoLng; + return $this; + } + + /** + * @return string|null + */ + public function getCreatedDate(): ?string + { + return $this->createdDate; + } + + /** + * @param string|null $createdDate + * @return GroupPlaces + */ + public function setCreatedDate(?string $createdDate): GroupPlaces + { + $this->createdDate = $createdDate; + return $this; + } + + /** + * @return Person|null + */ + public function getCreatedPerson(): ?Person + { + return $this->createdPerson; + } + + /** + * @param Person|null $createdPerson + * @return GroupPlaces + */ + public function setCreatedPerson(?Person $createdPerson): GroupPlaces + { + $this->createdPerson = $createdPerson; + return $this; + } +} \ No newline at end of file diff --git a/tests/integration/Requests/PublicGroupRequestTest.php b/tests/integration/Requests/PublicGroupRequestTest.php index e5bd10db..ad379c25 100644 --- a/tests/integration/Requests/PublicGroupRequestTest.php +++ b/tests/integration/Requests/PublicGroupRequestTest.php @@ -6,6 +6,7 @@ use CTApi\Models\GroupCategory; use CTApi\Models\GroupInformation; +use CTApi\Models\GroupPlaces; use CTApi\Models\TargetGroup; use CTApi\Requests\PublicGroupRequest; use Tests\Integration\TestCaseAuthenticated; @@ -35,6 +36,7 @@ public function testGetPublicGroup() $foundGroup = null; foreach ($publicGroup->getGroups() as $group) { + print_r($group); if ($group->getId() == $this->groupId) { $foundGroup = $group; } @@ -53,6 +55,9 @@ public function testGetPublicGroup() $this->assertNotNull($foundGroup->getInformation()->getTargetGroup()); $this->assertInstanceOf(TargetGroup::class, $foundGroup->getInformation()->getTargetGroup()); + + $this->assertNotNull($foundGroup->getInformation()->getGroupPlaces()); + $this->assertInstanceOf(GroupPlaces::class, $foundGroup->getInformation()->getGroupPlaces()); } } \ No newline at end of file From 8324b4566b5e542721fa8264e497ead1b93870a1 Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 14:42:30 +0100 Subject: [PATCH 3/7] feat(registration-link): generate registration link #63 --- src/Models/PublicGroup.php | 16 ++++++++++ .../Requests/PublicGroupRequestTest.php | 3 -- tests/unit/Models/PublicGroupTest.php | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tests/unit/Models/PublicGroupTest.php diff --git a/src/Models/PublicGroup.php b/src/Models/PublicGroup.php index cbee8edd..63c2fc64 100644 --- a/src/Models/PublicGroup.php +++ b/src/Models/PublicGroup.php @@ -4,6 +4,7 @@ namespace CTApi\Models; +use CTApi\CTConfig; use CTApi\Models\Traits\FillWithData; class PublicGroup extends Group @@ -31,6 +32,21 @@ protected function fillNonArrayType(string $key, $value): void parent::fillNonArrayType($key, $value); } + public function generateRegistrationLink(string $groupHash): string + { + $url = CTConfig::getApiUrl(); + + if ('/' != substr($url, -1)) { + $url .= '/'; + } + + $url .= 'publicgroup/' . $this->getId(); + + $url .= '?hash=' . $groupHash; + + return $url; + } + /** * @return string|null */ diff --git a/tests/integration/Requests/PublicGroupRequestTest.php b/tests/integration/Requests/PublicGroupRequestTest.php index ad379c25..59cfea79 100644 --- a/tests/integration/Requests/PublicGroupRequestTest.php +++ b/tests/integration/Requests/PublicGroupRequestTest.php @@ -36,14 +36,11 @@ public function testGetPublicGroup() $foundGroup = null; foreach ($publicGroup->getGroups() as $group) { - print_r($group); if ($group->getId() == $this->groupId) { $foundGroup = $group; } } - print_r($foundGroup); - $this->assertNotNull($foundGroup); $this->assertEquals($this->groupName, $foundGroup->getName()); diff --git a/tests/unit/Models/PublicGroupTest.php b/tests/unit/Models/PublicGroupTest.php new file mode 100644 index 00000000..e2c31cb3 --- /dev/null +++ b/tests/unit/Models/PublicGroupTest.php @@ -0,0 +1,30 @@ +setId("21"); + + $this->assertEquals("https://test.church.tools/publicgroup/21?hash=EXAMPLEHASHCODE", $publicGroup->generateRegistrationLink("EXAMPLEHASHCODE")); + + // WITH SLASH IN THE END OF URL + CTConfig::setApiUrl("https://test.church.tools/"); + + $this->assertEquals("https://test.church.tools/publicgroup/21?hash=EXAMPLEHASHCODE", $publicGroup->generateRegistrationLink("EXAMPLEHASHCODE")); + + } +} \ No newline at end of file From a5a5c9acf74c7a8b9d7f8f76be67493f7e88f94e Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 14:48:15 +0100 Subject: [PATCH 4/7] fix(nullsafe): check if url is not null --- src/Models/PublicGroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/PublicGroup.php b/src/Models/PublicGroup.php index 63c2fc64..feb00123 100644 --- a/src/Models/PublicGroup.php +++ b/src/Models/PublicGroup.php @@ -36,7 +36,7 @@ public function generateRegistrationLink(string $groupHash): string { $url = CTConfig::getApiUrl(); - if ('/' != substr($url, -1)) { + if (!is_null($url) && '/' != substr($url, -1)) { $url .= '/'; } From f01dbe65c22faf868878838da26870cca9efded4 Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 15:29:19 +0100 Subject: [PATCH 5/7] docs(public-group): create documentation of public-group --- CHANGELOG.md | 2 + README.md | 1 + docs/PublicGroupAPI.md | 69 +++++++++++++++++-- docs/src/ressources/PublicGroupAPI.md | 53 ++++++++++++-- src/Models/GroupInformation.php | 12 ++-- .../{GroupPlaces.php => GroupPlace.php} | 38 +++++----- .../Requests/PublicGroupRequestTest.php | 4 +- ...mepages_wryawBH318GLHasgm27awB0c241aj.json | 36 ++++++++++ 8 files changed, 176 insertions(+), 39 deletions(-) rename src/Models/{GroupPlaces.php => GroupPlace.php} (85%) create mode 100644 tests/unit/HttpMock/data/api_grouphomepages_wryawBH318GLHasgm27awB0c241aj.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a3bfae..b5020e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed ### 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 diff --git a/README.md b/README.md index e040cf53..b893764c 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/PublicGroupAPI.md b/docs/PublicGroupAPI.md index 20488cb8..bb75bd8a 100644 --- a/docs/PublicGroupAPI.md +++ b/docs/PublicGroupAPI.md @@ -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(); @@ -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 -``` \ No newline at end of file +``` + +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) diff --git a/docs/src/ressources/PublicGroupAPI.md b/docs/src/ressources/PublicGroupAPI.md index 6a096bce..68725687 100644 --- a/docs/src/ressources/PublicGroupAPI.md +++ b/docs/src/ressources/PublicGroupAPI.md @@ -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(); @@ -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 -``` \ No newline at end of file +``` + +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) diff --git a/src/Models/GroupInformation.php b/src/Models/GroupInformation.php index bed97673..4ee7d9ac 100644 --- a/src/Models/GroupInformation.php +++ b/src/Models/GroupInformation.php @@ -17,7 +17,7 @@ class GroupInformation protected ?TargetGroup $targetGroup = null; protected ?string $note = null; protected ?string $imageUrl = null; - protected ?GroupPlaces $groupPlaces = null; + protected ?array $groupPlaces = null; protected function fillArrayType(string $key, array $data): void { @@ -29,7 +29,7 @@ protected function fillArrayType(string $key, array $data): void $this->targetGroup = TargetGroup::createModelFromData($data); break; case "groupPlaces": - $this->groupPlaces = GroupPlaces::createModelFromData($data); + $this->groupPlaces = GroupPlace::createModelsFromArray($data); break; default: $this->{$key} = $data; @@ -73,18 +73,18 @@ public function setWeekday(?array $weekday): GroupInformation } /** - * @return GroupPlaces|null + * @return array|null */ - public function getGroupPlaces(): ?GroupPlaces + public function getGroupPlaces(): ?array { return $this->groupPlaces; } /** - * @param GroupPlaces|null $groupPlaces + * @param array|null $groupPlaces * @return GroupInformation */ - public function setGroupPlaces(?GroupPlaces $groupPlaces): GroupInformation + public function setGroupPlaces(?array $groupPlaces): GroupInformation { $this->groupPlaces = $groupPlaces; return $this; diff --git a/src/Models/GroupPlaces.php b/src/Models/GroupPlace.php similarity index 85% rename from src/Models/GroupPlaces.php rename to src/Models/GroupPlace.php index 2f6fb424..84e4838c 100644 --- a/src/Models/GroupPlaces.php +++ b/src/Models/GroupPlace.php @@ -6,7 +6,7 @@ use CTApi\Models\Traits\FillWithData; -class GroupPlaces +class GroupPlace { use FillWithData; @@ -42,9 +42,9 @@ public function getName(): ?string /** * @param string|null $name - * @return GroupPlaces + * @return GroupPlace */ - public function setName(?string $name): GroupPlaces + public function setName(?string $name): GroupPlace { $this->name = $name; return $this; @@ -60,9 +60,9 @@ public function getDistrict(): ?string /** * @param string|null $district - * @return GroupPlaces + * @return GroupPlace */ - public function setDistrict(?string $district): GroupPlaces + public function setDistrict(?string $district): GroupPlace { $this->district = $district; return $this; @@ -78,9 +78,9 @@ public function getPostalcode(): ?string /** * @param string|null $postalcode - * @return GroupPlaces + * @return GroupPlace */ - public function setPostalcode(?string $postalcode): GroupPlaces + public function setPostalcode(?string $postalcode): GroupPlace { $this->postalcode = $postalcode; return $this; @@ -96,9 +96,9 @@ public function getCity(): ?string /** * @param string|null $city - * @return GroupPlaces + * @return GroupPlace */ - public function setCity(?string $city): GroupPlaces + public function setCity(?string $city): GroupPlace { $this->city = $city; return $this; @@ -114,9 +114,9 @@ public function getMarkerUrl(): ?string /** * @param string|null $markerUrl - * @return GroupPlaces + * @return GroupPlace */ - public function setMarkerUrl(?string $markerUrl): GroupPlaces + public function setMarkerUrl(?string $markerUrl): GroupPlace { $this->markerUrl = $markerUrl; return $this; @@ -132,9 +132,9 @@ public function getGeoLat(): ?string /** * @param string|null $geoLat - * @return GroupPlaces + * @return GroupPlace */ - public function setGeoLat(?string $geoLat): GroupPlaces + public function setGeoLat(?string $geoLat): GroupPlace { $this->geoLat = $geoLat; return $this; @@ -150,9 +150,9 @@ public function getGeoLng(): ?string /** * @param string|null $geoLng - * @return GroupPlaces + * @return GroupPlace */ - public function setGeoLng(?string $geoLng): GroupPlaces + public function setGeoLng(?string $geoLng): GroupPlace { $this->geoLng = $geoLng; return $this; @@ -168,9 +168,9 @@ public function getCreatedDate(): ?string /** * @param string|null $createdDate - * @return GroupPlaces + * @return GroupPlace */ - public function setCreatedDate(?string $createdDate): GroupPlaces + public function setCreatedDate(?string $createdDate): GroupPlace { $this->createdDate = $createdDate; return $this; @@ -186,9 +186,9 @@ public function getCreatedPerson(): ?Person /** * @param Person|null $createdPerson - * @return GroupPlaces + * @return GroupPlace */ - public function setCreatedPerson(?Person $createdPerson): GroupPlaces + public function setCreatedPerson(?Person $createdPerson): GroupPlace { $this->createdPerson = $createdPerson; return $this; diff --git a/tests/integration/Requests/PublicGroupRequestTest.php b/tests/integration/Requests/PublicGroupRequestTest.php index 59cfea79..4496e8c1 100644 --- a/tests/integration/Requests/PublicGroupRequestTest.php +++ b/tests/integration/Requests/PublicGroupRequestTest.php @@ -6,7 +6,7 @@ use CTApi\Models\GroupCategory; use CTApi\Models\GroupInformation; -use CTApi\Models\GroupPlaces; +use CTApi\Models\GroupPlace; use CTApi\Models\TargetGroup; use CTApi\Requests\PublicGroupRequest; use Tests\Integration\TestCaseAuthenticated; @@ -54,7 +54,7 @@ public function testGetPublicGroup() $this->assertInstanceOf(TargetGroup::class, $foundGroup->getInformation()->getTargetGroup()); $this->assertNotNull($foundGroup->getInformation()->getGroupPlaces()); - $this->assertInstanceOf(GroupPlaces::class, $foundGroup->getInformation()->getGroupPlaces()); + $this->assertIsArray($foundGroup->getInformation()->getGroupPlaces()); } } \ No newline at end of file diff --git a/tests/unit/HttpMock/data/api_grouphomepages_wryawBH318GLHasgm27awB0c241aj.json b/tests/unit/HttpMock/data/api_grouphomepages_wryawBH318GLHasgm27awB0c241aj.json new file mode 100644 index 00000000..0141cf4a --- /dev/null +++ b/tests/unit/HttpMock/data/api_grouphomepages_wryawBH318GLHasgm27awB0c241aj.json @@ -0,0 +1,36 @@ +{ + "data": { + "id": 21, + "randomUrl": "wryawBH318GLHasgm27awB0c241aj", + "groups": [ + { + "id": 221, + "maxMemberCount": 42, + "currentMemberCount": 30, + "signUpHeadline": "Teilnahme beantragen", + "name": "Jugendwoche Kraftberg", + "information": { + "meetingTime": "Freitag, 01.03. um 16h bis Sonntag 03.03. um 24h", + "groupCategory": { + "name": "leisure", + "nameTranslated": "Freizeit" + }, + "targetGroup": { + "name": "youth", + "nameTranslated": "Jugendliche" + }, + "note": "Eine spannende Freizeit erwartet dich!", + "imageUrl": "https://test.church.tools/images/9281/2928912ioha8921ns891bs9", + "groupPlaces": [ + { + "name": "Freizeitheim Rosenberg", + "city": "Heilbronn", + "geoLat": "92.2912", + "geoLng": "2.291" + } + ] + } + } + ] + } +} \ No newline at end of file From 7e006c300122a408bc55d6b673e40ed4709568ba Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 15:37:41 +0100 Subject: [PATCH 6/7] feat(doc-generator): add logs to doc-generator --- docs/src/DocGenerator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/DocGenerator.php b/docs/src/DocGenerator.php index f0003906..2bbe6fb5 100644 --- a/docs/src/DocGenerator.php +++ b/docs/src/DocGenerator.php @@ -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); From 024bcca8c9f88d18d7ade7633f37336706c48e6f Mon Sep 17 00:00:00 2001 From: Lukas Dumberger Date: Fri, 11 Feb 2022 15:49:48 +0100 Subject: [PATCH 7/7] release(v1.3.1): release fixed version --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5020e1a..69f947e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed ### 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)