diff --git a/src/HueClient.php b/src/HueClient.php index dd2ad44..29d37d0 100644 --- a/src/HueClient.php +++ b/src/HueClient.php @@ -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() @@ -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 = [ @@ -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', [ @@ -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'))); @@ -83,6 +111,9 @@ public function refreshAndGetAccessToken() return object_get(json_decode($tokens), 'access_token'); } + /** + * @return void + */ public function startOAuth() { $parameters = http_build_query([ @@ -96,6 +127,11 @@ public function startOAuth() exit; } + /** + * @param $data + * + * @return void + */ public function setTokenFile($data) { $data = json_decode($data); @@ -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; diff --git a/src/PhilipsHueServiceProvider.php b/src/PhilipsHueServiceProvider.php index c3448ee..b95a6d8 100644 --- a/src/PhilipsHueServiceProvider.php +++ b/src/PhilipsHueServiceProvider.php @@ -6,6 +6,7 @@ class PhilipsHueServiceProvider extends ServiceProvider { + public function boot() { // If we do not disable the routes, load in the roads & views. diff --git a/src/Resources/HueLightResource.php b/src/Resources/HueLightResource.php index bf67cd5..0cc3880 100644 --- a/src/Resources/HueLightResource.php +++ b/src/Resources/HueLightResource.php @@ -4,6 +4,7 @@ class HueLightResource extends BaseHueResource { + public function isLightOn() { return $this->state->on;