mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
* Grocycode: Productpicker, StockService * Grocycode: Datamatrix generation * Grocycode: Display in UI, make Images downloadable * Grocycode: Do not show on product card * Grocycode: Stockentry Label view * Grocycode: Webhooks & Labelprinter Feature * Grocycode: Manual Label printing * Grocycode: Print Label from product form * Quagga2: use zxing for DataMatrix recognition * Grocycode: Default settings for label printing * Prepare merge of master * Grocycode: docs * Docs: label printing webhook * Review - "grocy" is currently written lower-case everywhere, so let's do this also for "grocycode" - Unified phrases / capitalization - Minor UI adjustments (mainly context menu item ordering / ordering/spacing on product edit page) - Documented API changes for Swagger UI (grocy.openapi.json) - Reverted German localizations (those are managed via Transifex; would cause conflicts when manually edited - will import them later there) - Reverted a somehow messed up localization string (productform/help text for `cumulate_min_stock_amount_of_sub_products`) - Suppress deprecation warnings when generating Datamatrix PNG (otherwise the PNG is invalid, https://github.com/jucksearm/php-barcode/issues/3) - Default `FEATURE_FLAG_LABELPRINTER` to disabled Co-authored-by: Bernd Bestel <bernd@berrnd.de>
49 lines
852 B
PHP
49 lines
852 B
PHP
<?php
|
|
|
|
namespace Grocy\Helpers;
|
|
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\ExceptionRequestException;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
class WebhookRunner
|
|
{
|
|
private $client;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->client = new Client(['timeout' => 2.0]);
|
|
}
|
|
|
|
public function run($url, $args, $json = false)
|
|
{
|
|
$reqArgs = [];
|
|
if ($json)
|
|
{
|
|
$reqArgs = ['json' => $args];
|
|
}
|
|
else
|
|
{
|
|
$reqArgs = ['form_params' => $args];
|
|
}
|
|
try
|
|
{
|
|
file_put_contents('php://stderr', 'Running Webhook: ' . $url . "\n" . print_r($reqArgs, true));
|
|
|
|
$this->client->request('POST', $url, $reqArgs);
|
|
}
|
|
catch (RequestException $e)
|
|
{
|
|
file_put_contents('php://stderr', 'Webhook failed: ' . $url . "\n" . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function runAll($urls, $args)
|
|
{
|
|
foreach ($urls as $url)
|
|
{
|
|
$this->run($url, $args);
|
|
}
|
|
}
|
|
}
|