Updated InlineQuery objects
This commit is contained in:
parent
58849813e9
commit
669ec19f46
17 changed files with 422 additions and 1647 deletions
|
@ -2,11 +2,14 @@
|
|||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
namespace TgBotLib\Objects\Inline;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\CallbackGame;
|
||||
use TgBotLib\Objects\LoginUrl;
|
||||
use TgBotLib\Objects\WebAppInfo;
|
||||
|
||||
class InlineKeyboardButton implements ObjectTypeInterface
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
namespace TgBotLib\Objects\Inline;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
namespace TgBotLib\Objects\Inline;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Location;
|
||||
use TgBotLib\Objects\User;
|
||||
|
||||
class InlineQuery implements ObjectTypeInterface
|
||||
{
|
78
src/TgBotLib/Objects/Inline/InlineQueryResult.php
Normal file
78
src/TgBotLib/Objects/Inline/InlineQueryResult.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\Inline;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Exceptions\NotImplementedException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultArticle;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultAudio;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultContact;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultDocument;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultGame;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultGif;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultLocation;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultMpeg4Gif;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultPhoto;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultVenue;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultVideo;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult\InlineQueryResultVoice;
|
||||
|
||||
abstract class InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
protected InlineQueryResultType $type;
|
||||
protected string $id;
|
||||
|
||||
/**
|
||||
* Type of the result
|
||||
*
|
||||
* @return InlineQueryResultType
|
||||
*/
|
||||
public function getType(): InlineQueryResultType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for this result, 1-64 Bytes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Unique Identifier for this result, must be 1-64 characters
|
||||
*
|
||||
* @param string $id The ID to set
|
||||
* @throws InvalidArgumentException If the size of the ID is empty or over 64 characters long
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResult
|
||||
{
|
||||
if(!Validate::length($id, 1, 64))
|
||||
{
|
||||
throw new InvalidArgumentException(sprintf('id must be between 1 and 64 characters long, got %s characters', $id));
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public abstract function toArray(): array;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
// TODO: Implement this
|
||||
}
|
||||
}
|
|
@ -1,122 +1,26 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultArticle implements ObjectTypeInterface
|
||||
class InlineQueryResultArticle extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var InputTextMessageContent|InputLocationMessageContent|InputVenueMessageContent|InputContactMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hide_url;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $thumbnail_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $thumbnail_height;
|
||||
|
||||
/**
|
||||
* InlineQueryResultArticle constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'article';
|
||||
}
|
||||
|
||||
/**
|
||||
* The Type of the result must be article
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field.
|
||||
* Unique identifier for this result, 1-64 Bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultArticle
|
||||
{
|
||||
if(!Validate::length($id, 1, 64))
|
||||
{
|
||||
throw new InvalidArgumentException('id should be between 1-64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private string $title;
|
||||
private InputMessageContent $input_message_content;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?string $url;
|
||||
private bool $hide_url;
|
||||
private ?string $description;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
|
||||
/**
|
||||
* Title of the result
|
||||
|
@ -144,9 +48,9 @@
|
|||
/**
|
||||
* Content of the message to be sent
|
||||
*
|
||||
* @return InputContactMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -155,10 +59,10 @@
|
|||
* Sets the value of the 'input_message_content' field.
|
||||
* Content of the message to be sent
|
||||
*
|
||||
* @param InputContactMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|null $input_message_content): InlineQueryResultArticle
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultArticle
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
|
@ -336,18 +240,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'input_message_content' => ($this->input_message_content instanceof ObjectTypeInterface) ? $this->input_message_content->toArray() : null,
|
||||
'reply_markup' => ($this->reply_markup instanceof ObjectTypeInterface) ? $this->reply_markup->toArray() : null,
|
||||
'input_message_content' => $this->input_message_content?->toArray(),
|
||||
'reply_markup' => $this->reply_markup?->toArray(),
|
||||
'url' => $this->url,
|
||||
'hide_url' => $this->hide_url,
|
||||
'description' => $this->description,
|
||||
|
@ -358,20 +260,16 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultArticle
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::ARTICLE;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->input_message_content = InputMessageContent::fromArray($data['input_message_content'] ?? []);
|
||||
$object->reply_markup = InlineKeyboardMarkup::fromArray($data['reply_markup'] ?? []);
|
||||
$object->input_message_content = isset($data['input_message_content']) ? InputMessageContent::fromArray($data['input_message_content']) : null;
|
||||
$object->reply_markup = isset($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->url = $data['url'] ?? null;
|
||||
$object->hide_url = $data['hide_url'] ?? null;
|
||||
$object->description = $data['description'] ?? null;
|
|
@ -1,123 +1,30 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultAudio implements ObjectTypeInterface
|
||||
class InlineQueryResultAudio extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $audio_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $audio_url;
|
||||
private string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $performer;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $audio_duration;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultAudio constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'audio';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result, must be audio
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of 'id' property
|
||||
* Unique identifier for this result, 1-64 bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultAudio
|
||||
{
|
||||
if(!Validate::length($id, 1, 64))
|
||||
{
|
||||
throw new InvalidArgumentException(sprintf('id must be between 1 and 64 characters long, got %s characters', $id));
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private ?string $performer;
|
||||
private ?int $audio_duration;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
|
||||
/**
|
||||
* A valid URL for the audio file
|
||||
|
@ -362,9 +269,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the audio
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -373,32 +280,28 @@
|
|||
* Sets the value of 'input_message_content' property
|
||||
* Optional. Content of the message to be sent instead of the audio
|
||||
*
|
||||
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultAudio
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultAudio
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'audio_url' => $this->audio_url,
|
||||
'title' => $this->title,
|
||||
'caption' => $this->caption,
|
||||
'parse_mode' => $this->parse_mode,
|
||||
'caption_entities' => ($this->caption_entities) ? array_map(static function (MessageEntity $messageEntity) {
|
||||
return $messageEntity->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'caption_entities' => array_map(fn(MessageEntity $messageEntity) => $messageEntity->toArray(), $this->caption_entities),
|
||||
'performer' => $this->performer,
|
||||
'audio_duration' => $this->audio_duration,
|
||||
'reply_markup' => ($this->reply_markup) ? $this->reply_markup->toArray() : null,
|
||||
|
@ -407,24 +310,18 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultAudio
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::AUDIO;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->audio_url = $data['audio_url'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = ($data['caption_entities']) ? array_map(static function (array $messageEntity) {
|
||||
return MessageEntity::fromArray($messageEntity);
|
||||
}, $data['caption_entities']) : null;
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $messageEntity) => MessageEntity::fromArray($messageEntity), $data['caption_entities']) : null;
|
||||
$object->performer = $data['performer'] ?? null;
|
||||
$object->audio_duration = $data['audio_duration'] ?? null;
|
||||
$object->reply_markup = ($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
|
@ -3,121 +3,27 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultContact implements ObjectTypeInterface
|
||||
class InlineQueryResultContact extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $phone_number;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $first_name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $last_name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $vcard;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* InlineQueryResultContact constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'contact';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result must be contact
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of 'id' property
|
||||
* Unique identifier for this result, 1-64 Bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): self
|
||||
{
|
||||
if(!Validate::length($id, 1, 64))
|
||||
{
|
||||
throw new InvalidArgumentException('id should be between 1-64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private string $phone_number;
|
||||
private string $first_name;
|
||||
private ?string $last_name;
|
||||
private ?string $vcard;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
|
||||
/**
|
||||
* Contact's phone number
|
||||
|
@ -242,9 +148,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the contact
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -253,10 +159,10 @@
|
|||
* Sets the value of 'input_message_content' property
|
||||
* Optional. Content of the message to be sent instead of the contact
|
||||
*
|
||||
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): self
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): self
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
|
@ -332,21 +238,19 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'phone_number' => $this->phone_number,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'vcard' => $this->vcard,
|
||||
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null,
|
||||
'input_message_content' => ($this->input_message_content instanceof ObjectTypeInterface) ? $this->input_message_content->toArray() : null,
|
||||
'reply_markup' => $this->reply_markup?->toArray(),
|
||||
'input_message_content' => $this->input_message_content?->toArray(),
|
||||
'thumbnail_url' => $this->thumbnail_url,
|
||||
'thumbnail_width' => $this->thumbnail_width,
|
||||
'thumbnail_height' => $this->thumbnail_height
|
||||
|
@ -354,15 +258,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultContact
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = InlineQueryResultType::CONTACT;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->phone_number = $data['phone_number'] ?? null;
|
||||
$object->first_name = $data['first_name'] ?? null;
|
|
@ -3,118 +3,35 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultDocument implements ObjectTypeInterface
|
||||
class InlineQueryResultDocument extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $document_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mime_type;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* InlineQueryResultDocument constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'document';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result, must be document
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private string $document_url;
|
||||
private string $mime_type;
|
||||
private ?string $description;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
|
||||
/**
|
||||
* Title for the result
|
||||
|
@ -344,9 +261,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the file
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -355,10 +272,10 @@
|
|||
* Sets the value of the 'input_message_content' field.
|
||||
* Optional. Content of the message to be sent instead of the file
|
||||
*
|
||||
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultDocument
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultDocument
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
|
@ -439,31 +356,22 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'caption' => $this->caption,
|
||||
'parse_mode' => $this->parse_mode,
|
||||
'caption_entities' => (function (array $data) {
|
||||
$result = [];
|
||||
foreach ($data as $item) {
|
||||
$result[] = $item->toArray();
|
||||
}
|
||||
|
||||
return $result;
|
||||
})($this->caption_entities ?? []),
|
||||
'caption_entities' => array_map(fn(MessageEntity $entity) => $entity->toArray(), $this->caption_entities),
|
||||
'document_url' => $this->document_url,
|
||||
'mime_type' => $this->mime_type,
|
||||
'description' => $this->description,
|
||||
'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,
|
||||
'reply_markup' => $this->reply_markup?->toArray(),
|
||||
'input_message_content' => $this->input_message_content?->toArray(),
|
||||
'thumbnail_url' => $this->thumbnail_url,
|
||||
'thumbnail_width' => $this->thumbnail_width,
|
||||
'thumbnail_height' => $this->thumbnail_height,
|
||||
|
@ -471,33 +379,22 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultDocument
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::DOCUMENT;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = (function (array $data) {
|
||||
$result = [];
|
||||
foreach ($data as $item) {
|
||||
$result[] = MessageEntity::fromArray($item);
|
||||
}
|
||||
|
||||
return $result;
|
||||
})($data['caption_entities'] ?? []);
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $entity) => MessageEntity::fromArray($entity), $data['caption_entities']) : null;
|
||||
$object->document_url = $data['document_url'] ?? null;
|
||||
$object->mime_type = $data['mime_type'] ?? null;
|
||||
$object->description = $data['description'] ?? null;
|
||||
$object->reply_markup = ($data['reply_markup'] ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null);
|
||||
$object->input_message_content = ($data['input_message_content'] ? InputVenueMessageContent::fromArray($data['input_message_content']) : 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;
|
|
@ -3,52 +3,17 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
class InlineQueryResultGame implements ObjectTypeInterface
|
||||
class InlineQueryResultGame extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $game_short_name;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* Type of the result must be game
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
private string $game_short_name;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field
|
||||
|
@ -109,34 +74,28 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'game_short_name' => $this->game_short_name,
|
||||
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null
|
||||
'reply_markup' => $this->reply_markup?->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultGame
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::GAME;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->game_short_name = $data['game_short_name'] ?? null;
|
||||
$object->reply_markup = $data['reply_markup'] ?? null;
|
||||
$object->reply_markup = isset($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
|
||||
return $object;
|
||||
}
|
|
@ -3,138 +3,35 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Classes\Validate;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Enums\Types\ThumbnailMimeType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultGif implements ObjectTypeInterface
|
||||
class InlineQueryResultGif extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $gif_url;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $gif_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $gif_height;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $gif_duration;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
* @see ThumbnailMimeType
|
||||
*/
|
||||
private $thumbnail_mime_type;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $gif_url;
|
||||
private ?int $gif_width;
|
||||
private ?int $gif_height;
|
||||
private ?int $gif_duration;
|
||||
private ?string $thumbnail_url;
|
||||
private ?ThumbnailMimeType $thumbnail_mime_type;
|
||||
private ?string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultGif constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'gif';
|
||||
}
|
||||
|
||||
/**
|
||||
* The Type of the result must be gif
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field.
|
||||
* Unique identifier for this result, 1-64 bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultGif
|
||||
{
|
||||
if(!Validate::length($id, 1, 64))
|
||||
{
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
|
||||
/**
|
||||
* A valid URL for the GIF file. File size must not exceed 1MB
|
||||
|
@ -276,9 +173,9 @@
|
|||
/**
|
||||
* Optional. MIME type of the thumbnail must be one of “image/jpeg,” “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
|
||||
*
|
||||
* @return string|null
|
||||
* @return ThumbnailMimeType|null
|
||||
*/
|
||||
public function getThumbnailMimeType(): ?string
|
||||
public function getThumbnailMimeType(): ?ThumbnailMimeType
|
||||
{
|
||||
return $this->thumbnail_mime_type;
|
||||
}
|
||||
|
@ -287,10 +184,10 @@
|
|||
* Sets the value of the 'thumbnail_mime_type' field.
|
||||
* Optional. MIME type of the thumbnail must be one of “image/jpeg,” “image/gif”, or “video/mp4”. Defaults to “image/jpeg”
|
||||
*
|
||||
* @param string|null $thumbnail_mime_type
|
||||
* @param string|ThumbnailMimeType|null $thumbnail_mime_type
|
||||
* @return $this
|
||||
*/
|
||||
public function setThumbnailMimeType(?string $thumbnail_mime_type): InlineQueryResultGif
|
||||
public function setThumbnailMimeType(string|ThumbnailMimeType|null $thumbnail_mime_type): InlineQueryResultGif
|
||||
{
|
||||
if(is_null($thumbnail_mime_type))
|
||||
{
|
||||
|
@ -298,6 +195,16 @@
|
|||
return $this;
|
||||
}
|
||||
|
||||
if(is_string($thumbnail_mime_type))
|
||||
{
|
||||
$thumbnail_mime_type = ThumbnailMimeType::tryFrom($thumbnail_mime_type);
|
||||
}
|
||||
|
||||
if($thumbnail_mime_type === null)
|
||||
{
|
||||
throw new InvalidArgumentException('Unexpected type for ThumbnailMimeType');
|
||||
}
|
||||
|
||||
$this->thumbnail_mime_type = $thumbnail_mime_type;
|
||||
return $this;
|
||||
}
|
||||
|
@ -437,9 +344,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the GIF animation
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -448,25 +355,22 @@
|
|||
* Sets the value of the 'input_message_content' field.
|
||||
* Optional. Content of the message to be sent instead of the GIF animation
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultGif
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultGif
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type ?? null,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id ?? null,
|
||||
'gif_url' => $this->gif_url ?? null,
|
||||
'gif_width' => $this->gif_width ?? null,
|
||||
|
@ -477,36 +381,19 @@
|
|||
'title' => $this->title ?? null,
|
||||
'caption' => $this->caption ?? null,
|
||||
'parse_mode' => $this->parse_mode ?? null,
|
||||
'caption_entities' => (static function (array $captionEntities)
|
||||
{
|
||||
$result = [];
|
||||
foreach($captionEntities as $captionEntity)
|
||||
{
|
||||
$result[] = $captionEntity->toArray();
|
||||
}
|
||||
return $result;
|
||||
})($this->caption_entities ?? []),
|
||||
'reply_markup' => (static function (InlineKeyboardMarkup|null $replyMarkup) {
|
||||
return $replyMarkup?->toArray();
|
||||
})($this->reply_markup ?? null),
|
||||
'input_message_content' => (static function (ObjectTypeInterface|null $inputMessageContent) {
|
||||
return $inputMessageContent?->toArray();
|
||||
})($this->input_message_content ?? null),
|
||||
'caption_entities' => array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
|
||||
'reply_markup' => $this->reply_markup?->toArray(),
|
||||
'input_message_content' => $this->input_message_content?->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @noinspection DuplicatedCode
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultGif
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::GIF;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->gif_url = $data['gif_url'] ?? null;
|
||||
$object->gif_width = $data['gif_width'] ?? null;
|
||||
|
@ -517,37 +404,9 @@
|
|||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
|
||||
$object->caption_entities = (static function (array $captionEntities)
|
||||
{
|
||||
$result = [];
|
||||
foreach($captionEntities as $captionEntity)
|
||||
{
|
||||
$result[] = MessageEntity::fromArray($captionEntity);
|
||||
}
|
||||
|
||||
return $result;
|
||||
})($data['caption_entities'] ?? []);
|
||||
|
||||
$object->reply_markup = (static function (array|null $replyMarkup)
|
||||
{
|
||||
if($replyMarkup !== null)
|
||||
{
|
||||
return InlineKeyboardMarkup::fromArray($replyMarkup);
|
||||
}
|
||||
|
||||
return null;
|
||||
})($data['reply_markup'] ?? null);
|
||||
|
||||
$object->input_message_content = (static function (array|null $inputMessageContent)
|
||||
{
|
||||
if($inputMessageContent !== null)
|
||||
{
|
||||
return InputVenueMessageContent::fromArray($inputMessageContent);
|
||||
}
|
||||
|
||||
return null;
|
||||
})($data['input_message_content'] ?? null);
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $items) => MessageEntity::fromArray($items), $data['caption_entities']) : null;
|
||||
$object->reply_markup = isset($data['reply_markup']) ? array_map(fn(array $items) => InlineKeyboardMarkup::fromArray($items), $data['reply_markup']) : null;
|
||||
$object->input_message_content = isset($data['input_message_content']) ? InputMessageContent::fromArray($data['input_message_content']) : null;
|
||||
|
||||
return $object;
|
||||
}
|
|
@ -2,133 +2,30 @@
|
|||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultLocation implements ObjectTypeInterface
|
||||
class InlineQueryResultLocation extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $latitude;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $longitude;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var float|null
|
||||
*/
|
||||
private $horizontal_accuracy;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $live_period;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $heading;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $proximity_alert_radius;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* InlineQueryResultLocation constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'location';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result must be location
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a unique identifier for this result, 1-64 Bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultLocation
|
||||
{
|
||||
if(strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('id should be less than 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private float $latitude;
|
||||
private float $longitude;
|
||||
private string $title;
|
||||
private ?float $horizontal_accuracy;
|
||||
private ?int $live_period;
|
||||
private ?int $heading;
|
||||
private ?int $proximity_alert_radius;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
|
||||
/**
|
||||
* Location latitude in degrees
|
||||
|
@ -331,9 +228,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the location
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -341,10 +238,10 @@
|
|||
/**
|
||||
* Sets the content of the message to be sent instead of the location
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(null|InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent $input_message_content): InlineQueryResultLocation
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultLocation
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
|
@ -417,14 +314,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'latitude' => $this->latitude,
|
||||
'longitude' => $this->longitude,
|
||||
|
@ -442,16 +337,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from an array representation.
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultLocation
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::LOCATION;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->latitude = $data['latitude'] ?? null;
|
||||
$object->longitude = $data['longitude'] ?? null;
|
||||
|
@ -460,8 +351,8 @@
|
|||
$object->live_period = $data['live_period'] ?? null;
|
||||
$object->heading = $data['heading'] ?? null;
|
||||
$object->proximity_alert_radius = $data['proximity_alert_radius'] ?? null;
|
||||
$object->reply_markup = ($data['reply_markup'] ?? null) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->input_message_content = ($data['input_message_content'] ?? null) ? InputContactMessageContent::fromArray($data['input_message_content']) : null;
|
||||
$object->reply_markup = isset($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->input_message_content = isset($data['input_message_content']) ? InputMessageContent::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;
|
|
@ -3,128 +3,33 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultMpeg4Gif implements ObjectTypeInterface
|
||||
class InlineQueryResultMpeg4Gif extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mpeg4_url;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $mpeg4_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $mpeg4_height;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $mpeg4_duration;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $thumbnail_mime_type;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $mpeg4_url;
|
||||
private ?int $mpeg4_width;
|
||||
private ?int $mpeg4_height;
|
||||
private ?int $mpeg4_duration;
|
||||
private string $thumbnail_url;
|
||||
private ?string $thumbnail_mime_type;
|
||||
private ?string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultMpeg4Gif constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'mpeg4_gif';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result, must be mpeg4_gif
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultMpeg4Gif
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
|
||||
/**
|
||||
* A valid URL for the MPEG4 file. File size must not exceed 1MB
|
||||
|
@ -371,9 +276,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the video animation
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -381,19 +286,17 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the video animation
|
||||
*
|
||||
* @param InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultMpeg4Gif
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultMpeg4Gif
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
@ -409,9 +312,7 @@
|
|||
'title' => $this->title ?? null,
|
||||
'caption' => $this->caption ?? null,
|
||||
'parse_mode' => $this->parse_mode ?? null,
|
||||
'caption_entities' => ($this->caption_entities ?? null) ? array_map(static function (MessageEntity $item) {
|
||||
return $item->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'caption_entities' => is_null($this->caption_entities) ? array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities) : null,
|
||||
'reply_markup' => ($this->reply_markup ?? null) ? $this->reply_markup->toArray() : null,
|
||||
'input_message_content' => ($this->input_message_content ?? null) ? $this->input_message_content->toArray() : null,
|
||||
];
|
||||
|
@ -419,30 +320,23 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultMpeg4Gif
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::MPEG_4_GIF;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->mpeg4_url = $data['mpeg4_url'] ?? null;
|
||||
$object->mpeg4_width = $data['mpeg4_width'] ?? null;
|
||||
$object->mpeg4_height = $data['mpeg4_height'] ?? null;
|
||||
$object->mpeg4_duration = $data['mpeg4_duration'] ?? null;
|
||||
/** @noinspection DuplicatedCode */
|
||||
$object->thumbnail_url = $data['thumbnail_url'] ?? null;
|
||||
$object->thumbnail_mime_type = $data['thumbnail_mime_type'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = array_map(static function ($item) {
|
||||
return MessageEntity::fromArray($item);
|
||||
}, $data['caption_entities'] ?? []);
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $items) => MessageEntity::fromArray($items), $data['caption_entities']) : null;
|
||||
$object->reply_markup = ($data['reply_markup'] ?? null) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->input_message_content = ($data['input_message_content'] ?? null) ? InputVenueMessageContent::fromArray($data['input_message_content']) : null;
|
||||
|
|
@ -3,129 +3,33 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultPhoto implements ObjectTypeInterface
|
||||
class InlineQueryResultPhoto extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $photo_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $photo_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $photo_height;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $photo_url;
|
||||
private string $thumbnail_url;
|
||||
private ?int $photo_width;
|
||||
private ?int $photo_height;
|
||||
private ?string $title;
|
||||
private ?string $description;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultPhoto constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'photo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result must be photo
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the 'id' field
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultPhoto
|
||||
{
|
||||
if(mb_strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('id length must not exceed 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputTextMessageContent $input_message_content;
|
||||
|
||||
/**
|
||||
* A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
|
||||
|
@ -356,9 +260,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the photo
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -366,19 +270,17 @@
|
|||
/**
|
||||
* Sets the value of the 'input_message_content' field
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): InlineQueryResultPhoto
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultPhoto
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
@ -393,24 +295,18 @@
|
|||
'description' => $this->description ?? null,
|
||||
'caption' => $this->caption ?? null,
|
||||
'parse_mode' => $this->parse_mode ?? null,
|
||||
'caption_entities' => ($this->caption_entities !== null) ? array_map(static function (MessageEntity $messageEntity) {
|
||||
return $messageEntity->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'caption_entities' => isset($data['caption_entities']) ? array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities) : null,
|
||||
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultPhoto
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::PHOTO;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->photo_url = $data['photo_url'] ?? null;
|
||||
$object->thumbnail_url = $data['thumbnail_url'] ?? null;
|
||||
|
@ -420,9 +316,7 @@
|
|||
$object->description = $data['description'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = ($data['caption_entities'] !== null) ? array_map(static function (array $messageEntity) {
|
||||
return MessageEntity::fromArray($messageEntity);
|
||||
}, $data['caption_entities']) : null;
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $items) => MessageEntity::fromArray($items), $data['caption_entities']) : null;
|
||||
$object->reply_markup = ($data['reply_markup'] !== null) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->input_message_content = $data['input_message_content'] ?? null;
|
||||
|
|
@ -2,138 +2,30 @@
|
|||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultVenue implements ObjectTypeInterface
|
||||
class InlineQueryResultVenue extends InlineQueryResult 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets id.
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultVenue
|
||||
{
|
||||
if(strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('id must be between 1 and 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private float $latitude;
|
||||
private float $longitude;
|
||||
private string $title;
|
||||
private string $address;
|
||||
private ?string $foursquare_id;
|
||||
private ?string $foursquare_type;
|
||||
private ?string $google_place_id;
|
||||
private ?string $google_place_type;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
private ?string $thumbnail_url;
|
||||
private ?int $thumbnail_width;
|
||||
private ?int $thumbnail_height;
|
||||
|
||||
/**
|
||||
* Latitude of the venue location in degrees
|
||||
|
@ -338,9 +230,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the venue
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -348,10 +240,10 @@
|
|||
/**
|
||||
* Sets the content of the message to be sent instead of the venue
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(null|InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent $input_message_content): InlineQueryResultVenue
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultVenue
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
|
@ -424,14 +316,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'latitude' => $this->latitude,
|
||||
'longitude' => $this->longitude,
|
||||
|
@ -441,8 +331,8 @@
|
|||
'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,
|
||||
'reply_markup' => $this->reply_markup?->toArray(),
|
||||
'input_message_content' => $this->input_message_content?->toArray(),
|
||||
'thumbnail_url' => $this->thumbnail_url,
|
||||
'thumbnail_width' => $this->thumbnail_width,
|
||||
'thumbnail_height' => $this->thumbnail_height
|
||||
|
@ -450,16 +340,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @noinspection DuplicatedCode
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultVenue
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = InlineQueryResultType::VENUE;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->latitude = $data['latitude'] ?? null;
|
||||
$object->longitude = $data['longitude'] ?? null;
|
|
@ -3,140 +3,34 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultVideo implements ObjectTypeInterface
|
||||
class InlineQueryResultVideo extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $video_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $mime_type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $thumbnail_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $video_url;
|
||||
private string $mime_type;
|
||||
private string $thumbnail_url;
|
||||
private string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $video_width;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $video_height;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $video_duration;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultVideo constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'video';
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of the result, must be video
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the unique identifier for this result, 1-64 bytes
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultVideo
|
||||
{
|
||||
if(strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('ID must be between 1 and 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
private ?array $caption_entities;
|
||||
private ?int $video_width;
|
||||
private ?int $video_height;
|
||||
private ?int $video_duration;
|
||||
private ?string $description;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private ?InputMessageContent $input_message_content;
|
||||
|
||||
/**
|
||||
* A valid URL for the embedded video player or video file
|
||||
|
@ -416,9 +310,9 @@
|
|||
* Optional. Content of the message to be sent instead of the video. This field is required if
|
||||
* InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -426,19 +320,17 @@
|
|||
/**
|
||||
* Sets the content of the message to be sent instead of the video. This field is required if
|
||||
*
|
||||
* @param InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null $input_message_content): static
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): static
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
@ -451,9 +343,7 @@
|
|||
'title' => $this->title,
|
||||
'caption' => $this->caption,
|
||||
'parse_mode' => $this->parse_mode,
|
||||
'caption_entities' => ($this->caption_entities ?? null) ? array_map(static function (MessageEntity $item) {
|
||||
return $item->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'caption_entities' => is_null($this->caption_entities) ? null : array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
|
||||
'video_width' => $this->video_width,
|
||||
'video_height' => $this->video_height,
|
||||
'video_duration' => $this->video_duration,
|
||||
|
@ -464,16 +354,12 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::VIDEO;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->video_url = $data['video_url'] ?? null;
|
||||
$object->mime_type = $data['mime_type'] ?? null;
|
||||
|
@ -481,9 +367,7 @@
|
|||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(static function ($item) {
|
||||
return MessageEntity::fromArray($item);
|
||||
}, $data['caption_entities']) : null;
|
||||
$object->caption_entities = isset($data['caption_entities']) ? array_map(fn(array $items) => MessageEntity::fromArray($items), $data['caption_entities']) : null;
|
||||
$object->video_width = $data['video_width'] ?? null;
|
||||
$object->video_height = $data['video_height'] ?? null;
|
||||
$object->video_duration = $data['video_duration'] ?? null;
|
|
@ -3,111 +3,30 @@
|
|||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\InlineQueryResult;
|
||||
namespace TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultVoice implements ObjectTypeInterface
|
||||
class InlineQueryResultVoice extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $voice_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
private string $voice_url;
|
||||
private string $title;
|
||||
private ?string $caption;
|
||||
private ?string $parse_mode;
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $voice_duration;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var \TgBotLib\Objects\InputMessageContent\InputContactMessageContent|\TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent|\TgBotLib\Objects\InputMessageContent\InputLocationMessageContent|\TgBotLib\Objects\InputMessageContent\InputTextMessageContent|\TgBotLib\Objects\InputMessageContent\InputVenueMessageContent|null
|
||||
*/
|
||||
private ?array $caption_entities;
|
||||
private ?int $voice_duration;
|
||||
private ?InlineKeyboardMarkup $reply_markup;
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* InlineQueryResultVoice constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = 'voice';
|
||||
}
|
||||
|
||||
/**
|
||||
* The Type of the result must be voice
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id of the result.
|
||||
*
|
||||
* @param string $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId(string $id): InlineQueryResultVoice
|
||||
{
|
||||
if(strlen($id) > 64)
|
||||
{
|
||||
throw new InvalidArgumentException('id must be between 1 and 64 characters');
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid URL for the voice recording
|
||||
*
|
||||
|
@ -272,9 +191,9 @@
|
|||
/**
|
||||
* Optional. Content of the message to be sent instead of the voice recording
|
||||
*
|
||||
* @return \TgBotLib\Objects\InputMessageContent\InputContactMessageContent|\TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent|\TgBotLib\Objects\InputMessageContent\InputLocationMessageContent|\TgBotLib\Objects\InputMessageContent\InputTextMessageContent|\TgBotLib\Objects\InputMessageContent\InputVenueMessageContent|null
|
||||
* @return InputMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): \TgBotLib\Objects\InputMessageContent\InputContactMessageContent|\TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent|\TgBotLib\Objects\InputMessageContent\InputLocationMessageContent|\TgBotLib\Objects\InputMessageContent\InputTextMessageContent|\TgBotLib\Objects\InputMessageContent\InputVenueMessageContent|null
|
||||
public function getInputMessageContent(): ?InputMessageContent
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
@ -282,36 +201,28 @@
|
|||
/**
|
||||
* Sets the input_message_content of the result.
|
||||
*
|
||||
* @param \TgBotLib\Objects\InputMessageContent\InputContactMessageContent|\TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent|\TgBotLib\Objects\InputMessageContent\InputLocationMessageContent|\TgBotLib\Objects\InputMessageContent\InputTextMessageContent|\TgBotLib\Objects\InputMessageContent\InputVenueMessageContent $input_message_content
|
||||
* @param InputMessageContent|null $input_message_content
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputMessageContent(\TgBotLib\Objects\InputMessageContent\InputContactMessageContent|\TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent|\TgBotLib\Objects\InputMessageContent\InputLocationMessageContent|\TgBotLib\Objects\InputMessageContent\InputTextMessageContent|\TgBotLib\Objects\InputMessageContent\InputVenueMessageContent $input_message_content): InlineQueryResultVoice
|
||||
public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultVoice
|
||||
{
|
||||
$this->input_message_content = $input_message_content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object.
|
||||
*
|
||||
* @return array
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'type' => $this->type->value,
|
||||
'id' => $this->id,
|
||||
'voice_url' => $this->voice_url,
|
||||
'title' => $this->title,
|
||||
'caption' => $this->caption,
|
||||
'parse_mode' => $this->parse_mode,
|
||||
'caption_entities' => (static function (array $data) {
|
||||
$result = [];
|
||||
foreach ($data as $item) {
|
||||
$result[] = $item->toArray();
|
||||
}
|
||||
return $result;
|
||||
})($this->caption_entities ?? null),
|
||||
'caption_entities' => is_null($this->caption_entities) ? null : array_map(fn(MessageEntity $item) => $item->toArray(), $this->caption_entities),
|
||||
'voice_duration' => $this->voice_duration,
|
||||
'reply_markup' => ($this->reply_markup instanceof InlineKeyboardMarkup) ? $this->reply_markup->toArray() : null,
|
||||
'input_message_content' => ($this->input_message_content instanceof ObjectTypeInterface) ? $this->input_message_content->toArray() : null,
|
||||
|
@ -319,30 +230,18 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
* @noinspection DuplicatedCode
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
public static function fromArray(array $data): InlineQueryResultVoice
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->type = InlineQueryResultType::VOICE;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->voice_url = $data['voice_url'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = (static function (array $data) {
|
||||
$result = [];
|
||||
foreach ($data as $item)
|
||||
{
|
||||
$result[] = MessageEntity::fromArray($item);
|
||||
}
|
||||
return $result;
|
||||
})($data['caption_entities'] ?? []);
|
||||
$object->caption_entities = array_map(fn(array $items) => MessageEntity::fromArray($items), $data['caption_entities']);
|
||||
$object->voice_duration = $data['voice_duration'] ?? null;
|
||||
$object->reply_markup = InlineKeyboardMarkup::fromArray($data['reply_markup'] ?? []);
|
||||
$object->input_message_content = InputMessageContent::fromArray($data['input_message_content'] ?? []);
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InlineQueryResultType;
|
||||
use TgBotLib\Exceptions\NotImplementedException;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultArticle;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultAudio;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultContact;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultDocument;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultGame;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultGif;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultLocation;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultMpeg4Gif;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultPhoto;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultVenue;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultVideo;
|
||||
use TgBotLib\Objects\InlineQueryResult\InlineQueryResultVoice;
|
||||
|
||||
class InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
* @throws NotImplementedException
|
||||
* @deprecated Don't use, use fromArray() instead directly to construct the appropriate child class
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
throw new NotImplementedException('This object is abstract, you can\'t use it directly, try constructing one of the child classes with fromArray()');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object constructed from the given array
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
if(!isset($data['type']))
|
||||
{
|
||||
throw new InvalidArgumentException('The type of the InlineQueryResult is not set, this is required!');
|
||||
}
|
||||
|
||||
return match (strtolower($data['type']))
|
||||
{
|
||||
InlineQueryResultType::ARTICLE => InlineQueryResultArticle::fromArray($data),
|
||||
InlineQueryResultType::PHOTO => InlineQueryResultPhoto::fromArray($data),
|
||||
InlineQueryResultType::GIF => InlineQueryResultGif::fromArray($data),
|
||||
InlineQueryResultType::MPEG_4_GIF => InlineQueryResultMpeg4Gif::fromArray($data),
|
||||
InlineQueryResultType::VIDEO => InlineQueryResultVideo::fromArray($data),
|
||||
InlineQueryResultType::AUDIO => InlineQueryResultAudio::fromArray($data),
|
||||
InlineQueryResultType::VOICE => InlineQueryResultVoice::fromArray($data),
|
||||
InlineQueryResultType::DOCUMENT => InlineQueryResultDocument::fromArray($data),
|
||||
InlineQueryResultType::LOCATION => InlineQueryResultLocation::fromArray($data),
|
||||
InlineQueryResultType::VENUE => InlineQueryResultVenue::fromArray($data),
|
||||
InlineQueryResultType::CONTACT => InlineQueryResultContact::fromArray($data),
|
||||
InlineQueryResultType::GAME => InlineQueryResultGame::fromArray($data),
|
||||
default => throw new InvalidArgumentException(sprintf('The type of the InlineQueryResult is invalid, got "%s", expected one of "%s"', $data['type'], implode('", "', InlineQueryResultType::ALL))),
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue