Ejemplo n.º 1
0
 /**
  * Inject into the request authentication options
  *
  * @param \Guzzle\Common\Event $event
  */
 public function onCreateRequest(Event $event)
 {
     $data = $event->toArray();
     /** @var $request Request */
     $request = $data['request'];
     $request->setAuth($this->username, $this->password);
 }
 /**
  * Default method that will throw exceptions if an unsuccessful response is received.
  *
  * @param Event $event Received
  * @throws BadResponseException if the response is not successful
  */
 public static function onRequestError(Event $event)
 {
     $e = BadResponseException::factory($event['request'], $event['response']);
     $event['request']->setState(self::STATE_ERROR, array('exception' => $e) + $event->toArray());
     throw $e;
 }