Updated ChatJoinRequest

This commit is contained in:
netkas 2024-10-04 14:05:45 -04:00
parent 65845b53de
commit 0272c7b3ed

View file

@ -8,35 +8,12 @@
class ChatJoinRequest implements ObjectTypeInterface class ChatJoinRequest implements ObjectTypeInterface
{ {
/** private Chat $chat;
* @var Chat private User $from;
*/ private int $user_chat_id;
private $chat; private int $date;
private ?string $bio;
/** private ?ChatInviteLink $invite_link;
* @var User
*/
private $from;
/**
* @var int
*/
private $user_chat_id;
/**
* @var int
*/
private $date;
/**
* @var string|null
*/
private $bio;
/**
* @var ChatInviteLink|null
*/
private $invite_link;
/** /**
* Chat to which the request was sent * Chat to which the request was sent
@ -103,38 +80,37 @@
} }
/** /**
* Returns an array representation of the object * @inheritDoc
*
* @return array
*/ */
public function toArray(): array public function toArray(): array
{ {
return [ return [
'chat' => ($this->chat instanceof ObjectTypeInterface) ? $this->chat->toArray() : $this->chat, 'chat' => $this->chat?->toArray(),
'from' => ($this->from instanceof ObjectTypeInterface) ? $this->from->toArray() : $this->from, 'from' => $this->from?->toArray(),
'user_chat_id' => $this->user_chat_id, 'user_chat_id' => $this->user_chat_id,
'date' => $this->date, 'date' => $this->date,
'bio' => $this->bio, 'bio' => $this->bio,
'invite_link' => ($this->invite_link instanceof ObjectTypeInterface) ? $this->invite_link->toArray() : $this->invite_link, 'invite_link' => $this->invite_link?->toArray()
]; ];
} }
/** /**
* Constructs ChatJoinRequest object from an array representation * @inheritDoc
*
* @param array $data
* @return ChatJoinRequest
*/ */
public static function fromArray(array $data): self public static function fromArray(?array $data): ?ChatJoinRequest
{ {
$object = new self(); if($data === null)
{
return null;
}
$object->chat = (isset($data['chat'])) ? Chat::fromArray($data['chat']) : null; $object = new self();
$object->from = (isset($data['from'])) ? User::fromArray($data['from']) : null; $object->chat = isset($data['chat']) ? Chat::fromArray($data['chat']) : null;
$object->user_chat_id = (isset($data['user_chat_id'])) ? $data['user_chat_id'] : null; $object->from = isset($data['from']) ? User::fromArray($data['from']) : null;
$object->date = (isset($data['date'])) ? $data['date'] : null; $object->user_chat_id = $data['user_chat_id'];
$object->bio = (isset($data['bio'])) ? $data['bio'] : null; $object->date = $data['date'];
$object->invite_link = (isset($data['invite_link'])) ? ChatInviteLink::fromArray($data['invite_link']) : null; $object->bio = $data['bio'] ?? null;
$object->invite_link = isset($data['invite_link']) ? ChatInviteLink::fromArray($data['invite_link']) : null;
return $object; return $object;
} }