Files
app-agent/app/Services/CafeBazaar/BazaarResponse.php
T
2026-08-24 19:44:24 +03:30

28 lines
643 B
PHP

<?php
namespace App\Services\CafeBazaar;
use Illuminate\Http\JsonResponse;
class BazaarResponse
{
public function __construct(
public readonly int $status,
public readonly array $body,
) {}
public function successful(): bool
{
return $this->status >= 200 && $this->status < 300;
}
public function toJsonResponse(): JsonResponse
{
return response()->json([
'data' => $this->successful() ? $this->body : null,
'error' => $this->successful() ? null : $this->body,
'meta' => ['bazaar_status' => $this->status],
], $this->status);
}
}