feat(#46): added support for request body in recipes

This commit is contained in:
Benjamin Nussbaum 2025-07-02 17:33:05 +02:00
parent 3673654df6
commit e326ded933
7 changed files with 130 additions and 19 deletions

View file

@ -56,9 +56,19 @@ class Plugin extends Model
}
}
$response = Http::withHeaders($headers)
->get($this->polling_url)
->json();
$httpRequest = Http::withHeaders($headers);
// Add body for POST requests if polling_body is provided
if ($this->polling_verb === 'post' && $this->polling_body) {
$httpRequest = $httpRequest->withBody($this->polling_body);
}
// Make the request based on the verb
if ($this->polling_verb === 'post') {
$response = $httpRequest->post($this->polling_url)->json();
} else {
$response = $httpRequest->get($this->polling_url)->json();
}
$this->update([
'data_payload' => $response,