Skip to content

Commit 3e3f85f

Browse files
Introduce client interface
1 parent 43de757 commit 3e3f85f

File tree

2 files changed

+66
-17
lines changed

2 files changed

+66
-17
lines changed

src/Client.php

+9-17
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
namespace Sylius\Api;
1313

1414
use GuzzleHttp\ClientInterface as HttpClientInterface;
15-
use GuzzleHttp\Message\ResponseInterface;
1615
use GuzzleHttp\Post\PostBodyInterface;
17-
use GuzzleHttp\Url;
1816
use Sylius\Api\Factory\PostFileFactory;
1917
use Sylius\Api\Factory\PostFileFactoryInterface;
2018

@@ -23,12 +21,15 @@
2321
*
2422
* @author Michał Marcinkowski <[email protected]>
2523
*/
26-
class Client
24+
class Client implements ClientInterface
2725
{
2826
/**
2927
* @var HttpClientInterface $httpClient
3028
*/
3129
private $httpClient;
30+
/**
31+
* @var PostFileFactoryInterface $postFileFactory
32+
*/
3233
private $postFileFactory;
3334

3435
public function __construct(HttpClientInterface $httpClient, PostFileFactoryInterface $postFileFactory = null)
@@ -38,48 +39,39 @@ public function __construct(HttpClientInterface $httpClient, PostFileFactoryInte
3839
}
3940

4041
/**
41-
* @param string|Url $url URL or URI template
42-
* @return ResponseInterface
42+
* {@inheritdoc }
4343
*/
4444
public function get($url)
4545
{
4646
return $this->httpClient->get($url);
4747
}
4848

4949
/**
50-
* @param string|Url $url URL or URI template
51-
* @param array $body
52-
* @return ResponseInterface
50+
* {@inheritdoc }
5351
*/
5452
public function patch($url, array $body)
5553
{
5654
return $this->httpClient->patch($url, ['body' => $body]);
5755
}
5856

5957
/**
60-
* @param string|Url $url URL or URI template
61-
* @param array $body
62-
* @return ResponseInterface
58+
* {@inheritdoc }
6359
*/
6460
public function put($url, array $body)
6561
{
6662
return $this->httpClient->put($url, ['body' => $body]);
6763
}
6864

6965
/**
70-
* @param string|Url $url URL or URI template
71-
* @return ResponseInterface
66+
* {@inheritdoc }
7267
*/
7368
public function delete($url)
7469
{
7570
return $this->httpClient->delete($url);
7671
}
7772

7873
/**
79-
* @param string|Url $url URL or URI template
80-
* @param array $body
81-
* @param array $files
82-
* @return ResponseInterface
74+
* {@inheritdoc }
8375
*/
8476
public function post($url, $body, array $files = array())
8577
{

src/ClientInterface.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Lakion package.
5+
*
6+
* (c) Lakion
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Sylius\Api;
13+
14+
use GuzzleHttp\Message\ResponseInterface;
15+
use GuzzleHttp\Url;
16+
17+
/**
18+
* Sylius API client interface
19+
*
20+
* @author Michał Marcinkowski <[email protected]>
21+
*/
22+
interface ClientInterface
23+
{
24+
/**
25+
* @param string|Url $url URL or URI template
26+
* @return ResponseInterface
27+
*/
28+
public function get($url);
29+
30+
/**
31+
* @param string|Url $url URL or URI template
32+
* @param array $body
33+
* @return ResponseInterface
34+
*/
35+
public function patch($url, array $body);
36+
37+
/**
38+
* @param string|Url $url URL or URI template
39+
* @param array $body
40+
* @return ResponseInterface
41+
*/
42+
public function put($url, array $body);
43+
44+
/**
45+
* @param string|Url $url URL or URI template
46+
* @return ResponseInterface
47+
*/
48+
public function delete($url);
49+
50+
/**
51+
* @param string|Url $url URL or URI template
52+
* @param array $body
53+
* @param array $files
54+
* @return ResponseInterface
55+
*/
56+
public function post($url, $body, array $files = array());
57+
}

0 commit comments

Comments
 (0)