From 4558ebb9a7fd54eaee0e4c9daa3160be5e1ef675 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 9 Oct 2024 13:13:21 -0400 Subject: [PATCH] Added ChatBoost --- src/TgBotLib/Objects/ChatBoost.php | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/TgBotLib/Objects/ChatBoost.php diff --git a/src/TgBotLib/Objects/ChatBoost.php b/src/TgBotLib/Objects/ChatBoost.php new file mode 100644 index 0000000..ba315f3 --- /dev/null +++ b/src/TgBotLib/Objects/ChatBoost.php @@ -0,0 +1,86 @@ +boost_id; + } + + /** + * Point in time (Unix timestamp) when the chat was boosted + * + * @return int + */ + public function getAddDate(): int + { + return $this->add_date; + } + + /** + * Point in time (Unix timestamp) when the boost will automatically expire, + * unless the booster's Telegram Premium subscription is prolonged + * + * @return int + */ + public function getExpirationDate(): int + { + return $this->expiration_date; + } + + /** + * Source of the added boost + * + * @return ChatBoostSource + */ + public function getSource(): ChatBoostSource + { + return $this->source; + } + + /** + * @inheritDoc + */ + public function toArray(): ?array + { + return [ + 'boost_id' => $this->boost_id, + 'add_date' => $this->add_date, + 'expiration_date' => $this->expiration_date, + 'source' => $this->source->toArray() + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?ChatBoost + { + if($data === null) + { + return null; + } + + $object = new self(); + $object->boost_id = $data['boost_id']; + $object->add_date = $data['add_date']; + $object->expiration_date = $data['expiration_date']; + $object->source = ChatBoostSource::fromArray($data['source']); + + return $object; + } + } \ No newline at end of file