Пример #1
0
 /**
  * update character log (active system, ...)
  * -> CREST API request for character log data
  * @param array $additionalOptions (optional) request options for cURL request
  * @return $this
  */
 public function updateLog($additionalOptions = [])
 {
     // Try to pull data from CREST
     $ssoController = new Sso();
     $logData = $ssoController->getCharacterLocationData($this->getAccessToken(), 5, $additionalOptions);
     if ($logData['timeout'] === false) {
         if (empty($logData['system'])) {
             // character is not in-game
             if (is_object($this->characterLog)) {
                 // delete existing log
                 $this->characterLog->erase();
                 $this->save();
             }
         } else {
             // character is currently in-game
             if (!($characterLog = $this->getLog())) {
                 // create new log
                 $characterLog = $this->rel('characterLog');
                 $characterLog->characterId = $this->_id;
             }
             $characterLog->setData($logData);
             $characterLog->save();
             $this->characterLog = $characterLog;
         }
     }
     return $this;
 }