Example #1
0
 /**
  * @throws \Guzzle\Common\Exception\InvalidArgumentException
  * @throws \Exception
  * @return AuthResponse
  */
 public function auth()
 {
     $request = $this->post($this->getBaseUrl() . Endpoint::OAUTH_TOKEN, ["Accept" => "application/json", "Accept-Language" => "en_US"], ["grant_type" => "client_credentials"]);
     $request->setAuth($this->credentials->getClientId(), $this->credentials->getSecret());
     $response = parent::send($request);
     // todo retry if status code in self::$retryCode
     return $this->getSerializer()->deserialize($response->getBody(true), 'Onend\\PayPal\\Common\\Auth\\AuthResponse', RequestFormat::JSON);
 }
 /**
  * {@inheritdoc}
  */
 public function send($requests)
 {
     $accessToken = $this->provider->getAccessToken();
     if (!$requests instanceof RequestInterface) {
         /** @var $requests RequestInterface[] */
         foreach ($requests as &$request) {
             $this->addTokenHeader($request, $accessToken);
             $this->addJsonContentTypeHeader($request);
         }
         return $this->sendMultiple($requests);
     }
     $this->addTokenHeader($requests, $accessToken);
     $this->addJsonContentTypeHeader($requests);
     return parent::send($requests);
 }