@@ -31,12 +31,15 @@ class RestApi
31
31
32
32
protected $ enumCustomFields ;
33
33
34
- public function __construct ($ baseUrl , $ username , $ password )
34
+ protected ?string $ proxy ;
35
+
36
+ public function __construct ($ baseUrl , $ username , $ password , ?string $ proxy )
35
37
{
36
38
$ this ->username = $ username ;
37
39
$ this ->password = $ password ;
38
40
$ this ->baseUrlForLink = $ baseUrl ;
39
41
$ this ->baseUrl = \rtrim ($ baseUrl , '/ ' ) . '/rest ' ;
42
+ $ this ->proxy = $ proxy ;
40
43
$ this ->serverInfo = $ this ->get ('serverInfo ' )->getResult ();
41
44
}
42
45
@@ -61,8 +64,9 @@ public static function fromConfig()
61
64
62
65
$ user = $ config ->get ('api ' , 'username ' );
63
66
$ pass = $ config ->get ('api ' , 'password ' );
67
+ $ proxy = $ config ->get ('api ' , 'proxy ' );
64
68
65
- $ api = new static ($ url , $ user , $ pass );
69
+ $ api = new static ($ url , $ user , $ pass, $ proxy );
66
70
67
71
return $ api ;
68
72
}
@@ -448,6 +452,10 @@ protected function request($method, $url, $body = null)
448
452
CURLOPT_SSL_VERIFYPEER => false ,
449
453
);
450
454
455
+ if ($ this ->proxy ) {
456
+ $ opts [CURLOPT_PROXY ] = $ this ->proxy ;
457
+ }
458
+
451
459
curl_setopt_array ($ curl , $ opts );
452
460
// TODO: request headers, validate status code
453
461
0 commit comments