Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

theihasan/geezap

97 stars
2 code files
View theihasan/geezap on GitHub

app/Exceptions/ApiKeyNotFoundException.php

Open in GitHub
use App\Models\ApiKey;
use Exception;
 
class ApiKeyNotFoundException extends Exception
{
public function __construct()
{
parent::__construct('No available API key found with remaining requests');
}
 
/**
* @throws ApiKeyNotFoundException
*/
public static function validateApiKey(ApiKey|null $apiKey): void
{
if (!$apiKey || $apiKey->request_remaining <= 0) {
throw new self();
}
}
}

app/Jobs/GetJobData.php

Open in GitHub
use App\DTO\JobResponseDTO;
use App\Enums\ApiName;
use App\Exceptions\ApiKeyNotFoundException;
use App\Exceptions\CategoryNotFoundException;
use App\Models\ApiKey;
use Illuminate\Support\Facades\Log;
 
class GetJobData implements ShouldQueue
{
// ...
 
public function handle(): void
{
try {
$apiKey = ApiKey::query()
->where('api_name', ApiName::JOB)
->orderByDesc('request_remaining')
->first();
 
ApiKeyNotFoundException::validateApiKey($apiKey);
 
$categories = JobCategory::all();
 
CategoryNotFoundException::throwIfNotFound($categories);
 
foreach ($categories as $category) {
$this->fetchAndStoreJobs($apiKey, $category);
}
 
} catch (ApiKeyNotFoundException|CategoryNotFoundException|\Exception $e) {
Log::error('Error on job fetching', [
'message' => $e->getMessage(),
'line' => $e->getLine(),
'file' => $e->getFile(),
]);
}
}
 
// ...
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.