From aa43a8a53a4ebb5bc44fc584338caf12fee7e30b Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 13 Feb 2023 16:02:01 -0500 Subject: [PATCH] Added \TgBotLib\Objects > ChatInviteLink --- src/TgBotLib/Objects/ChatInviteLink.php | 189 ++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 src/TgBotLib/Objects/ChatInviteLink.php diff --git a/src/TgBotLib/Objects/ChatInviteLink.php b/src/TgBotLib/Objects/ChatInviteLink.php new file mode 100644 index 0000000..dbfa345 --- /dev/null +++ b/src/TgBotLib/Objects/ChatInviteLink.php @@ -0,0 +1,189 @@ +invite_link; + } + + /** + * Creator of the link + * + * @return User + */ + public function getCreator(): User + { + return $this->creator; + } + + /** + * True, if users joining the chat via the link need to be approved by chat administrators + * + * @return bool + */ + public function isCreatesJoinRequest(): bool + { + return $this->creates_join_request; + } + + /** + * True, if the link is primary + * + * @return bool + */ + public function isIsPrimary(): bool + { + return $this->is_primary; + } + + /** + * True, if the link is revoked + * + * @return bool + */ + public function isIsRevoked(): bool + { + return $this->is_revoked; + } + + /** + * Optional. Invite link name + * + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * Optional. Point in time (Unix timestamp) when the link will expire or has been expired + * + * @return int|null + */ + public function getExpireDate(): ?int + { + return $this->expire_date; + } + + /** + * Optional. The maximum number of users that can be members of the chat simultaneously after joining the + * chat via this invite link; 1-99999 + * + * @return int|null + */ + public function getMemberLimit(): ?int + { + return $this->member_limit; + } + + /** + * Optional. Number of pending join requests created using this link + * + * @return int|null + */ + public function getPendingJoinRequestCount(): ?int + { + return $this->pending_join_request_count; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'invite_link' => $this->invite_link, + 'creator' => ($this->creator instanceof ObjectTypeInterface) ? $this->creator->toArray() : null, + 'creates_join_request' => $this->creates_join_request ?? false, + 'is_primary' => $this->is_primary ?? false, + 'is_revoked' => $this->is_revoked ?? false, + 'name' => $this->name, + 'expire_date' => $this->expire_date, + 'member_limit' => $this->member_limit, 'pending_join_request_count' => $this->pending_join_request_count + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->invite_link = $data['invite_link']; + $object->creator = isset($data['creator']) ? User::fromArray($data['creator']) : null; + $object->creates_join_request = $data['creates_join_request']; + $object->is_primary = $data['is_primary']; + $object->is_revoked = $data['is_revoked']; + $object->name = $data['name']; + $object->expire_date = $data['expire_date']; + $object->member_limit = $data['member_limit']; + $object->pending_join_request_count = $data['pending_join_request_count']; + + return $object; + } + } \ No newline at end of file