Exemplo n.º 1
0
 /**
  * @param $arrHeaders
  * @param $postData
  * @throws \RuntimeException
  * @throws \LogicException
  */
 private function prepareRequest(&$arrHeaders, &$postData)
 {
     switch ($this->authType) {
         case self::AUTH_TYPE_ACCESS_TOKEN:
             if (false == $this->accessToken) {
                 throw new \RuntimeException('Access Token must be set');
             }
             $arrHeaders[] = 'Authorization: token ' . $this->accessToken;
             break;
         case self::AUTH_TYPE_BASIC_AUTH:
             if (false == $this->clientId || false == $this->clientSecret) {
                 throw new \RuntimeException('ClientId and ClientSecret Must be set');
             }
             $this->httpClient->setCredentials($this->getClientId(), $this->getClientSecret());
             break;
         case self::AUTH_TYPE_REQUEST:
             if (false == $this->clientId || false == $this->clientSecret) {
                 throw new \RuntimeException('ClientId and ClientSecret Must be set');
             }
             $postData['client_id'] = $this->getClientId();
             $postData['client_secret'] = $this->getClientSecret();
             break;
         default:
             throw new \LogicException(sprintf("Invalid authentication type '%s'", $this->authType));
     }
 }