Skip to content

Commit

Permalink
Adding location setters
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Jul 25, 2015
1 parent e16b009 commit 8e59a65
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All Notable changes to `jobs-indeed` will be documented in this file
### Added
- Name field to jobs
- Using setCompany method to include hiringOrganization Object
- Date as string
- Adding setCity and setState method support

### Deprecated
- Nothing
Expand Down
22 changes: 21 additions & 1 deletion src/Indeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ public function createJobObject($payload)
'location' => $payload['formattedLocation'],
]);

$job->setCompany($payload['company']);
$location = $this->parseLocation($payload['formattedLocation']);

$job->setCompany($payload['company'])
->setDatePostedAsString($payload['date']);

if (isset($location[0])) {
$job->setCity($location[0]);
}
if (isset($location[1])) {
$job->setState($location[1]);
}

return $job;
}
Expand Down Expand Up @@ -174,4 +184,14 @@ public function getVerb()
{
return 'GET';
}

/**
* Parse city and state from string given by API
*
* @return array
*/
public function parseLocation($location)
{
return explode(', ', $location);
}
}
5 changes: 3 additions & 2 deletions tests/src/IndeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private function getResultItems($count = 1)
'company' => uniqid(),
'formattedLocation' => uniqid(),
'source' => uniqid(),
'date' => uniqid(),
'date' => '2015-07-'.rand(1,31),
'snippet' => uniqid(),
'url' => uniqid(),
'jobkey' => uniqid(),
Expand Down Expand Up @@ -268,8 +268,9 @@ private function createJobArray() {
return [
'jobtitle' => uniqid(),
'company' => uniqid(),
'formattedLocation' => uniqid(),
'formattedLocation' => uniqid().', '.uniqid(),
'snippet' => uniqid(),
'date' => '2015-07-'.rand(1,31),
'url' => uniqid(),
'jobkey' => uniqid(),
];
Expand Down

0 comments on commit 8e59a65

Please sign in to comment.