@@ -64,23 +64,14 @@ class CallWebhookJob implements ShouldQueue
64
64
65
65
public function handle ()
66
66
{
67
- $ client = $ this ->getClient ();
68
-
69
67
$ lastAttempt = $ this ->attempts () >= $ this ->tries ;
70
68
71
69
try {
72
70
$ body = strtoupper ($ this ->httpVerb ) === 'GET '
73
71
? ['query ' => $ this ->payload ]
74
72
: ['body ' => json_encode ($ this ->payload )];
75
73
76
- $ this ->response = $ client ->request ($ this ->httpVerb , $ this ->webhookUrl , array_merge ([
77
- 'timeout ' => $ this ->requestTimeout ,
78
- 'verify ' => $ this ->verifySsl ,
79
- 'headers ' => $ this ->headers ,
80
- 'on_stats ' => function (TransferStats $ stats ) {
81
- $ this ->transferStats = $ stats ;
82
- },
83
- ], $ body , is_null ($ this ->proxy ) ? [] : ['proxy ' => $ this ->proxy ]));
74
+ $ this ->response = $ this ->createRequest ($ body );
84
75
85
76
if (! Str::startsWith ($ this ->response ->getStatusCode (), 2 )) {
86
77
throw new Exception ('Webhook call failed ' );
@@ -135,6 +126,20 @@ protected function getClient(): ClientInterface
135
126
return app (Client::class);
136
127
}
137
128
129
+ protected function createRequest (array $ body ): Response
130
+ {
131
+ $ client = $ this ->getClient ();
132
+
133
+ return $ client ->request ($ this ->httpVerb , $ this ->webhookUrl , array_merge ([
134
+ 'timeout ' => $ this ->requestTimeout ,
135
+ 'verify ' => $ this ->verifySsl ,
136
+ 'headers ' => $ this ->headers ,
137
+ 'on_stats ' => function (TransferStats $ stats ) {
138
+ $ this ->transferStats = $ stats ;
139
+ },
140
+ ], $ body , is_null ($ this ->proxy ) ? [] : ['proxy ' => $ this ->proxy ]));
141
+ }
142
+
138
143
protected function shouldBeRemovedFromQueue (): bool
139
144
{
140
145
return false ;
0 commit comments