This PR introduces several modifications in CollaboratorsController.php to enhance collaborator management based on different areas.
Change Details
Refactored conditions in the index method to improve code readability and maintenance.
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());
}
Pull Request Description #106
Proposed Changes
This PR introduces several modifications in
CollaboratorsController.php
to enhance collaborator management based on different areas.Change Details
index
method to improve code readability and maintenance.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/';
}
Affected Areas
Testing
Tests have been added in the
CollaboratorTest.php
file to ensure that the changes function correctly.Pull Request Description [#107 ]