1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Zanzara\Telegram\Type\File; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This object represents a file ready to be downloaded. The file can be downloaded via the link |
9
|
|
|
* https://api.telegram.org/file/bot<token>/<file_path>;. It is guaranteed that the link will be valid for |
10
|
|
|
* at least 1 hour. When the link expires, a new one can be requested by calling getFile. |
11
|
|
|
* |
12
|
|
|
* More on https://core.telegram.org/bots/api#file |
13
|
|
|
*/ |
14
|
|
|
class File |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Identifier for this file, which can be used to download or reuse the file |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $file_id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to |
26
|
|
|
* download or reuse the file. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
private $file_unique_id; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Optional. File size, if known |
34
|
|
|
* |
35
|
|
|
* @var int|null |
36
|
|
|
*/ |
37
|
|
|
private $file_size; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file. |
41
|
|
|
* |
42
|
|
|
* @var string|null |
43
|
|
|
*/ |
44
|
|
|
private $file_path; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function getFileId(): string |
50
|
|
|
{ |
51
|
|
|
return $this->file_id; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $file_id |
56
|
|
|
*/ |
57
|
|
|
public function setFileId(string $file_id): void |
58
|
|
|
{ |
59
|
|
|
$this->file_id = $file_id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getFileUniqueId(): string |
66
|
|
|
{ |
67
|
|
|
return $this->file_unique_id; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $file_unique_id |
72
|
|
|
*/ |
73
|
|
|
public function setFileUniqueId(string $file_unique_id): void |
74
|
|
|
{ |
75
|
|
|
$this->file_unique_id = $file_unique_id; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return int|null |
80
|
|
|
*/ |
81
|
|
|
public function getFileSize(): ?int |
82
|
|
|
{ |
83
|
|
|
return $this->file_size; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param int|null $file_size |
88
|
|
|
*/ |
89
|
|
|
public function setFileSize(?int $file_size): void |
90
|
|
|
{ |
91
|
|
|
$this->file_size = $file_size; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string|null |
96
|
|
|
*/ |
97
|
|
|
public function getFilePath(): ?string |
98
|
|
|
{ |
99
|
|
|
return $this->file_path; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string|null $file_path |
104
|
|
|
*/ |
105
|
|
|
public function setFilePath(?string $file_path): void |
106
|
|
|
{ |
107
|
|
|
$this->file_path = $file_path; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
} |