getTransport() public method

Get transport
public getTransport ( ) : Phue\Transport\TransportInterface
return Phue\Transport\TransportInterface Transport
コード例 #1
0
ファイル: GetLights.php プロジェクト: sqmk/phue
 /**
  * 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;
 }
コード例 #2
0
ファイル: GetGroups.php プロジェクト: wardcraigj/gametime
 /**
  * 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;
 }
コード例 #3
0
ファイル: GetSchedules.php プロジェクト: wardcraigj/gametime
 /**
  * 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;
 }
コード例 #4
0
ファイル: IsAuthorized.php プロジェクト: bendspoons/Phue
 /**
  * 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;
 }
コード例 #5
0
ファイル: GetRules.php プロジェクト: bendspoons/Phue
 /**
  * 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;
 }
コード例 #6
0
ファイル: GetSensors.php プロジェクト: sqmk/phue
 /**
  * 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;
 }
コード例 #7
0
ファイル: GetTimezones.php プロジェクト: bendspoons/Phue
 /**
  * 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;
 }
コード例 #8
0
ファイル: GetNewLights.php プロジェクト: wardcraigj/gametime
 /**
  * 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;
 }
コード例 #9
0
ファイル: GetUsers.php プロジェクト: sqmk/phue
 /**
  * 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;
 }
コード例 #10
0
ファイル: GetLights.php プロジェクト: Mahlstrom/Phue
 /**
  * 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;
 }
コード例 #11
0
ファイル: GetGroups.php プロジェクト: Mahlstrom/Phue
 /**
  * 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;
 }
コード例 #12
0
ファイル: GetSchedules.php プロジェクト: Mahlstrom/Phue
 /**
  * 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;
 }
コード例 #13
0
ファイル: CreateScene.php プロジェクト: sqmk/phue
 /**
  * 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;
 }
コード例 #14
0
ファイル: SetBridgeConfig.php プロジェクト: Mahlstrom/Phue
 /**
  * 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);
 }
コード例 #15
0
ファイル: CreateUser.php プロジェクト: bendspoons/Phue
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return \stdClass Authentication response
  */
 public function send(Client $client)
 {
     // Get response
     $response = $client->getTransport()->sendRequest('/api', TransportInterface::METHOD_POST, $this->buildRequestData($client));
     return $response;
 }
コード例 #16
0
ファイル: DeleteGroup.php プロジェクト: bendspoons/Phue
 /**
  * Send command
  *
  * @param Client $client Phue Client
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest("/api/{$client->getUsername()}/groups/{$this->groupId}", TransportInterface::METHOD_DELETE);
 }
コード例 #17
0
ファイル: DeleteSchedule.php プロジェクト: Mahlstrom/Phue
 /**
  * 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);
 }
コード例 #18
0
ファイル: Ping.php プロジェクト: Mahlstrom/Phue
 /**
  * Send command
  *
  * @param Client $client Phue Client
  *
  * @return mixed|void
  */
 public function send(Client $client)
 {
     $client->getTransport()->sendRequest('none/config');
 }
コード例 #19
0
ファイル: StartLightScan.php プロジェクト: sqmk/phue
 /**
  * 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;
 }
コード例 #20
0
ファイル: SetLightName.php プロジェクト: sqmk/phue
 /**
  * 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));
 }
コード例 #21
0
ファイル: CreateScene.php プロジェクト: kasperhartwich/Phue
 /**
  * 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;
 }
コード例 #22
0
ファイル: DeleteUser.php プロジェクト: bendspoons/Phue
 /**
  * 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);
 }
コード例 #23
0
ファイル: CreateGroup.php プロジェクト: wardcraigj/gametime
 /**
  * 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];
 }
コード例 #24
0
ファイル: GetScheduleById.php プロジェクト: Mahlstrom/Phue
 /**
  * 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);
 }
コード例 #25
0
ファイル: GetBridge.php プロジェクト: bendspoons/Phue
 /**
  * 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);
 }
コード例 #26
0
ファイル: GetLightById.php プロジェクト: wardcraigj/gametime
 /**
  * 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);
 }
コード例 #27
0
ファイル: UpdateSensorState.php プロジェクト: sqmk/phue
 /**
  * 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);
 }
コード例 #28
0
ファイル: SetGroupAttributes.php プロジェクト: Mahlstrom/Phue
 /**
  * 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);
 }
コード例 #29
0
ファイル: SetSceneLightState.php プロジェクト: sqmk/phue
 /**
  * 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);
 }
コード例 #30
0
ファイル: CreateRule.php プロジェクト: sqmk/phue
 /**
  * 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;
 }