/** * @return \Guzzle\Http\Client */ protected function getClient() { if ($this->client === null) { $this->client = new Client('https://bitbucket.org/api/1.0/'); if ($this->authentication) { switch ($this->authentication->getType()) { case AuthInterface::BASIC: $this->client->getConfig()->setPath('request.options/auth', array($this->authentication->getUsername(), $this->authentication->getPassword(), 'Basic|Digest|NTLM|Any')); break; case AuthInterface::OAUTH: // TODO throw new \RuntimeException('Incomplete implementation'); break; default: throw new \RuntimeException(sprintf('Authentication via "%s" is not supported by bitbucket', $this->authentication->getType())); } } } return $this->client; }
/** * @return \Guzzle\Http\Client */ protected function getClient() { if ($this->client === null) { $this->client = new Client('https://api.github.com/'); $this->client->setDefaultOption('headers/Accept', 'application/vnd.github.v3+json'); if ($this->authentication) { switch ($this->authentication->getType()) { case AuthInterface::BASIC: $this->client->getConfig()->setPath('request.options/auth', array($this->authentication->getUsername(), $this->authentication->getPassword(), 'Basic|Digest|NTLM|Any')); break; case AuthInterface::ACCESS_TOKEN: $this->client->setDefaultOption('headers/Authorization', 'token ' . $this->authentication->getAccessToken()); break; default: throw new \RuntimeException(sprintf('Authentication via "%s" is not supported by github', $this->authentication->getType())); } } } return $this->client; }