- Menambahkan ResponseCode enum untuk standarisasi semua response API. - Integrasi meta data: nomor rekening, periode, request_id, dan reference_code. - Memperbarui validasi input dengan response code standar (INVALID_FIELD). - Struktur response dibuat konsisten untuk success dan error. - Logging diperkuat untuk debugging dan monitoring.
45 lines
1.7 KiB
PHP
45 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Str;
|
|
|
|
class BalanceSummaryResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'account_number' => $this['account_number'],
|
|
'period' => [
|
|
'start_date' => $this['period']['start_date'],
|
|
'end_date' => $this['period']['end_date'],
|
|
],
|
|
'opening_balance' => [
|
|
'date' => $this['opening_balance']['date'],
|
|
'balance' => $this['opening_balance']['balance'],
|
|
'formatted_balance' => number_format($this['opening_balance']['balance'], 2, ',', '.'),
|
|
],
|
|
'closing_balance' => [
|
|
'date' => $this['closing_balance']['date'],
|
|
'balance' => $this['closing_balance']['balance'],
|
|
'formatted_balance' => number_format($this['closing_balance']['balance'], 2, ',', '.'),
|
|
'base_balance' => [
|
|
'date' => $this['closing_balance']['base_balance']['date'],
|
|
'balance' => $this['closing_balance']['base_balance']['balance'],
|
|
'formatted_balance' => number_format($this['closing_balance']['base_balance']['balance'], 2, ',', '.'),
|
|
],
|
|
'transactions_on_end_date' => $this['closing_balance']['transactions_on_end_date'],
|
|
'formatted_transactions_on_end_date' => number_format($this['closing_balance']['transactions_on_end_date'], 2, ',', '.'),
|
|
]
|
|
];
|
|
}
|
|
}
|