/**
  * Resets/initializes the interpreted response to a fresh instance
  * with default values
  */
 protected function resetInterpretedResponse()
 {
     $this->interpretedResponse = app(ServiceResponse::class);
     $this->interpretedResponse->setStatusCode(0);
     $this->interpretedResponse->setErrors([]);
     $this->interpretedResponse->setData(null);
 }
 /**
  * Validates the ServiceResponse
  *
  * @param ServiceResponseInterface $response
  * @return bool
  */
 protected function validateResponse(ServiceResponseInterface $response)
 {
     if ($response->getData() == 'wrong') {
         $this->errors[] = 'wrong response';
         return false;
     }
     return true;
 }
 /**
  * Checks whether any user is logged in
  *
  * @param bool $onlyLocally if true, only checks locally and does not ask server
  * @return bool
  */
 public function isAnyUserLoggedIn($onlyLocally = false)
 {
     if (!$this->userAccessToken && !$this->getUserAccessTokenFromCache() && !$this->userRefreshToken && !$this->getUserRefreshTokenFromCache()) {
         return false;
     }
     if ($onlyLocally) {
         return true;
     }
     try {
         $this->get('users/ping');
         // if the userAccessToken is not intact after actually talking to the server
         // this means that it fell back to the guest token
         if (!$this->userAccessToken) {
             return false;
         }
         return $this->serviceResponse->getStatusCode() === 200;
     } catch (OAuthUnauthorizedException $e) {
         return false;
     }
 }