Compare commits
3 commits
main
...
feature/pr
Author | SHA1 | Date | |
---|---|---|---|
|
ab514bfcf5 | ||
|
a6f2a4fac7 | ||
|
900ffdb56f |
2 changed files with 42 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\Printer\ClearQueuePrinterController;
|
||||
use App\Http\Controllers\Api\Printer\GetPrinterController;
|
||||
use App\Http\Controllers\Api\Printer\ListPrinterController;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -22,3 +23,4 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
|||
|
||||
Route::get('/printers', ListPrinterController::class);
|
||||
Route::get('/printers/{id}', GetPrinterController::class);
|
||||
Route::post('/printers/{id}/clear-queue', ClearQueuePrinterController::class);
|
||||
|
|
Loading…
Reference in a new issue