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
This commit is contained in:
parent
89b240f2eb
commit
61249cb18d
2 changed files with 306 additions and 0 deletions
|
@ -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()`
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultVenue implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $latitude;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $longitude;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $foursquare_id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $foursquare_type;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $google_place_id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $google_place_type;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $thumbnail_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $thumbnail_height;
|
||||
|
||||
/**
|
||||
* InlineQueryResultVenue constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue