getUsername() public method

Get username
public getUsername ( ) : string
return string Username
Esempio n. 1
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return bool True if authorized, false if not
  */
 public function send(Client $client)
 {
     // Get response
     try {
         $client->getTransport()->sendRequest("/api/{$client->getUsername()}");
     } catch (UnauthorizedUserException $e) {
         return false;
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return Sensor[] List of Sensor objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors");
     $sensors = array();
     foreach ($results as $sensorId => $attributes) {
         $sensors[$sensorId] = new Sensor($sensorId, $attributes, $client);
     }
     return $sensors;
 }
Esempio n. 3
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Schedule[] List of Schedule objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/schedules");
     $schedules = [];
     foreach ($response as $scheduleId => $attributes) {
         $schedules[$scheduleId] = new Schedule($scheduleId, $attributes, $client);
     }
     return $schedules;
 }
Esempio n. 4
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return Light[] List of Light objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights");
     $lights = array();
     foreach ($response as $lightId => $attributes) {
         $lights[$lightId] = new Light($lightId, $attributes, $client);
     }
     return $lights;
 }
Esempio n. 5
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Rule[] List of Rule objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/rules");
     $rules = [];
     foreach ($results as $ruleId => $attributes) {
         $rules[$ruleId] = new Rule($ruleId, $attributes, $client);
     }
     return $rules;
 }
Esempio n. 6
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Group[] List of Group objects
  */
 public function send(Client $client)
 {
     // Get response
     $results = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups");
     $groups = [];
     foreach ($results as $groupId => $attributes) {
         $groups[$groupId] = new Group($groupId, $attributes, $client);
     }
     return $groups;
 }
Esempio n. 7
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return array List of timezones
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequestBypassBodyValidation("/api/{$client->getUsername()}/info/timezones");
     $timezones = [];
     foreach ($response as $timezone) {
         $timezones[] = $timezone;
     }
     return $timezones;
 }
Esempio n. 8
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return self This object
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/new");
     $this->lastScan = $response->lastscan;
     // Remove scan from response
     unset($response->lastscan);
     // Iterate through left over properties as lights
     foreach ($response as $lightId => $light) {
         $this->lights[$lightId] = $light->name;
     }
     return $this;
 }
Esempio n. 9
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return User[] List of User objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config");
     // Return empty list if no users
     if (!isset($response->whitelist)) {
         return array();
     }
     $users = array();
     foreach ($response->whitelist as $username => $attributes) {
         $users[$username] = new User($username, $attributes, $client);
     }
     return $users;
 }
Esempio n. 10
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Light[] List of Light objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no lights
     if (!isset($response->lights)) {
         return [];
     }
     $lights = [];
     foreach ($response->lights as $lightId => $attributes) {
         $lights[$lightId] = new Light($lightId, $attributes, $client);
     }
     return $lights;
 }
Esempio n. 11
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Group[] List of Group objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no groups
     if (!isset($response->groups)) {
         return [];
     }
     $groups = [];
     foreach ($response->groups as $groupId => $attributes) {
         $groups[$groupId] = new Group($groupId, $attributes, $client);
     }
     return $groups;
 }
Esempio n. 12
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Schedule[] List of Schedule objects
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest($client->getUsername());
     // Return empty list if no schedules
     if (!isset($response->schedules)) {
         return [];
     }
     $schedules = [];
     foreach ($response->schedules as $scheduleId => $attributes) {
         $schedules[$scheduleId] = new Schedule($scheduleId, $attributes, $client);
     }
     return $schedules;
 }
Esempio n. 13
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return int Sensor Id
  */
 public function send(Client $client)
 {
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors", TransportInterface::METHOD_POST, (object) array_merge($this->attributes, ['state' => $this->state, 'config' => $this->config]));
     return $response->id;
 }
Esempio n. 14
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return mixed|void
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("{$client->getUsername()}/schedules/{$this->scheduleId}", TransportInterface::METHOD_DELETE);
 }
Esempio n. 15
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return mixed|void
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("{$client->getUsername()}/config", TransportInterface::METHOD_PUT, (object) $this->config);
 }
Esempio n. 16
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return mixed
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights", TransportInterface::METHOD_POST);
     return $response;
 }
Esempio n. 17
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups/{$this->groupId}", TransportInterface::METHOD_DELETE);
 }
Esempio n. 18
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Bridge Bridge object
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config");
     return new Bridge($response, $client);
 }
Esempio n. 19
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return mixed|void
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("{$client->getUsername()}/groups/{$this->groupId}", TransportInterface::METHOD_PUT, (object) $this->attributes);
 }
Esempio n. 20
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/{$this->lightId}", TransportInterface::METHOD_PUT, (object) array('name' => $this->name));
 }
Esempio n. 21
0
 /**
  * Get schedulable params
  *
  * @param Client $client Phue Client
  *
  * @return array Key/value pairs of params
  */
 public function getSchedulableParams(Client $client)
 {
     return ['address' => "{$client->getUsername()}/groups/{$this->groupId}/action", 'method' => TransportInterface::METHOD_PUT, 'body' => (object) $this->params];
 }
Esempio n. 22
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/config/whitelist/{$this->username}", TransportInterface::METHOD_DELETE);
 }
Esempio n. 23
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return int Group Id
  */
 public function send(Client $client)
 {
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups", TransportInterface::METHOD_POST, (object) ['name' => $this->name, 'lights' => $this->lights]);
     return explode('/', $response->id)[2];
 }
Esempio n. 24
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return string Scene Id
  */
 public function send(Client $client)
 {
     $body = (object) array('name' => $this->name, 'lights' => $this->lights);
     if ($this->transitionTime !== null) {
         $body->transitiontime = $this->transitionTime;
     }
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->id}", TransportInterface::METHOD_PUT, $body);
     return $this->id;
 }
Esempio n. 25
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Schedule Schedule object
  */
 public function send(Client $client)
 {
     // Get response
     $attributes = $client->getTransport()->sendRequest("{$client->getUsername()}/schedules/{$this->scheduleId}");
     return new Schedule($this->scheduleId, $attributes, $client);
 }
Esempio n. 26
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return Light Light object
  */
 public function send(Client $client)
 {
     // Get response
     $attributes = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/{$this->lightId}");
     return new Light($this->lightId, $attributes, $client);
 }
Esempio n. 27
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/sensors/{$this->sensorId}/state", TransportInterface::METHOD_PUT, (object) $this->state);
 }
Esempio n. 28
0
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return string Scene Id
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->id}", TransportInterface::METHOD_PUT, (object) ['name' => $this->name, 'lights' => $this->lights]);
     return $this->id;
 }
Esempio n. 29
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/scenes/{$this->sceneId}/lights/{$this->lightId}/state", TransportInterface::METHOD_PUT, (object) $this->params);
 }
Esempio n. 30
0
 /**
  * Send command
  *
  * @param Client $client
  *            Phue Client
  *
  * @return int Rule Id
  */
 public function send(Client $client)
 {
     $response = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/rules", TransportInterface::METHOD_POST, (object) array('name' => $this->name, 'conditions' => array_map(function ($condition) {
         return $condition->export();
     }, $this->conditions), 'actions' => array_map(function ($action) use($client) {
         return $action->getActionableParams($client);
     }, $this->actions)));
     return $response->id;
 }