/** * @param array $data * * @return string * @throws Exception\RuntimeException */ private function getFile(array $data) { $data = array_merge(array('api_token' => $this->options->getApiToken(), 'id' => $this->options->getProjectId(), 'action' => 'export'), $data); $fileKey = md5(json_encode($data)); if (isset($this->files[$fileKey])) { return $this->files[$fileKey]; } $client = new Http\Client(null, $this->options->getClient()); $request = new Http\Request(); $request->setUri($this->options->getUrl()); $request->setMethod(Http\Request::METHOD_POST); $request->setContent(http_build_query($data)); usleep($this->options->getRequestDelay()); /** @var \Zend\Http\Response $response */ $response = $client->dispatch($request); if (!$response->isSuccess()) { throw new Exception\RuntimeException('Request was not successful'); } /** @var \stdClass $content */ $content = json_decode($response->getContent()); if ($content->response->code != 200) { throw new Exception\RuntimeException($content->response->message); } $this->files[$fileKey] = $content->item; return $this->files[$fileKey]; }
public function testMutateClient() { $value = array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl'); $this->fixture->setClient($value); $this->assertSame($value, $this->fixture->getClient()); }