File tree 4 files changed +72
-2
lines changed
4 files changed +72
-2
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace Ivan770 \HttpClient \Contracts ;
5
+
6
+ use Ivan770 \HttpClient \Response ;
7
+
8
+ interface Request
9
+ {
10
+ /**
11
+ * Attach builder properties. HttpClient instance is passed into Closure
12
+ *
13
+ * @param \Closure $callback
14
+ * @return Request
15
+ */
16
+ public function attach ($ callback );
17
+
18
+ /**
19
+ * Run request
20
+ *
21
+ * @return Response
22
+ */
23
+ public function execute ();
24
+
25
+ /**
26
+ * Run request, and retrieve response contents
27
+ *
28
+ * @return \Illuminate\Support\Collection|string
29
+ */
30
+ public function get ();
31
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Ivan770 \HttpClient \Contracts ;
4
+
5
+ use Illuminate \Pipeline \Pipeline ;
6
+
7
+ interface Response
8
+ {
9
+ /**
10
+ * Create collection from response
11
+ *
12
+ * @return \Illuminate\Support\Collection
13
+ */
14
+ public function toCollection ();
15
+
16
+ /**
17
+ * Get body of response, or collection, if response is JSON-compatible
18
+ *
19
+ * @param bool $throw
20
+ * @return \Illuminate\Support\Collection|string
21
+ */
22
+ public function getContent ($ throw = true );
23
+
24
+ /**
25
+ * Pass response content to function
26
+ *
27
+ * @param \Closure $function Function to call
28
+ */
29
+ public function then ($ function );
30
+
31
+ /**
32
+ * Pass response content to pipeline
33
+ *
34
+ * @return Pipeline
35
+ */
36
+ public function pipeline ();
37
+ }
Original file line number Diff line number Diff line change 3
3
4
4
namespace Ivan770 \HttpClient ;
5
5
6
+ use Ivan770 \HttpClient \Contracts \Request as RequestContract ;
6
7
7
- abstract class Request
8
+ abstract class Request implements RequestContract
8
9
{
9
10
/**
10
11
* HttpClient instance
Original file line number Diff line number Diff line change 7
7
use Illuminate \Container \Container ;
8
8
use Illuminate \Contracts \Pipeline \Pipeline as PipelineContract ;
9
9
use Illuminate \Pipeline \Pipeline ;
10
+ use Ivan770 \HttpClient \Contracts \Response as ResponseContract ;
10
11
11
12
/**
12
13
* @method int getStatusCode() Get response status code
13
14
* @method array getHeaders(bool $throw = true) Get response headers
14
15
* @method array toArray(bool $throw = true) Get array from response
15
16
* @method array|mixed|null getInfo(string $type = null) Get info from transport layer
16
17
*/
17
- class Response
18
+ class Response implements ResponseContract
18
19
{
19
20
protected $ baseResponse ;
20
21
You can’t perform that action at this time.
0 commit comments