-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ursuleacv/1.0-dev
Adding resource owner
- Loading branch information
Showing
3 changed files
with
115 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace League\OAuth2\Client\Provider; | ||
|
||
use League\OAuth2\Client\Provider\ResourceOwnerInterface; | ||
|
||
class LightspeedResourceOwner implements ResourceOwnerInterface | ||
{ | ||
/** | ||
* Raw response | ||
* | ||
* @var array | ||
*/ | ||
protected $response; | ||
|
||
/** | ||
* Creates new resource owner. | ||
* | ||
* @param array $response | ||
*/ | ||
public function __construct(array $response = array()) | ||
{ | ||
$this->response = $response; | ||
} | ||
|
||
/** | ||
* Get Account ID | ||
* | ||
* @return string|null | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->getResponseData('Account.accountID'); | ||
} | ||
|
||
/** | ||
* Attempts to pull value from array using dot notation. | ||
* | ||
* @param string $path | ||
* @param string $default | ||
* | ||
* @return mixed | ||
*/ | ||
protected function getResponseData($path, $default = null) | ||
{ | ||
$array = $this->response; | ||
if (!empty($path)) { | ||
$keys = explode('.', $path); | ||
foreach ($keys as $key) { | ||
if (isset($array[$key])) { | ||
$array = $array[$key]; | ||
} else { | ||
return $default; | ||
} | ||
} | ||
} | ||
return $array; | ||
} | ||
|
||
/** | ||
* Return all of the owner details available as an array. | ||
* | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
return $this->response; | ||
} | ||
} |