token = $token; $this->vendor = $vendor; switch ($vendor) { case "vorwerk": $this->baseUrl = "https://vorwerk-beehive-production.herokuapp.com"; break; case "orbital": $this->baseUrl = "https://orbital.neatocloud.com"; break; } } public function authorize($email, $password, $force = false) { if($this->token === false || $force === true) { if ($this->vendor == "orbital") { $url = $this->baseUrl."/vendors/".$this->vendor."/sessions"; } else { $url = this->baseUrl."/sessions"; } $result = NeatoBotvacApi::request($url, array( "platform" => "ios", "email" => $email, "token" => bin2hex(openssl_random_pseudo_bytes(32)), "password" => $password ) ); if(isset($result["access_token"])) { $this->token = $result["access_token"]; } if(isset($result["user_id"])) { $this->userid = $result["user_id"]; } if(isset($result["token"])) { $this->token = $result["token"]; } } return $this->token; } public function reauthorize($email, $password) { return $this->authorize($email, $password, true); } public function getRobots($token = false) { $result = array("message" => "no token"); if($token !== false) { $this->token = $token; } if($this->token !== false) { $result = NeatoBotvacApi::request($this->baseUrl."/dashboard", null, "GET", array("Authorization: Token token=".$this->token)); } return $result; } } ?>