From 61249cb18dbb92e5d300b9f30433dda71c065ebf Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 24 Apr 2023 16:15:03 -0400 Subject: [PATCH] Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVenue`, see [InlineQueryResultVenue](https://core.telegram.org/bots/api#inlinequeryresultvenue) for more information. https://git.n64.cc/nosial/libs/tgbot/-/issues/3 --- CHANGELOG.md | 1 + .../InlineQueryResultVenue.php | 305 ++++++++++++++++++ 2 files changed, 306 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultVenue.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 46d99b8..30f5059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ input objects for methods that require input objects. * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVoice`, see [InlineQueryResultVoice](https://core.telegram.org/bots/api#inlinequeryresultvoice) for more information. * Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultDocument`, see [InlineQueryResultDocument](https://core.telegram.org/bots/api#inlinequeryresultdocument) for more information. * 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. ### 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/InlineQueryResultVenue.php b/src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultVenue.php new file mode 100644 index 0000000..a47856b --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/InlineQueryResult/InlineQueryResultVenue.php @@ -0,0 +1,305 @@ +type = 'venue'; + } + + /** + * Type of the result, must be venue + * + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * Unique identifier for this result, 1-64 Bytes + * + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * Latitude of the venue location in degrees + * + * @return float + */ + public function getLatitude(): float + { + return $this->latitude; + } + + /** + * Longitude of the venue location in degrees + * + * @return float + */ + public function getLongitude(): float + { + return $this->longitude; + } + + /** + * Title of the venue + * + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * Address of the venue + * + * @return string + */ + public function getAddress(): string + { + return $this->address; + } + + /** + * Optional. Foursquare identifier of the venue if known + * + * @return string|null + */ + public function getFoursquareId(): ?string + { + return $this->foursquare_id; + } + + /** + * Optional. Foursquare type of the venue, if known. + * (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * + * @return string|null + */ + public function getFoursquareType(): ?string + { + return $this->foursquare_type; + } + + /** + * Optional. Google Places identifier of the venue + * + * @return string|null + */ + public function getGooglePlaceId(): ?string + { + return $this->google_place_id; + } + + /** + * Optional. Google Places type of the venue. + * + * @see https://developers.google.com/places/web-service/supported_types + * @return string|null + */ + public function getGooglePlaceType(): ?string + { + return $this->google_place_type; + } + + /** + * Optional. Inline keyboard attached to the message + * + * @return InlineKeyboardMarkup|null + */ + public function getReplyMarkup(): ?InlineKeyboardMarkup + { + return $this->reply_markup; + } + + /** + * Optional. Content of the message to be sent instead of the venue + * + * @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null + */ + public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null + { + return $this->input_message_content; + } + + /** + * Optional. Url of the thumbnail for the result + * + * @return string|null + */ + public function getThumbnailUrl(): ?string + { + return $this->thumbnail_url; + } + + /** + * Optional. Thumbnail width + * + * @return int|null + */ + public function getThumbnailWidth(): ?int + { + return $this->thumbnail_width; + } + + /** + * Optional. Thumbnail height + * + * @return int|null + */ + public function getThumbnailHeight(): ?int + { + return $this->thumbnail_height; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'type' => $this->type, + 'id' => $this->id, + 'latitude' => $this->latitude, + 'longitude' => $this->longitude, + 'title' => $this->title, + 'address' => $this->address, + 'foursquare_id' => $this->foursquare_id, + 'foursquare_type' => $this->foursquare_type, + 'google_place_id' => $this->google_place_id, + 'google_place_type' => $this->google_place_type, + 'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null, + 'input_message_content' => ($this->input_message_content instanceof InputVenueMessageContent) ? $this->input_message_content->toArray() : null, + 'thumbnail_url' => $this->thumbnail_url, + 'thumbnail_width' => $this->thumbnail_width, + 'thumbnail_height' => $this->thumbnail_height + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->id = $data['id'] ?? null; + $object->latitude = $data['latitude'] ?? null; + $object->longitude = $data['longitude'] ?? null; + $object->title = $data['title'] ?? null; + $object->address = $data['address'] ?? null; + $object->foursquare_id = $data['foursquare_id'] ?? null; + $object->foursquare_type = $data['foursquare_type'] ?? null; + $object->google_place_id = $data['google_place_id'] ?? null; + $object->google_place_type = $data['google_place_type'] ?? null; + $object->reply_markup = isset($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null; + $object->input_message_content = isset($data['input_message_content']) ? InputVenueMessageContent::fromArray($data['input_message_content']) : null; + $object->thumbnail_url = $data['thumbnail_url'] ?? null; + $object->thumbnail_width = $data['thumbnail_width'] ?? null; + $object->thumbnail_height = $data['thumbnail_height'] ?? null; + + return $object; + } + } \ No newline at end of file