From 6fb6f744060c690a1ee0b84cb0a7fac8b287e00a Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 24 Apr 2023 19:14:36 -0400 Subject: [PATCH] Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultGame`, see [InlineQueryResultGame](https://core.telegram.org/bots/api#inlinequeryresultgame) for more information. https://git.n64.cc/nosial/libs/tgbot/-/issues/3 --- CHANGELOG.md | 1 + .../InlineQueryResultGame.php | 104 ++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultGame.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 695d4c0..bf0ef48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ input objects for methods that require input objects. * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultLocation`, see [InlineQueryResultLocation](https://core.telegram.org/bots/api#inlinequeryresultlocation) for more information. * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVenue`, see [InlineQueryResultVenue](https://core.telegram.org/bots/api#inlinequeryresultvenue) for more information. * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultContact`, see [InlineQueryResultContact](https://core.telegram.org/bots/api#inlinequeryresultcontact) for more information. + * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultGame`, see [InlineQueryResultGame](https://core.telegram.org/bots/api#inlinequeryresultgame) for more information. ### Changed * Refactored InputMessageContent types to its own namespace so InputMessageContent can always return the correct InputMessageContent object type when calling `fromArray()` diff --git a/src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultGame.php b/src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultGame.php new file mode 100644 index 0000000..8ec5717 --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultGame.php @@ -0,0 +1,104 @@ +type; + } + + /** + * Unique identifier for this result, 1-64 bytes + * + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * Short name of the game + * + * @return string + */ + public function getGameShortName(): string + { + return $this->game_short_name; + } + + /** + * Optional. Inline keyboard attached to the message + * + * @return InlineKeyboardMarkup|null + */ + public function getReplyMarkup(): ?InlineKeyboardMarkup + { + return $this->reply_markup; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'type' => $this->type, + 'id' => $this->id, + 'game_short_name' => $this->game_short_name, + 'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->type = $data['type'] ?? null; + $object->id = $data['id'] ?? null; + $object->game_short_name = $data['game_short_name'] ?? null; + $object->reply_markup = $data['reply_markup'] ?? null; + + return $object; + } + } \ No newline at end of file