Skip to content

Commit

Permalink
Adding locations
Browse files Browse the repository at this point in the history
  • Loading branch information
karllhughes committed Jul 25, 2015
1 parent 82e525d commit c58ab8e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Changelog
All Notable changes to `jobs-jobs2careers` will be documented in this file

## 0.1.1 - 2015-07-25

### Added
- Adding name attribute
- Adding city/state to company and job listing address

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing

## 0.1.0 - 2015-07-04

### Added
Expand Down
27 changes: 23 additions & 4 deletions src/J2c.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function createJobObject($payload)
'date',
'onclick',
'company',
'city', // Array
'city',
'description',
'price',
'id',
Expand All @@ -81,16 +81,25 @@ public function createJobObject($payload)

$job = new Job([
'title' => $payload['title'],
'name' => $payload['title'],
'description' => $payload['description'],
'javascriptFunction' => $payload['onclick'],
'javascriptAction' => 'onclick',
'sourceId' => $payload['id'],
'industry' => $payload['industry0'],
]);

$job->setDatePostedAsString($payload['date']);
$job->setCompany($payload['company']);
$job->setLocation($payload['city']);
$location = $this->parseLocation($payload['city']);

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

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

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

/**
* Parse city and state from string given by API
*
* @return array
*/
public function parseLocation($location)
{
return explode(', ', $location);
}
}
1 change: 1 addition & 0 deletions tests/src/J2cTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public function testUrlNotIncludesStartWhenNotProvided()
public function testItCanCreateJobFromPayload()
{
$payload = $this->createJobArray();
$payload['city'] = uniqid().', '.uniqid();
$results = $this->client->createJobObject($payload);

$this->assertEquals($payload['title'], $results->title);
Expand Down

0 comments on commit c58ab8e

Please sign in to comment.