File tree Expand file tree Collapse file tree 1 file changed +36
-23
lines changed Expand file tree Collapse file tree 1 file changed +36
-23
lines changed Original file line number Diff line number Diff line change @@ -58,29 +58,14 @@ private function execute(
58
58
array $ formData = []
59
59
): Response {
60
60
try {
61
- if ($ formData ) {
62
- /** @var GuzzleResponse $response */
63
- $ guzzleResponse = $ this ->guzzle ->request (
64
- $ method ,
65
- $ url ,
66
- [
67
- 'headers ' => $ headers ,
68
- 'form_params ' => $ formData ,
69
- 'timeout ' => 30
70
- ]
71
- );
72
- } else {
73
- /** @var GuzzleResponse $response */
74
- $ guzzleResponse = $ this ->guzzle ->request (
75
- $ method ,
76
- $ url ,
77
- [
78
- 'headers ' => $ headers ,
79
- 'body ' => $ content ,
80
- 'timeout ' => 30
81
- ]
82
- );
83
- }
61
+ $ guzzleResponse = $ this ->doExecute (
62
+ $ method ,
63
+ $ url ,
64
+ $ headers ,
65
+ $ content ,
66
+ $ formData
67
+ );
68
+
84
69
} catch (ConnectException $ e ) {
85
70
if (str_contains ($ e ->getMessage (), 'cURL error 28 ' )) {
86
71
throw new HttpTimeOutException ();
@@ -100,4 +85,32 @@ private function execute(
100
85
$ guzzleResponse ->getHeaders ()
101
86
);
102
87
}
88
+
89
+ private function doExecute (
90
+ string $ method ,
91
+ string $ url ,
92
+ array $ headers ,
93
+ ?string $ content ,
94
+ array $ formData
95
+ ): GuzzleResponse {
96
+ $ requestData = [
97
+ 'headers ' => $ headers ,
98
+ 'timeout ' => 30
99
+ ];
100
+
101
+ if ($ formData ) {
102
+ $ requestData ['form_params ' ] = $ formData ;
103
+ } else {
104
+ $ requestData ['body ' ] = $ content ;
105
+ }
106
+
107
+ /** @var GuzzleResponse $response */
108
+ $ guzzleResponse = $ this ->guzzle ->request (
109
+ $ method ,
110
+ $ url ,
111
+ $ requestData
112
+ );
113
+
114
+ return $ guzzleResponse ;
115
+ }
103
116
}
You can’t perform that action at this time.
0 commit comments