diff --git a/app/Annotations/OpenApi/controllersAnnotations/collaboratorsAnnotations/AnnotationsCollaborators.php b/app/Annotations/OpenApi/controllersAnnotations/collaboratorsAnnotations/AnnotationsCollaborators.php index 5728c2e..b7adc45 100644 --- a/app/Annotations/OpenApi/controllersAnnotations/collaboratorsAnnotations/AnnotationsCollaborators.php +++ b/app/Annotations/OpenApi/controllersAnnotations/collaboratorsAnnotations/AnnotationsCollaborators.php @@ -9,20 +9,26 @@ class AnnotationsCollaborators * path="/collaborators/{area}", * tags={"Collaborators"}, * summary="User Collaborators", - * description="This endpoint is used to get persons that work on the specific project", + * description="This endpoint is used to get persons that work on the specific project, + * URL parameters: area (landing, wiki, challenges, profiles).", * * @OA\Parameter( * name="area", * in="path", * required=true, - * description="name of the area", + * description="name of the area.", * * @OA\Schema( * type="string", + * enum={"landing", "wiki", "challenges", "profiles"}, * example="landing" - * ) + * ), * ), * + * @OA\Response( + * response="404", + * description="Invalid area" + * ), * @OA\Response( * response="200", * description="Collaborators details.", diff --git a/app/Http/Controllers/api/CollaboratorsController.php b/app/Http/Controllers/api/CollaboratorsController.php index 6deb307..3d82ae0 100644 --- a/app/Http/Controllers/api/CollaboratorsController.php +++ b/app/Http/Controllers/api/CollaboratorsController.php @@ -15,6 +15,8 @@ public function index($area) return $this->collaboratorItaWiki(); } elseif ($area === 'challenges') { return $this->collaboratorItaChallenges(); + } elseif ($area === 'profiles') { + return $this->collaboratorItaProfiles(); } return response()->json([ @@ -24,7 +26,6 @@ public function index($area) public function collaboratorLogic($collaborator) { - $url = env('URL_SERVER_API', 'https://api.github.com'); $response = Http::withToken(env('MY_TOKEN'))->get($url.$collaborator); @@ -40,7 +41,6 @@ public function collaboratorLogic($collaborator) } return $allCollaborators; - } public function uniqueCollaborators(...$arrays) @@ -60,7 +60,6 @@ public function uniqueCollaborators(...$arrays) public function collaboratorLanding() { - $collaboratorPhp = '/ita-landing-backend/collaborators?affiliation=direct'; $collaboratorReact = '/ita-landing-frontend/collaborators?affiliation=direct'; @@ -78,7 +77,11 @@ public function collaboratorItaWiki() $collaboratorWiki = '/ita-wiki/collaborators?affiliation=direct'; - return $this->collaboratorLogic($collaboratorWiki); + $wiki = $this->collaboratorLogic($collaboratorWiki); + + $uniqueCollaborators = $this->uniqueCollaborators($wiki); + + return $uniqueCollaborators; } @@ -95,4 +98,17 @@ public function collaboratorItaChallenges() return $uniqueCollaborators; } + + public function collaboratorItaProfiles() + { + $collaboratorReactProfiles = '/ita-profiles-frontend/collaborators?affiliation=direct'; + $collaboratorPhpProfiles = '/ita-profiles-backend/collaborators?affiliation=direct'; + + $reactProfiles = $this->collaboratorLogic($collaboratorReactProfiles); + $phpProfiles = $this->collaboratorLogic($collaboratorPhpProfiles); + + $uniqueCollaborators = $this->uniqueCollaborators($reactProfiles, $phpProfiles); + + return $uniqueCollaborators; + } } diff --git a/storage/api-docs/api-docs.json b/storage/api-docs/api-docs.json index 0af52d3..9c01aef 100644 --- a/storage/api-docs/api-docs.json +++ b/storage/api-docs/api-docs.json @@ -348,21 +348,30 @@ "Collaborators" ], "summary": "User Collaborators", - "description": "This endpoint is used to get persons that work on the specific project", + "description": "This endpoint is used to get persons that work on the specific project,\n * URL parameters: area (landing, wiki, challenges, profiles).", "operationId": "9ed89cb2a49abd38189ba3c947d6c40f", "parameters": [ { "name": "area", "in": "path", - "description": "name of the area", + "description": "name of the area.", "required": true, "schema": { "type": "string", + "enum": [ + "landing", + "wiki", + "challenges", + "profiles" + ], "example": "landing" } } ], "responses": { + "404": { + "description": "Invalid area" + }, "200": { "description": "Collaborators details.", "content": { @@ -814,6 +823,12 @@ ], "example": "ADMIN" }, + "last_login_at": { + "description": "Last user log in timestamp", + "type": "string", + "format": "date-time", + "example": "2023-06-19T12:00:00+00:00" + }, "email_verified_at": { "description": "Email verification timestamp", "type": "string", diff --git a/tests/Feature/CollaboratorTest.php b/tests/Feature/CollaboratorTest.php index fc822b4..5915a5f 100644 --- a/tests/Feature/CollaboratorTest.php +++ b/tests/Feature/CollaboratorTest.php @@ -28,6 +28,12 @@ public function test_index_get_collaborators_challenges(): void $response->assertStatus(200); } + public function test_index_get_collaborators_profiles(): void + { + $response = $this->get('/api/collaborators/profiles'); + $response->assertStatus(200); + } + public function test_inserting_on_index_a_area_that_dont_exist(): void { $response = $this->get('/api/collaborators/prueba'); @@ -67,4 +73,12 @@ public function test_collaborator_challenges_function() $response = $collaboratorsController->collaboratorItaChallenges(); $this->assertIsArray($response); } + + public function test_collaborator_ita_profiles_function() + { + + $collaboratorsController = new CollaboratorsController(); + $response = $collaboratorsController->collaboratorItaProfiles(); + $this->assertIsArray($response); + } }