printer-manager-admin/app/Http/Controllers/Api/Printer/ClearQueuePrinterController.php
2023-11-03 12:01:21 +01:00

40 lines
1 KiB
PHP

<?php
namespace App\Http\Controllers\Api\Printer;
use App\Http\Resources\Printer\ListPrinterResource;
use App\Models\Printer;
use App\Http\Responses\ApiResponse;
use Illuminate\Support\Facades\Http;
class ClearQueuePrinterController
{
public function __invoke(string $id)
{
//todo fetch printer from request instead of doing it on controller
$printer = Printer::find($id);
//todo validate from rquest class
$data = request()->input('params');
$baseUrl = 'http://' .$printer->config->networkFormat();
//todo create service class to send requests
$httpClient = Http::withHeaders([
// 'Accept-Language' => $integrationProfile->api_credentials['language'],
// 'Authorization' => $authToken,
]);
$url = $baseUrl . '/server/job_queue/job';
$query = [];
$method = 'delete';
$response = $httpClient->{$method}($url, $method === 'get' ? $query : $data);
dd($response);
return ApiResponse::handle();
}
}