updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\GitlabApp;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Lcobucci\JWT\Encoding\ChainedFormatter;
|
||||
use Lcobucci\JWT\Encoding\JoseEncoder;
|
||||
@@ -45,3 +46,20 @@ function generate_github_jwt_token(GithubApp $source)
|
||||
->toString();
|
||||
return $issuedToken;
|
||||
}
|
||||
|
||||
function get_from_git_api(GithubApp|GitlabApp $source, $endpoint)
|
||||
{
|
||||
if ($source->getMorphClass() == 'App\Models\GithubApp') {
|
||||
if ($source->is_public) {
|
||||
$response = Http::github($source->api_url)->get($endpoint);
|
||||
}
|
||||
}
|
||||
$json = $response->json();
|
||||
if ($response->status() !== 200) {
|
||||
throw new \Exception("Failed to get data from {$source->name} with error: " . $json['message']);
|
||||
}
|
||||
return [
|
||||
'rate_limit_remaining' => $response->header('X-RateLimit-Remaining'),
|
||||
'data' => collect($json)
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user