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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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
 /**
  * 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;
 }