File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,19 @@ abstract class AbstractApi
47
47
*/
48
48
protected $ response = Response::class;
49
49
50
+ /**
51
+ * @var array
52
+ */
53
+ protected $ config = [];
54
+
50
55
/**
51
56
* AbstractApi constructor.
52
57
* @param Request|null $request
53
58
*/
54
59
public function __construct (Request $ request = null )
55
60
{
56
61
if (!$ request ) {
57
- $ this ->request = new Request (new GuzzleClient ());
62
+ $ this ->request = new Request (new GuzzleClient ($ this -> config ));
58
63
}
59
64
60
65
$ this ->setBaseURL ($ this ->getBaseURL ());
@@ -66,6 +71,26 @@ public function __construct(Request $request = null)
66
71
*/
67
72
abstract protected function getBaseURL ();
68
73
74
+ /**
75
+ * Get client configs
76
+ *
77
+ * @return array
78
+ */
79
+ public function getConfig ()
80
+ {
81
+ return $ this ->config ;
82
+ }
83
+
84
+ /**
85
+ * Set client config
86
+ *
87
+ * @param $config
88
+ */
89
+ public function setConfig ($ config )
90
+ {
91
+ $ this ->config = $ config ;
92
+ }
93
+
69
94
/**
70
95
* Get request instance
71
96
*
Original file line number Diff line number Diff line change 9
9
10
10
abstract class AbstractClient
11
11
{
12
+
13
+ /**
14
+ * @var array
15
+ */
16
+ protected $ config ;
17
+
18
+ public function __construct ($ config = [])
19
+ {
20
+ $ this ->config = $ config ;
21
+ }
12
22
/**
13
23
* @return string
14
24
*/
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function getUriClass()
42
42
*/
43
43
public function send (...$ args )
44
44
{
45
- $ client = new Client ();
45
+ $ client = new Client ($ this -> config );
46
46
47
47
return $ client ->send (... $ args );
48
48
}
You can’t perform that action at this time.
0 commit comments