Skip to content

Commit

Permalink
Merge pull request #12 from krainiuk-michael/add-summary-field
Browse files Browse the repository at this point in the history
Add a summary field from LinkedIn API.
  • Loading branch information
stevenmaguire committed May 4, 2018
2 parents 10cdba6 + 9f44da2 commit 6f86114
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Provider/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LinkedIn extends AbstractProvider
protected $fields = [
'id', 'email-address', 'first-name', 'last-name', 'headline',
'location', 'industry', 'picture-url', 'public-profile-url',
'summary',
];

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Provider/LinkedInResourceOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ public function getUrl()
return $this->getAttribute('publicProfileUrl');
}

/**
* Get user summary
*
* @return string|null
*/
public function getSummary()
{
return $this->getAttribute('summary');
}

/**
* Return all of the owner details available as an array.
*
Expand Down
10 changes: 8 additions & 2 deletions test/src/Provider/LinkedInTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ public function testUserData()
$location = uniqid();
$url = uniqid();
$description = uniqid();
$summary = uniqid();
$somethingExtra = ['more' => uniqid()];

$postResponse = m::mock('Psr\Http\Message\ResponseInterface');
$postResponse->shouldReceive('getBody')->andReturn('{"access_token": "mock_access_token", "expires_in": 3600}');
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);

$userResponse = m::mock('Psr\Http\Message\ResponseInterface');
$userResponse->shouldReceive('getBody')->andReturn('{"id": '.$userId.', "firstName": "'.$firstName.'", "lastName": "'.$lastName.'", "emailAddress": "'.$email.'", "location": { "name": "'.$location.'" }, "headline": "'.$description.'", "pictureUrl": "'.$picture.'", "publicProfileUrl": "'.$url.'", "somethingExtra": '.json_encode($somethingExtra).'}');
$userResponse->shouldReceive('getBody')->andReturn('{"id": '.$userId.', "firstName": "'.$firstName.'", "lastName": "'.$lastName.'", "emailAddress": "'.$email.'", "location": { "name": "'.$location.'" }, "headline": "'.$description.'", "summary": "'.$summary.'", "pictureUrl": "'.$picture.'", "publicProfileUrl": "'.$url.'", "somethingExtra": '.json_encode($somethingExtra).'}');
$userResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);

$client = m::mock('GuzzleHttp\ClientInterface');
Expand Down Expand Up @@ -160,6 +161,8 @@ public function testUserData()
$this->assertEquals($url, $user->toArray()['publicProfileUrl']);
$this->assertEquals($description, $user->getDescription());
$this->assertEquals($description, $user->toArray()['headline']);
$this->assertEquals($summary, $user->getSummary());
$this->assertEquals($summary, $user->toArray()['summary']);
$this->assertEquals($somethingExtra, $user->getAttribute('somethingExtra'));
$this->assertEquals($somethingExtra, $user->toArray()['somethingExtra']);
$this->assertEquals($somethingExtra['more'], $user->getAttribute('somethingExtra.more'));
Expand All @@ -174,13 +177,14 @@ public function testMissingUserData()
$location = uniqid();
$url = uniqid();
$description = uniqid();
$summary = uniqid();

$postResponse = m::mock('Psr\Http\Message\ResponseInterface');
$postResponse->shouldReceive('getBody')->andReturn('{"access_token": "mock_access_token", "expires_in": 3600}');
$postResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);

$userResponse = m::mock('Psr\Http\Message\ResponseInterface');
$userResponse->shouldReceive('getBody')->andReturn('{"id": '.$userId.', "firstName": "'.$firstName.'", "lastName": "'.$lastName.'", "emailAddress": "'.$email.'", "location": { "name": "'.$location.'" }, "headline": "'.$description.'", "publicProfileUrl": "'.$url.'"}');
$userResponse->shouldReceive('getBody')->andReturn('{"id": '.$userId.', "firstName": "'.$firstName.'", "lastName": "'.$lastName.'", "emailAddress": "'.$email.'", "location": { "name": "'.$location.'" }, "headline": "'.$description.'", "summary": "'.$summary.'", "publicProfileUrl": "'.$url.'"}');
$userResponse->shouldReceive('getHeader')->andReturn(['content-type' => 'json']);

$client = m::mock('GuzzleHttp\ClientInterface');
Expand All @@ -207,6 +211,8 @@ public function testMissingUserData()
$this->assertEquals($url, $user->toArray()['publicProfileUrl']);
$this->assertEquals($description, $user->getDescription());
$this->assertEquals($description, $user->toArray()['headline']);
$this->assertEquals($summary, $user->getSummary());
$this->assertEquals($summary, $user->toArray()['summary']);
}

/**
Expand Down

0 comments on commit 6f86114

Please sign in to comment.