IT-Academy-BCN / ita-landing-backend

5 stars 1 forks source link

[BE] Feature/ita profiles collaborators #106 and #107 #111

Open brycoti opened 8 months ago

brycoti commented 8 months ago

Pull Request Description #106

Proposed Changes

This PR introduces several modifications in CollaboratorsController.php to enhance collaborator management based on different areas.

Change Details

  1. Refactored conditions in the index method to improve code readability and maintenance.
  2. Added comments indicating the need for assistance with the provided token and the use of reverse engineering.

here's an example function to test a scenario where the provided token does not have the necessary permissions:

public function getUsers() { // Define la URL de la API de GitHub $url = 'https://api.github.com/';

// Define la ruta para obtener colaboradores del repositorio
$repositoryPath = '/repos/AnUser/testingApi/collaborators';

// Construye la URL completa
$fullUrl = $url . $repositoryPath;

// Realiza la solicitud a la API de GitHub
$response = Http::withToken(env('MY_TOKEN'))->get($fullUrl);

// Verifica si la solicitud fue exitosa
if ($response->successful()) {
    // Obtiene los datos de la respuesta JSON
    $data = $response->json();

    // Procesa los datos y devuelve la información requerida
    $users = [];
    foreach ($data as $collaborator) {
        $users[] = [
            'name' => $collaborator['login'],
            'photo' => $collaborator['avatar_url'],
            'url' => $collaborator['html_url'],
        ];
    }

    return response()->json($users);
} else {

    return response()->json(['error' => 'Error al obtener colaboradores'], $response->status());
}

}

   Route::get('/get-users', [CollaboratorsController::class, 'getUsers']);     http://127.0.0.1:8000/api/get-users  

Affected Areas

  1. Wiki: Updated collaborator retrieval for the wiki.
  2. Profiles: Enhanced collaborator retrieval for both frontend and backend parts.

Testing

Tests have been added in the CollaboratorTest.php file to ensure that the changes function correctly.

Pull Request Description [#107 ]

  1. Swagger doc: Updated collaborator parameters with an enum list and 404 error.
sonarcloud[bot] commented 8 months ago

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud