Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions app/Http/Controllers/Apis/Protected/Main/OAuth2TeamsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@
use utils\OrderParser;
use utils\PagingInfo;
use utils\PagingResponse;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\Response;

/**
* Class OAuth2TeamsApiController
* @package App\Http\Controllers
*/
#[OA\Tag(name: "Teams", description: "Teams Management Endpoints")]
final class OAuth2TeamsApiController extends OAuth2ProtectedController
{
use ParametrizedGetAll;
use RequestProcessor;
use GetAndValidateJsonPayload;

/**
* @var IChatTeamService
Expand Down Expand Up @@ -76,6 +83,30 @@ public function __construct
$this->member_repository = $member_repository;
}

#[OA\Get(
path: "/api/v1/teams/me",
operationId: "getMyTeams",
description: "Get all teams for the authenticated user",
tags: ["Teams"],
parameters: [
new OA\Parameter(
name: "expand",
in: "query",
required: false,
schema: new OA\Schema(type: "string"),
description: "Expand relationships: company, members"
),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: "User teams retrieved successfully",
content: new OA\JsonContent(ref: "#/components/schemas/TeamsList")
),
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden - User not authenticated"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
/**
* @return mixed
*/
Expand Down Expand Up @@ -125,6 +156,38 @@ public function getMyTeams(){
}
}

#[OA\Get(
path: "/api/v1/teams/me/{team_id}",
operationId: "getMyTeam",
description: "Get a specific team by ID for the authenticated user",
tags: ["Teams"],
parameters: [
new OA\Parameter(
name: "team_id",
in: "path",
required: true,
schema: new OA\Schema(type: "integer", format: "int64"),
description: "Team ID"
),
new OA\Parameter(
name: "expand",
in: "query",
required: false,
schema: new OA\Schema(type: "string"),
description: "Expand relationships: company, members"
),
],
responses: [
new OA\Response(
response: Response::HTTP_OK,
description: "Team retrieved successfully",
content: new OA\JsonContent(ref: "#/components/schemas/Team")
),
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden - User not authenticated"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Team not found"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
/**
* @param $team_id
* @return mixed
Expand Down Expand Up @@ -173,6 +236,45 @@ public function getMyTeam($team_id){
}
}

#[OA\Post(
path: "/api/v1/teams",
operationId: "addTeam",
description: "Create a new team",
tags: ["Teams"],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(
type: "object",
required: ["name", "company_id"],
properties: [
new OA\Property(
property: "name",
type: "string",
description: "Team name",
example: "Development Team"
),
new OA\Property(
property: "company_id",
type: "integer",
format: "int64",
description: "Company ID",
example: 123
),
]
)
),
responses: [
new OA\Response(
response: Response::HTTP_CREATED,
description: "Team created successfully",
content: new OA\JsonContent(ref: "#/components/schemas/Team")
),
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden - User not authenticated"),
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
/**
* @return mixed
*/
Expand Down
32 changes: 32 additions & 0 deletions app/Swagger/TeamsListSchemas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace App\Swagger\schemas;

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: "TeamsList",
type: "object",
properties: [
new OA\Property(
property: "data",
type: "array",
items: new OA\Items(ref: "#/components/schemas/Team")
),
new OA\Property(
property: "total",
type: "integer",
example: 5
),
new OA\Property(
property: "per_page",
type: "integer",
example: 20
),
new OA\Property(
property: "current_page",
type: "integer",
example: 1
),
]
)]
class TeamsListSchema {}