1 | <?php |
||
11 | class TelegramResponse |
||
12 | { |
||
13 | /** |
||
14 | * Used in the TelegramDocument class, saves some processing |
||
15 | * @var string |
||
16 | */ |
||
17 | private $rawData = ''; |
||
18 | |||
19 | /** |
||
20 | * The actual representation of the decoded data |
||
21 | * @var array |
||
22 | */ |
||
23 | private $decodedData = []; |
||
24 | |||
25 | /** |
||
26 | * The headers sent with the response. |
||
27 | * @var array |
||
28 | */ |
||
29 | private $headers; |
||
30 | |||
31 | 42 | public function __construct(string $rawData, array $headers = []) |
|
36 | |||
37 | /** |
||
38 | * Fills in the raw data |
||
39 | * |
||
40 | * @param string $rawData |
||
41 | * @return TelegramResponse |
||
42 | * @throws \unreal4u\TelegramAPI\Exceptions\ClientException |
||
43 | */ |
||
44 | 42 | public function fillRawData(string $rawData): TelegramResponse |
|
57 | |||
58 | /** |
||
59 | * To quickly find out what type of request we are dealing with |
||
60 | * |
||
61 | * Unused so far |
||
62 | * |
||
63 | * @return string |
||
64 | * @throws InvalidResultType |
||
65 | */ |
||
66 | 8 | public function getTypeOfResult(): string |
|
79 | |||
80 | /** |
||
81 | * Most of the requests Telegram sends, come as an array, so send the response back as an array by default |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 22 | public function getResult(): array |
|
89 | |||
90 | /** |
||
91 | * Hack: for some requests Telegram sends back an array, integer, string or a boolean value, convert it to boolean |
||
92 | * here |
||
93 | * @return bool |
||
94 | */ |
||
95 | 5 | public function getResultBoolean(): bool |
|
99 | |||
100 | /** |
||
101 | * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to int here |
||
102 | * @return int |
||
103 | */ |
||
104 | 1 | public function getResultInt(): int |
|
108 | |||
109 | /** |
||
110 | * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to string |
||
111 | * here |
||
112 | * @return string |
||
113 | */ |
||
114 | 1 | public function getResultString(): string |
|
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | 2 | public function getRawData(): string |
|
126 | |||
127 | /** |
||
128 | * @return array |
||
129 | */ |
||
130 | 2 | public function getHeaders(): array |
|
134 | } |
||
135 |