/** * @dataProvider countableResponseDataProvider */ public function testExecuteReturnsCountableResponse(AbstractAction $action) { $proxyStub = $this->prepareProxyStub(); $client = new Client('test'); $action->client($client); $action->proxy($proxyStub); $result = $action->execute(); $this->assertInstanceOf('SMSApi\\Api\\Response\\CountableResponse', $result); }
public function execute(AbstractAction $action) { try { $uri = $action->uri(); $file = $action->file(); if ($uri == null) { throw new ProxyException("Invalid URI"); } $url = $this->prepareRequestUrl($uri); $query = $uri->getQuery(); $response = $this->makeRequest($url, $query, $file); $this->checkCode($response['code']); if (empty($response['output'])) { throw new ProxyException('Error fetching remote content empty'); } } catch (\Exception $e) { throw new ProxyException($e->getMessage()); } return $response['output']; }
public function execute(AbstractAction $action) { try { $uri = $action->uri(); $file = $action->file(); if ($uri == null) { throw new ProxyException("Invalid URI"); } $method = $action->getMethod(); $url = $this->prepareRequestUrl($uri); $query = $uri->getQuery(); $response = $this->makeRequest($method, $url, $query, $file, $action->isContacts()); if (!$action->isContacts()) { $this->checkCode($response['code']); } $notDeleteOrHead = !in_array($method, array(AbstractAction::METHOD_DELETE, AbstractAction::METHOD_HEAD)); if ($notDeleteOrHead and empty($response['output'])) { throw new ProxyException('Error fetching remote content empty'); } } catch (\Exception $e) { throw new ProxyException($e->getMessage(), 0, $e); } return $response; }
public function __construct(Client $client, Proxy $proxy) { parent::__construct(); $this->client($client)->proxy($proxy->setBasicAuthentication($client)); }