1 | <?php |
||
20 | class TgLog |
||
21 | { |
||
22 | /** |
||
23 | * @var RequestHandlerInterface |
||
24 | */ |
||
25 | protected $requestHandler; |
||
26 | |||
27 | /** |
||
28 | * @var PostOptionsConstructor |
||
29 | */ |
||
30 | protected $formConstructor; |
||
31 | |||
32 | /** |
||
33 | * Stores the token |
||
34 | * @var string |
||
35 | */ |
||
36 | private $botToken; |
||
37 | |||
38 | /** |
||
39 | * Contains an instance to a PSR-3 compatible logger |
||
40 | * @var LoggerInterface |
||
41 | */ |
||
42 | protected $logger; |
||
43 | |||
44 | /** |
||
45 | * Stores the API URL from Telegram |
||
46 | * @var string |
||
47 | */ |
||
48 | private $apiUrl = ''; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $methodName = ''; |
||
54 | |||
55 | /** |
||
56 | * TelegramLog constructor. |
||
57 | * |
||
58 | * @param string $botToken |
||
59 | * @param RequestHandlerInterface $handler |
||
60 | * @param LoggerInterface $logger |
||
61 | */ |
||
62 | 40 | public function __construct(string $botToken, RequestHandlerInterface $handler, LoggerInterface $logger = null) |
|
76 | |||
77 | /** |
||
78 | * @param TelegramMethods $method |
||
79 | * |
||
80 | * @return PromiseInterface |
||
81 | */ |
||
82 | 31 | public function performApiRequest(TelegramMethods $method) |
|
92 | |||
93 | /** |
||
94 | * @param File $file |
||
95 | * |
||
96 | * @return PromiseInterface |
||
97 | */ |
||
98 | public function downloadFile(File $file): PromiseInterface |
||
117 | |||
118 | /** |
||
119 | * @param TelegramMethods $method |
||
120 | * @param array $formData |
||
121 | * |
||
122 | * @return PromiseInterface |
||
123 | */ |
||
124 | protected function sendRequestToTelegram(TelegramMethods $method, array $formData): PromiseInterface |
||
129 | |||
130 | /** |
||
131 | * Resets everything to the default values |
||
132 | * |
||
133 | * @return TgLog |
||
134 | */ |
||
135 | 31 | private function resetObjectValues(): TgLog |
|
140 | |||
141 | /** |
||
142 | * Builds up the URL with which we can work with |
||
143 | * |
||
144 | * All methods in the Bot API are case-insensitive. |
||
145 | * All queries must be made using UTF-8. |
||
146 | * |
||
147 | * @see https://core.telegram.org/bots/api#making-requests |
||
148 | * |
||
149 | * @param TelegramMethods $call |
||
150 | * @return string |
||
151 | */ |
||
152 | 30 | protected function composeApiMethodUrl(TelegramMethods $call): string |
|
160 | } |
||
161 |