1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Type\InlineQueryResult; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
9
|
|
|
use TgBotApi\BotApiBase\Type\InputMessageContent\InputMessageContentType; |
10
|
|
|
use TgBotApi\BotApiBase\Type\Traits\CaptionEntitiesFieldTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class InlineQueryResultDocumentType. |
14
|
|
|
* |
15
|
|
|
* Represents a link to a file. By default, this file will be sent by the user with an optional caption. |
16
|
|
|
* Alternatively, you can use input_message_content to send a message with the specified content instead of the file. |
17
|
|
|
* Currently, only .PDF and .ZIP files can be sent using this method. |
18
|
|
|
* |
19
|
|
|
* @see https://core.telegram.org/bots/api#inlinequeryresultdocument |
20
|
|
|
*/ |
21
|
|
|
class InlineQueryResultDocumentType extends InlineQueryResultType implements HasParseModeVariableInterface |
22
|
|
|
{ |
23
|
|
|
use CaptionEntitiesFieldTrait; |
24
|
|
|
use FillFromArrayTrait; |
25
|
|
|
|
26
|
|
|
public const MIME_TYPE_PDF = 'application/pdf'; |
27
|
|
|
public const MIME_TYPE_ZIP = 'application/zip'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Title for the result;. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
public $title; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* A valid URL for the file. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
public $documentUrl; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Mime type of the content of the file, either “application/pdf” or “application/zip”. |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
* |
48
|
|
|
* @see InlineQueryResultDocumentType::MIME_TYPE_PDF, InlineQueryResultDocumentType::MIME_TYPE_ZIP |
49
|
|
|
*/ |
50
|
|
|
public $mimeType; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Optional. Caption of the document to be sent, 0-1024 characters. |
54
|
|
|
* |
55
|
|
|
* @var string|null |
56
|
|
|
*/ |
57
|
|
|
public $caption; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, |
61
|
|
|
* fixed-width text or inline URLs in the media caption. |
62
|
|
|
* |
63
|
|
|
* @var string|null |
64
|
|
|
*/ |
65
|
|
|
public $parseMode; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Optional. Short description of the result. |
69
|
|
|
* |
70
|
|
|
* @var string|null |
71
|
|
|
*/ |
72
|
|
|
public $description; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Optional. Content of the message to be sent instead of the file. |
76
|
|
|
* |
77
|
|
|
* @var InputMessageContentType|null |
78
|
|
|
*/ |
79
|
|
|
public $inputMessageContent; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Optional. URL of the thumbnail (jpeg only) for the file. |
83
|
|
|
* |
84
|
|
|
* @var string|null |
85
|
|
|
*/ |
86
|
|
|
public $thumbUrl; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Optional. Thumbnail width. |
90
|
|
|
* |
91
|
|
|
* @var int|null |
92
|
|
|
*/ |
93
|
|
|
public $thumbWidth; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Optional. Thumbnail height. |
97
|
|
|
* |
98
|
|
|
* @var int|null |
99
|
|
|
*/ |
100
|
|
|
public $thumbHeight; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
104
|
|
|
*/ |
105
|
|
|
public static function create( |
106
|
|
|
string $id, |
107
|
|
|
string $title, |
108
|
|
|
string $documentUrl, |
109
|
|
|
string $mimeType, |
110
|
|
|
array $data = null |
111
|
|
|
): InlineQueryResultDocumentType { |
112
|
|
|
$instance = new static(); |
113
|
|
|
$instance->type = static::TYPE_DOCUMENT; |
114
|
|
|
$instance->id = $id; |
115
|
|
|
$instance->title = $title; |
116
|
|
|
$instance->documentUrl = $documentUrl; |
117
|
|
|
$instance->$mimeType = $mimeType; |
118
|
|
|
if ($data) { |
119
|
|
|
$instance->fill($data); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return $instance; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|