/** * Authenticates $this.credentials */ public function authenticate() { $this->call("Authenticate", ["database" => $this->credentials->getDatabase(), "userName" => $this->credentials->getUsername(), "password" => $this->credentials->getPassword()], function ($result) { $credentials = $result["credentials"]; $this->credentials->setUsername($credentials["userName"]); $this->credentials->setDatabase($credentials["database"]); $this->credentials->setSessionId($credentials["sessionId"]); if ($result["path"] !== "ThisServer") { $this->credentials->setServer($result["path"]); } return $this->credentials; }, function ($error) { if ($error["name"] == "InvalidUserException") { throw new MyGeotabException("Cannot authenticate " . $this->credentials->getUsername() . " on " . $this->credentials->getServer() . "/" . $this->credentials->getDatabase()); } }); }