Skip to content

Commit

Permalink
Fix setData
Browse files Browse the repository at this point in the history
  • Loading branch information
sabinus52 committed Jun 27, 2020
1 parent 93dd0fb commit 2887e97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Device/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct($id, $name = '', $icon = '')
*
* @param Array $data
*/
public function setData(array $data)
public function setData($data)
{
$this->data = $data;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ private function _refreshToken()
* @param String $message : Message par défaut
* @throws Exception
*/
public function checkResponse(array $response, $message = null)
public function checkResponse($response, $message = null)
{
if ( empty($response) ) {
throw new \Exception($message.' : Datas return null');
}
if ( isset($response['responseStatus']) && $response['responseStatus'] === 'error' ) {
$message = isset($response['errorMsg']) ? $response['errorMsg'] : $message;
throw new \Exception($message);
Expand Down
2 changes: 1 addition & 1 deletion src/TuyaCloudApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function _request($name, $namespace, array $payload = [])
),
));
$response = json_decode((string) $response->getBody(), true);
$this->session->checkResponse($response, sprintf('Failed to get response from %s', $name));
$this->session->checkResponse($response, sprintf('Failed to get "%s" response from Cloud Tuya', $name));

return $response;
}
Expand Down

0 comments on commit 2887e97

Please sign in to comment.