доп фукнции апи
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\BalanceService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
class LauncherAccountController extends Controller
|
||||
{
|
||||
#[OA\Get(
|
||||
path: '/api/launcher/account',
|
||||
summary: 'Получить информацию об аккаунте',
|
||||
description: 'Возвращает имя и текущий баланс авторизованного игрового аккаунта.',
|
||||
tags: ['Launcher'],
|
||||
security: [['bearerAuth' => []]],
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Информация об аккаунте',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'username', type: 'string', example: 'PLAYER'),
|
||||
new OA\Property(property: 'balance', type: 'string', example: '1250.00'),
|
||||
],
|
||||
),
|
||||
),
|
||||
new OA\Response(
|
||||
response: 401,
|
||||
description: 'Не авторизован',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'Unauthenticated.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)]
|
||||
public function show(Request $request, BalanceService $balances): JsonResponse
|
||||
{
|
||||
$account = $request->user();
|
||||
|
||||
return response()->json([
|
||||
'username' => (string) $account->username,
|
||||
'balance' => $balances->balance((int) $account->id),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user