printer-manager-admin/app/Http/Controllers/Api/Printer/ClearQueuePrinterController.php

41 lines
1 KiB
PHP
Raw Permalink Normal View History

2023-11-03 10:49:11 +00:00
<?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)
{
2023-11-03 11:01:21 +00:00
//todo fetch printer from request instead of doing it on controller
2023-11-03 10:49:11 +00:00
$printer = Printer::find($id);
2023-11-03 11:01:21 +00:00
//todo validate from rquest class
2023-11-03 10:58:43 +00:00
$data = request()->input('params');
2023-11-03 10:49:11 +00:00
$baseUrl = 'http://' .$printer->config->networkFormat();
2023-11-03 11:01:21 +00:00
//todo create service class to send requests
2023-11-03 10:49:11 +00:00
$httpClient = Http::withHeaders([
// 'Accept-Language' => $integrationProfile->api_credentials['language'],
// 'Authorization' => $authToken,
]);
$url = $baseUrl . '/server/job_queue/job';
$query = [];
2023-11-03 10:58:43 +00:00
$method = 'delete';
2023-11-03 10:49:11 +00:00
$response = $httpClient->{$method}($url, $method === 'get' ? $query : $data);
dd($response);
return ApiResponse::handle();
}
}