diff --git a/src/TgBotLib/Objects/LoginUrl.php b/src/TgBotLib/Objects/LoginUrl.php new file mode 100644 index 0000000..23a112e --- /dev/null +++ b/src/TgBotLib/Objects/LoginUrl.php @@ -0,0 +1,110 @@ +url; + } + + /** + * Optional. New text of the button in forwarded messages. + * + * @return string|null + */ + public function getForwardText(): ?string + { + return $this->forward_text; + } + + /** + * Optional. Username of a bot, which will be used for user authorization. See Setting up a bot for more details. + * If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain + * linked with the bot. See Linking your domain to the bot for more details. + * + * @see https://core.telegram.org/widgets/login#setting-up-a-bot + * @see https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot + * @return string|null + */ + public function getBotUsername(): ?string + { + return $this->bot_username; + } + + /** + * Optional. Pass True to request the permission for your bot to send messages to the user. + * + * @return bool + */ + public function getRequestWriteAccess(): bool + { + return $this->request_write_access; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'url' => $this->url, + 'forward_text' => $this->forward_text, + 'bot_username' => $this->bot_username, + 'request_write_access' => $this->request_write_access + ]; + } + + /** + * Constructs the object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->url = $data['url']; + $object->forward_text = $data['forward_text'] ?? null; + $object->bot_username = $data['bot_username'] ?? null; + $object->request_write_access = $data['request_write_access'] ?? false; + + return $object; + } + } \ No newline at end of file