79 lines
1.5 KiB
PHP
79 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Mrjoops\OAuth2\Client\Provider;
|
||
|
|
||
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
|
||
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
|
||
|
|
||
|
class JiraResourceOwner implements ResourceOwnerInterface
|
||
|
{
|
||
|
use ArrayAccessorTrait;
|
||
|
|
||
|
/**
|
||
|
* Raw response
|
||
|
*
|
||
|
* @var array
|
||
|
*/
|
||
|
protected $response;
|
||
|
|
||
|
/**
|
||
|
* Creates new resource owner.
|
||
|
*
|
||
|
* @param array $response
|
||
|
*/
|
||
|
public function __construct(array $response = [])
|
||
|
{
|
||
|
$this->response = $response;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get resource owner email
|
||
|
*
|
||
|
* @return string|null
|
||
|
*/
|
||
|
public function getEmail()
|
||
|
{
|
||
|
return $this->getValueByKey($this->response, 'emailAddress');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get resource owner id
|
||
|
*
|
||
|
* @return string|null
|
||
|
*/
|
||
|
public function getId()
|
||
|
{
|
||
|
return $this->getValueByKey($this->response, 'accountId');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get resource owner name
|
||
|
*
|
||
|
* @return string|null
|
||
|
*/
|
||
|
public function getName()
|
||
|
{
|
||
|
return $this->getValueByKey($this->response, 'displayName');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get resource owner nickname
|
||
|
*
|
||
|
* @return string|null
|
||
|
*/
|
||
|
public function getNickname()
|
||
|
{
|
||
|
return $this->getValueByKey($this->response, 'name');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return all of the owner details available as an array.
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function toArray()
|
||
|
{
|
||
|
return $this->response;
|
||
|
}
|
||
|
}
|