/** * Helper method to execute deferred HTTP requests. * * @param $request Google\Http\Request|Google\Http\Batch * @throws Google\Exception * @return object of the type of the expected class or array. */ public function execute($request) { if ($request instanceof Request) { $request->setUserAgent($this->getApplicationName() . " " . self::USER_AGENT_SUFFIX . $this->getLibraryVersion()); if (!$this->getClassConfig("Google\\Http\\Request", "disable_gzip")) { $request->enableGzip(); } $request->maybeMoveParametersToBody(); return REST::execute($this, $request); } else { if ($request instanceof Batch) { return $request->execute(); } else { throw new Exception("Do not know how to execute this type of object."); } } }
/** * Helper method to execute deferred HTTP requests. * * @param $request RequestInterface|Google_Http_Batch * @throws Google_Exception * @return object of the type of the expected class or Psr\Http\Message\ResponseInterface. */ public function execute(RequestInterface $request, $expectedClass = null) { $request = $request->withHeader('User-Agent', $this->config['application_name'] . " " . self::USER_AGENT_SUFFIX . $this->getLibraryVersion()); // call the authorize method // this is where most of the grunt work is done $http = $this->authorize(); return REST::execute($http, $request, $expectedClass, $this->config['retry']); }