From 09f515c76ee112d5883170de027bee6f18318620 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 14 Feb 2023 19:51:44 -0500 Subject: [PATCH] Added \TgBotLib\Objects\Telegram > ChosenInlineResult --- .../Objects/Telegram/ChosenInlineResult.php | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/ChosenInlineResult.php diff --git a/src/TgBotLib/Objects/Telegram/ChosenInlineResult.php b/src/TgBotLib/Objects/Telegram/ChosenInlineResult.php new file mode 100644 index 0000000..7943e2b --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/ChosenInlineResult.php @@ -0,0 +1,124 @@ +result_id; + } + + /** + * The user that chose the result + * + * @return User + */ + public function getFrom(): User + { + return $this->from; + } + + /** + * Optional. Sender location, only for bots that require user location + * + * @return Location|null + */ + public function getLocation(): ?Location + { + return $this->location; + } + + /** + * Optional. Identifier of the scent inline message. Available only if there is an inline keyboard attached to + * the message. Will be also received in callback queries and can be used to edit the message. + * + * @see https://core.telegram.org/bots/api#inlinekeyboardmarkup + * @see https://core.telegram.org/bots/api#callbackquery + * @see https://core.telegram.org/bots/api#updating-messages + * @return string|null + */ + public function getInlineMessageId(): ?string + { + return $this->inline_message_id; + } + + /** + * The query that was used to obtain the result + * + * @return string + */ + public function getQuery(): string + { + return $this->query; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'result_id' => $this->result_id, + 'from' => ($this->from instanceof ObjectTypeInterface) ? $this->from->toArray() : $this->from, + 'location' => ($this->location instanceof ObjectTypeInterface) ? $this->location->toArray() : $this->location, + 'inline_message_id' => $this->inline_message_id, + 'query' => $this->query, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->result_id = $data['result_id'] ?? null; + $object->from = $data['from'] ?? null; + $object->location = $data['location'] ?? null; + $object->inline_message_id = $data['inline_message_id'] ?? null; + $object->query = $data['query'] ?? null; + + return $object; + } + } \ No newline at end of file