-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from 5pm-HDH/feature/groups
Groups
- Loading branch information
Showing
19 changed files
with
1,560 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# GroupAPI | ||
|
||
```php | ||
use CTApi\Requests\GroupRequest;use CTApi\Requests\PersonRequest; | ||
|
||
/** | ||
* Group-Request | ||
*/ | ||
|
||
// Retrieve all groups | ||
$allGroups = GroupRequest::all(); | ||
$allGroups = GroupRequest::orderBy('name')->get(); | ||
|
||
$myGroups = PersonRequest::whoami()?->requestGroups(); | ||
|
||
// Get specific Group | ||
$group = GroupRequest::find(21); // returns "null" if id is invalid | ||
$group = GroupRequest::findOrFail(22); // throws exception if id is invalid | ||
|
||
|
||
/** | ||
* Group-Data | ||
*/ | ||
echo "-".$group->getId(); | ||
echo "-".$group->getGuid(); | ||
echo "-".$group->getName(); | ||
print_r($group->getSecurityLevelForGroup()); | ||
print_r($group->getPermissions()); | ||
print_r($group->getInformation()); | ||
print_r($group->getFollowUp()); | ||
print_r($group->getRoles()); | ||
|
||
echo "GroupSettings\n"; | ||
echo "-".$group->getSettings()?->getIsHidden(); | ||
echo "-".$group->getSettings()?->getIsOpenForMembers(); | ||
echo "-".$group->getSettings()?->getAllowSpouseRegistration(); | ||
echo "-".$group->getSettings()?->getAllowChildRegistration(); | ||
echo "-".$group->getSettings()?->getAllowSameEmailRegistration(); | ||
echo "-".$group->getSettings()?->getAutoAccept(); | ||
echo "-".$group->getSettings()?->getAllowWaitinglist(); | ||
echo "-".$group->getSettings()?->getWaitinglistMaxPersons(); | ||
echo "-".$group->getSettings()?->getAutomaticMoveUp(); | ||
echo "-".$group->getSettings()?->getIsPublic(); | ||
print_r($group->getSettings()?->getGroupMeeting()); | ||
echo "-".$group->getSettings()?->getQrCodeCheckin(); | ||
print_r($group->getSettings()?->getNewMember()); | ||
|
||
echo "GroupRoles\n"; | ||
$groupRole = $group->getRoles()[0]; | ||
echo "-".$groupRole->getId(); | ||
echo "-".$groupRole->getGroupTypeId(); | ||
echo "-".$groupRole->getName(); | ||
echo "-".$groupRole->getShorty(); | ||
echo "-".$groupRole->getShortKey(); | ||
echo "-".$groupRole->getToDelete(); | ||
echo "-".$groupRole->getHasRequested(); | ||
echo "-".$groupRole->getIsLeader(); | ||
echo "-".$groupRole->getIsDefault(); | ||
echo "-".$groupRole->getIsHidden(); | ||
echo "-".$groupRole->getGrowPathId(); | ||
echo "-".$groupRole->getGroupTypeRoleId(); | ||
echo "-".$groupRole->getForceTwoFactorAuth(); | ||
echo "-".$groupRole->getIsActive(); | ||
echo "-".$groupRole->getCanReadChat(); | ||
echo "-".$groupRole->getCanWriteChat(); | ||
|
||
echo "GroupMembers"; | ||
$groupMember = $group->requestMembers()[0]; | ||
|
||
echo "-".$groupMember->getId(); | ||
echo "-".$groupMember->getPersonId(); | ||
echo "-".$groupMember->getGroupTypeRoleId(); | ||
echo "-".$groupMember->getMemberStartDate(); | ||
echo "-".$groupMember->getComment(); | ||
echo "-".$groupMember->getMemberEndDate(); | ||
echo "-".$groupMember->getWaitinglistPosition(); | ||
print_r($groupMember->getFields()); | ||
|
||
$personGroupMember = $groupMember->getPerson(); | ||
$personGroupMember = $groupMember->requestPerson(); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
<?php | ||
|
||
|
||
namespace CTApi\Models; | ||
|
||
|
||
use CTApi\Models\Traits\FillWithData; | ||
use CTApi\Requests\GroupMemberRequestBuilder; | ||
|
||
class Group | ||
{ | ||
use FillWithData; | ||
|
||
protected ?string $id = null; | ||
protected ?string $guid = null; | ||
protected ?string $name = null; | ||
protected ?string $securityLevelForGroup = null; | ||
protected array $permissions = []; | ||
protected array $information = []; | ||
protected ?GroupSettings $settings = null; | ||
protected array $followUp = []; | ||
protected array $roles = []; | ||
|
||
|
||
protected function fillNonArrayType(string $key, $value) | ||
{ | ||
switch ($key) { | ||
case "title": | ||
$this->setName($value); | ||
break; | ||
case "domainIdentifier": | ||
$this->setId($value); | ||
break; | ||
default: | ||
$this->{$key} = $value; | ||
} | ||
} | ||
|
||
protected function fillArrayType(string $key, array $data) | ||
{ | ||
switch ($key) { | ||
case "roles": | ||
$this->setRoles(GroupRole::createModelsFromArray($data)); | ||
break; | ||
case "settings": | ||
$this->setSettings(GroupSettings::createModelFromData($data)); | ||
break; | ||
default: | ||
$this->{$key} = $data; | ||
} | ||
} | ||
|
||
|
||
public function requestMembers(): ?GroupMemberRequestBuilder | ||
{ | ||
if ($this->getId() != null) { | ||
return new GroupMemberRequestBuilder((int)$this->getId()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param string|null $id | ||
* @return Group | ||
*/ | ||
public function setId(?string $id): Group | ||
{ | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getGuid(): ?string | ||
{ | ||
return $this->guid; | ||
} | ||
|
||
/** | ||
* @param string|null $guid | ||
* @return Group | ||
*/ | ||
public function setGuid(?string $guid): Group | ||
{ | ||
$this->guid = $guid; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string|null $name | ||
* @return Group | ||
*/ | ||
public function setName(?string $name): Group | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getSecurityLevelForGroup(): ?string | ||
{ | ||
return $this->securityLevelForGroup; | ||
} | ||
|
||
/** | ||
* @param string|null $securityLevelForGroup | ||
* @return Group | ||
*/ | ||
public function setSecurityLevelForGroup(?string $securityLevelForGroup): Group | ||
{ | ||
$this->securityLevelForGroup = $securityLevelForGroup; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getPermissions(): array | ||
{ | ||
return $this->permissions; | ||
} | ||
|
||
/** | ||
* @param array $permissions | ||
* @return Group | ||
*/ | ||
public function setPermissions(array $permissions): Group | ||
{ | ||
$this->permissions = $permissions; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getInformation(): array | ||
{ | ||
return $this->information; | ||
} | ||
|
||
/** | ||
* @param array $information | ||
* @return Group | ||
*/ | ||
public function setInformation(array $information): Group | ||
{ | ||
$this->information = $information; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return GroupSettings|null | ||
*/ | ||
public function getSettings(): ?GroupSettings | ||
{ | ||
return $this->settings; | ||
} | ||
|
||
/** | ||
* @param GroupSettings|null $settings | ||
* @return Group | ||
*/ | ||
public function setSettings(?GroupSettings $settings): Group | ||
{ | ||
$this->settings = $settings; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getFollowUp(): array | ||
{ | ||
return $this->followUp; | ||
} | ||
|
||
/** | ||
* @param array $followUp | ||
* @return Group | ||
*/ | ||
public function setFollowUp(array $followUp): Group | ||
{ | ||
$this->followUp = $followUp; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getRoles(): array | ||
{ | ||
return $this->roles; | ||
} | ||
|
||
/** | ||
* @param array $roles | ||
* @return Group | ||
*/ | ||
public function setRoles(array $roles): Group | ||
{ | ||
$this->roles = $roles; | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.