1 | <?php |
||
10 | class HttpClient extends Guzzle implements HttpClientInterface |
||
11 | { |
||
12 | /** |
||
13 | * Http base uri. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $baseUri; |
||
18 | |||
19 | /** |
||
20 | * Create a new instance of HttpClient. |
||
21 | * |
||
22 | * @param string $baseUri |
||
23 | */ |
||
24 | 11 | public function __construct($baseUri) |
|
40 | |||
41 | /** |
||
42 | * Get base uri. |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 1 | public function baseUri() |
|
50 | |||
51 | /** |
||
52 | * Send HTTP GET request. |
||
53 | * |
||
54 | * @param string $uri |
||
55 | * |
||
56 | * @return \Psr\Http\Message\ResponseInterface |
||
57 | */ |
||
58 | 6 | public function get($uri) |
|
62 | |||
63 | /** |
||
64 | * Send HTTP POST request. |
||
65 | * |
||
66 | * @param string $uri |
||
67 | * @param array $data |
||
68 | * |
||
69 | * @return \Psr\Http\Message\ResponseInterface |
||
70 | */ |
||
71 | 3 | public function post($uri, array $data = []) |
|
77 | |||
78 | /** |
||
79 | * Parse JSON response. |
||
80 | * |
||
81 | * @param \Psr\Http\Message\ResponseInterface $response |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 4 | public function parseJsonResponse(ResponseInterface $response) |
|
89 | |||
90 | /** |
||
91 | * Parse HTML response. |
||
92 | * |
||
93 | * @param \Psr\Http\Message\ResponseInterface $response |
||
94 | * |
||
95 | * @return \Symfony\Component\DomCrawler\Crawler |
||
96 | */ |
||
97 | 3 | public function parseHtmlResponse(ResponseInterface $response) |
|
103 | |||
104 | /** |
||
105 | * Send HTTP GET request and JSON response. |
||
106 | * |
||
107 | * @param string $uri |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 3 | public function getAndParseJson($uri) |
|
117 | |||
118 | /** |
||
119 | * Send HTTP POST request. |
||
120 | * |
||
121 | * @param string $uri |
||
122 | * @param array $data |
||
123 | * |
||
124 | * @return \Symfony\Component\DomCrawler\Crawler |
||
125 | */ |
||
126 | 3 | public function postAndParseHtml($uri, array $data = []) |
|
132 | } |
||
133 |