Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| LinkTelegramEndpoint | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| handle | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Api\Endpoints; |
| 4 | |
| 5 | use Olz\Api\OlzTypedEndpoint; |
| 6 | use PhpTypeScriptApi\HttpError; |
| 7 | |
| 8 | /** |
| 9 | * @extends OlzTypedEndpoint< |
| 10 | * ?array{}, |
| 11 | * array{ |
| 12 | * botName: non-empty-string, |
| 13 | * pin: non-empty-string, |
| 14 | * } |
| 15 | * > |
| 16 | */ |
| 17 | class LinkTelegramEndpoint extends OlzTypedEndpoint { |
| 18 | protected function handle(mixed $input): mixed { |
| 19 | $user = $this->authUtils()->getCurrentUser(); |
| 20 | if (!$user) { |
| 21 | throw new HttpError(403, "Kein Zugriff!"); |
| 22 | } |
| 23 | |
| 24 | $bot_name = $this->telegramUtils()->getBotName(); |
| 25 | $pin = $this->telegramUtils()->getFreshPinForUser($user); |
| 26 | |
| 27 | return [ |
| 28 | 'botName' => $bot_name ?: '-', |
| 29 | 'pin' => $pin ?: '-', |
| 30 | ]; |
| 31 | } |
| 32 | } |