public function read()
    {
        if ($this->isComplete) {
            throw new ValidationException("Cannot call read() after streaming call is complete.");
        }
        $resourcesGetMethod = $this->resourcesGetMethod;
        if (!is_null($resourcesGetMethod)) {
            if (count($this->pendingResources) === 0) {
                $response = $this->call->read();
                if (!is_null($response)) {
                    $pendingResources = [];
                    foreach ($response->$resourcesGetMethod() as $resource) {
                        $pendingResources[] = $resource;
                    }
                    $this->pendingResources = array_reverse($pendingResources);
                }
            }
            $result = array_pop($this->pendingResources);
        } else {
            $result = $this->call->read();
        }
        if (is_null($result)) {
            $status = $this->call->getStatus();
            $this->isComplete = true;
            if (!($status->code == Code::OK)) {
                throw ApiException::createFromStdClass($status);
            }
        }
        return $result;
    }
public function read()
    {
        if ($this->isComplete) {
            throw new ValidationException("Cannot call read() after streaming call is complete.");
        }
        $resourcesGetMethod = $this->resourcesGetMethod;
        if (!is_null($resourcesGetMethod)) {
            if (count($this->pendingResources) === 0) {
                $response = $this->call->read();
                if (!is_null($response)) {
                    $pendingResources = [];
                    foreach ($response->$resourcesGetMethod() as $resource) {
                        $pendingResources[] = $resource;
                    }
                    $this->pendingResources = array_reverse($pendingResources);
                }
            }
            $result = array_pop($this->pendingResources);
        } else {
            $result = $this->call->read();
        }
        if (is_null($result)) {
            $status = $this->call->getStatus();
            $this->isComplete = true;
            if (!($status->code == Code::OK)) {
                throw ApiException::createFromStdClass($status);
            }
        }
        return $result;
    }
public function read ( ) { if ( $ this -> isComplete ) { throw new ValidationException ( "Cannot call read() after streaming call is complete." ) ; } $ resourcesGetMethod = $ this -> resourcesGetMethod ; if ( ! is_null ( $ resourcesGetMethod ) ) { if ( count ( $ this -> pendingResources ) === 0 ) { $ response = $ this -> call -> read ( ) ; if ( ! is_null ( $ response ) ) { $ pendingResources = [ ] ; foreach ( $ response -> $ resourcesGetMethod ( ) as $ resource ) { $ pendingResources [ ] = $ resource ; } $ this -> pendingResources = array_reverse ( $ pendingResources ) ; } } $ result = array_pop ( $ this -> pendingResources ) ; } else { $ result = $ this -> call -> read ( ) ; } if ( is_null ( $ result ) ) { $ status = $ this -> call -> getStatus ( ) ; $ this -> isComplete = true ; if ( ! ( $ status -> code == Code :: OK ) ) { throw ApiException :: createFromStdClass ( $ status ) ; } } return $ result ; }
Read the next response from the server. Returns null if the streaming call completed
successfully. Throws an ApiException if the streaming call failed.

@throws ValidationException
@throws ApiException
@return mixed
Read the next response from the server . Returns null if the streaming call completed successfully . Throws an ApiException if the streaming call failed .