Skip to content

Commit

Permalink
Merge pull request #28 from sem-soft/master
Browse files Browse the repository at this point in the history
Возможность тонкой настройки Guzzle-клиента
  • Loading branch information
zelenin authored Mar 26, 2018
2 parents f290233 + 2035b5e commit 6a24d63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Api
* @var ClientInterface
*/
private $client;

/**
* @param AuthInterface $auth
*/
Expand Down
18 changes: 14 additions & 4 deletions Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@

class Client implements ClientInterface
{

/**
* @var string
*/
private $baseUrl = 'https://sms.ru/{method}';

/**
* @var \GuzzleHttp\Client
*/
private $client;

/**
* @param array $config Additional configuration for Guzzle Client
*/
public function __construct($config = [])
{
$this->client = new \GuzzleHttp\Client($config);
}

/**
* @param string $method
* @param array $params
Expand All @@ -22,9 +34,7 @@ class Client implements ClientInterface
*/
public function request($method, $params = [])
{
$client = new \GuzzleHttp\Client();

$response = $client->post($this->getUrl($method), ['query' => $params]);
$response = $this->client->post($this->getUrl($method), ['query' => $params]);

if ($response->getStatusCode() === 200) {
return (string)$response->getBody();
Expand Down

0 comments on commit 6a24d63

Please sign in to comment.