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