source->api_key) { $client = $client->withQueryParameters(['api_key' => $this->source->api_key]); } return $client; } /** * Fetch jobs from The Muse API * * @param array $params [ * 'page' => int, // Page number (default 0) * 'descending' => bool, // Sort order (default true) * 'category' => string, // Job category * 'level' => string, // e.g., 'Entry Level', 'Mid Level', 'Senior Level' * 'location' => string, // Location filter * 'company' => string, // Company name or ID * ] * @return array */ public function fetchJobs(array $params = []): array { try { $queryParams = $this->buildQueryParams($params); $response = $this->makeRequest('GET', 'jobs', $queryParams); $data = $response->json(); if (!isset($data['results']) || !is_array($data['results'])) { throw new ApiException( 'Invalid response structure from The Muse API', $this->source->name, ['response' => $data] ); } $this->updateLastFetched(); return $this->transformer->transformMany($data['results']); } catch (ApiException $e) { throw $e; } catch (\Throwable $e) { throw new ApiException( 'Failed to fetch jobs from The Muse', $this->source->name, ['error' => $e->getMessage()], 0, $e ); } } /** * Build query parameters for the API request */ private function buildQueryParams(array $params): array { $queryParams = [ 'page' => $params['page'] ?? 0, 'descending' => $params['descending'] ?? true, ]; if (!empty($params['category'])) { $queryParams['category'] = $params['category']; } if (!empty($params['level'])) { $queryParams['level'] = $params['level']; } if (!empty($params['location'])) { $queryParams['location'] = $params['location']; } if (!empty($params['company'])) { $queryParams['company'] = $params['company']; } return $queryParams; } /** * Get available job categories from The Muse */ public function getCategories(): array { return [ 'Account Management', 'Business & Strategy', 'Creative & Design', 'Customer Service', 'Data Science', 'Editorial', 'Education', 'Engineering', 'Finance', 'Healthcare & Medicine', 'HR & Recruiting', 'Legal', 'Marketing & PR', 'Operations', 'Project & Product Management', 'Retail', 'Sales', 'Social Media & Community', ]; } /** * Get available experience levels */ public function getLevels(): array { return [ 'Internship', 'Entry Level', 'Mid Level', 'Senior Level', 'Executive', ]; } }