/**
  * Test the URL builder
  */
 public function testUrlBuilder()
 {
     $request = $this->getMockBuilder('Silktide\\SemRushApi\\Model\\Request')->disableOriginalConstructor()->getMock();
     $request->method('getUrlParameters')->willReturn(["a" => "b", "c" => "d", 'export_columns' => ['a', 'b']]);
     $request->method('getEndpoint')->willReturn("http://endpoint.com");
     $url = $this->urlBuilder->build($request);
     $this->assertEquals("http://endpoint.com?a=b&c=d&export_columns=" . urlencode("a,b"), $url);
 }
Beispiel #2
0
 /**
  * Use guzzle to make request to API
  *
  * @param Request $request
  * @return string
  */
 protected function makeHttpRequest($request)
 {
     $url = $this->urlBuilder->build($request);
     $guzzleRequest = $this->guzzle->createRequest('GET', $url);
     $guzzleResponse = $this->guzzle->send($guzzleRequest);
     return $guzzleResponse->getBody();
 }
Beispiel #3
0
 /**
  * Use guzzle to make request to API
  *
  * @param Request $request
  * @return string
  */
 protected function makeHttpRequest($request)
 {
     $url = $this->urlBuilder->build($request);
     $guzzleResponse = $this->guzzle->request('GET', $url, [RequestOptions::CONNECT_TIMEOUT => $this->connectTimeout, RequestOptions::TIMEOUT => $this->timeout]);
     return $guzzleResponse->getBody();
 }