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