public function testDecodeToHashSingleJob() { $item = JsonHelper::decodeToHash($this->json); $this->assertEquals($item['id'], 167538); $this->assertEquals($item['departments'][0]['id'], 7219); }
/** * Given a job id, make a requrest to the Greenhouse API for those questions and build an associative * array indexed on the human-readable name containing an array of the indices that must be set. The * array is due to the fact that one required question can have one of two things required. For example, * if first name, last name, and resume are required, your response would look like this: * * <code> * array( * 'First Name' => array('first_name'), * 'Last Name' => array('last_name'), * 'Resume' => array('resume', 'resume_text') * ); * </code> * * Where either resume or resume_text must have a value. * * @params number $jobId A Greenhouse job id. * @returns Array * @throws GreenhouseAPIResponseException if getJob returns a non-200 response. */ public function getRequiredFields($jobId) { $job = $this->_jobApiService->getJob($jobId, true); $jobHash = JsonHelper::decodeToHash($job); $requiredFields = array(); foreach ($jobHash['questions'] as $question) { if ($question['required']) { $questionFields = array(); foreach ($question['fields'] as $field) { $questionFields[] = $field['name']; } $requiredFields[$question['label']] = $questionFields; } } return $requiredFields; }