2015-03-23 23:41:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Service;
|
|
|
|
|
|
|
|
use Guzzle\Service\Client;
|
|
|
|
use Guzzle\Http\Message\Request as GuzzleRequest;
|
|
|
|
use Guzzle\Http\Message\Response as GuzzleResponse;
|
|
|
|
|
|
|
|
// @todo Implement commands: https://github.com/misd-service-development/guzzle-bundle/blob/master/Resources/doc/serialization.md
|
|
|
|
class AbstractApi
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var Client HTTP-client from Guzzle
|
|
|
|
*/
|
|
|
|
protected $client;
|
2015-03-27 19:49:21 +00:00
|
|
|
|
2015-03-23 23:41:41 +00:00
|
|
|
public function __construct($httpClient)
|
|
|
|
{
|
|
|
|
$this->client = $httpClient;
|
|
|
|
}
|
2015-03-27 19:49:21 +00:00
|
|
|
|
2015-03-23 23:41:41 +00:00
|
|
|
/**
|
|
|
|
* Make GET request and return Response object
|
2015-03-27 19:49:21 +00:00
|
|
|
*
|
2015-03-23 23:41:41 +00:00
|
|
|
* @param string $pathTemplate
|
|
|
|
* @param array $parameters
|
|
|
|
* @return GuzzleResponse
|
|
|
|
*/
|
|
|
|
public function sendGetRequest($pathTemplate, array $parameters = [])
|
|
|
|
{
|
|
|
|
$path = vsprintf($pathTemplate, $parameters);
|
2015-03-27 19:49:21 +00:00
|
|
|
|
2015-03-23 23:41:41 +00:00
|
|
|
$request = $this->client->get($path);
|
2015-03-27 19:49:21 +00:00
|
|
|
|
2015-03-23 23:41:41 +00:00
|
|
|
return $request->send();
|
|
|
|
}
|
|
|
|
}
|