/** * Retrieves a new plentymarkets API token * * @throws Exception */ private function getToken() { // Load the request model // Authentication $Request_GetAuthentificationToken = new PlentySoapRequest_GetAuthentificationToken(); $Request_GetAuthentificationToken->Username = $this->username; $Request_GetAuthentificationToken->Userpass = $this->userpass; $Response_GetAuthentificationToken = $this->GetAuthentificationToken($Request_GetAuthentificationToken); if ($Response_GetAuthentificationToken->Success == true) { $this->userId = $Response_GetAuthentificationToken->UserID; $this->userToken = $Response_GetAuthentificationToken->Token; if (!$this->dryrun) { // Save the auth data $this->Config->setApiUserID($this->userId); $this->Config->setApiToken($this->userToken); $this->Config->setApiLastAuthTimestamp(time()); // Log PlentymarketsLogger::getInstance()->message('Soap:Auth', 'Received a new token'); } } else { $this->userId = -1; $this->userToken = ''; // Log invalid api data PlentymarketsLogger::getInstance()->message('Soap:Auth', 'Invalid API credentials'); // Quit throw new \Exception('Invalid API credentials'); } }