diff --git a/src/TgBotLib/Objects/Telegram/GiveawayCompleted.php b/src/TgBotLib/Objects/Telegram/GiveawayCompleted.php new file mode 100644 index 0000000..a62ff9f --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/GiveawayCompleted.php @@ -0,0 +1,79 @@ +winner_count; + } + + /** + * Optional. Number of undistributed prizes + * + * @return int|null + */ + public function getUnclaimedPrizeCount(): ?int + { + return $this->unclaimed_prize_count; + } + + /** + * Optional. Message with the giveaway that was completed, if it wasn't deleted + * + * @return Message|null + */ + public function getGiveawayMessage(): ?Message + { + return $this->giveaway_message; + } + + /** + * Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. + * + * @return bool + */ + public function isStarGiveaway(): bool + { + return $this->is_star_giveaway; + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'winner_count' => $this->winner_count, + 'unclaimed_prize_count' => $this->unclaimed_prize_count, + 'giveaway_message' => $this->giveaway_message?->toArray(), + 'is_star_giveaway' => $this->is_star_giveaway + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + $object->winner_count = $data['winner_count']; + $object->unclaimed_prize_count = $data['unclaimed_prize_count'] ?? null; + $object->giveaway_message = isset($data['giveaway_message']) ? Message::fromArray($data['giveaway_message']) : null; + $object->is_star_giveaway = $data['is_star_giveaway'] ?? false; + return $object; + } +} \ No newline at end of file