Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from allentje/update-php-doc
Browse files Browse the repository at this point in the history
Update php doc
  • Loading branch information
Cannonb4ll authored Nov 1, 2019
2 parents fee79ae + 68399bd commit 015f231
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/HueClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@

class HueClient
{
/**
* @var Client
*/
private $guzzle;

/**
* @var string
*/
private $baseUrl = 'https://api.meethue.com';

/**
* @var string
*/
protected $baseUser;

public function __construct()
Expand All @@ -18,6 +29,15 @@ public function __construct()
$this->guzzle = new Client;
}

/**
* Sends a request and returns response from Hue api
*
* @param $url
* @param string $method
* @param array $params
*
* @return mixed
*/
public function send($url, $method = 'get', $params = [])
{
$options = [
Expand All @@ -36,6 +56,11 @@ public function send($url, $method = 'get', $params = [])
return json_decode($r->getBody()->getContents());
}

/**
* @param $code
*
* @return mixed
*/
public function getAccessTokenForTheFirstTime($code)
{
$r = $this->guzzle->post($this->baseUrl . '/oauth2/token', [
Expand All @@ -56,6 +81,9 @@ public function getAccessTokenForTheFirstTime($code)
return json_decode($tokens);
}

/**
* @return mixed
*/
public function refreshAndGetAccessToken()
{
$tokens = json_decode(file_get_contents(storage_path('app/hue.json')));
Expand Down Expand Up @@ -83,6 +111,9 @@ public function refreshAndGetAccessToken()
return object_get(json_decode($tokens), 'access_token');
}

/**
* @return void
*/
public function startOAuth()
{
$parameters = http_build_query([
Expand All @@ -96,6 +127,11 @@ public function startOAuth()
exit;
}

/**
* @param $data
*
* @return void
*/
public function setTokenFile($data)
{
$data = json_decode($data);
Expand All @@ -110,21 +146,33 @@ public function setTokenFile($data)
\Storage::put('hue.json', json_encode($data));
}

/**
* @return HueLight
*/
public function lights()
{
return new HueLight;
}

/**
* @return HueGroups
*/
public function groups()
{
return new HueGroups;
}

/**
* @return HueUser
*/
public function users()
{
return new HueUser;
}

/**
* @return HueSchedule
*/
public function schedules()
{
return new HueSchedule;
Expand Down
1 change: 1 addition & 0 deletions src/PhilipsHueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class PhilipsHueServiceProvider extends ServiceProvider
{

public function boot()
{
// If we do not disable the routes, load in the roads & views.
Expand Down
1 change: 1 addition & 0 deletions src/Resources/HueLightResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class HueLightResource extends BaseHueResource
{

public function isLightOn()
{
return $this->state->on;
Expand Down

0 comments on commit 015f231

Please sign in to comment.