Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\PembiayaanOnline\PembiayaanOnlineService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PembiayaanOnlineController extends Controller
|
||||
{
|
||||
protected $service;
|
||||
|
||||
public function __construct(PembiayaanOnlineService $service = null)
|
||||
{
|
||||
$this->service = $service ?: new PembiayaanOnlineService();
|
||||
}
|
||||
|
||||
protected function respond(array $result)
|
||||
{
|
||||
return response()->json($result['payload'], $result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}
|
||||
*/
|
||||
public function store($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->store($kodcaw, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/by-norujukan/{norujukan}
|
||||
*/
|
||||
public function show($kodcaw, $norujukan)
|
||||
{
|
||||
return $this->respond($this->service->show($kodcaw, $norujukan));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/queue
|
||||
*/
|
||||
public function queue($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->queue($kodcaw, $request->input('status')));
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT /api/pembiayaan-online/{kodcaw}/lines/{id}
|
||||
*/
|
||||
public function updateLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
// Prefer only present keys so "has" semantics match previous controller.
|
||||
$input = [];
|
||||
foreach ([
|
||||
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
||||
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
||||
] as $key) {
|
||||
if ($request->has($key)) {
|
||||
$input[$key] = $request->input($key);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond($this->service->updateLine($kodcaw, $id, $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/batches
|
||||
*/
|
||||
public function listBatches($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->listBatches(
|
||||
$kodcaw,
|
||||
$request->input('tarikh'),
|
||||
$request->input('status')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/batches/{batchId}
|
||||
*/
|
||||
public function showBatch($kodcaw, $batchId)
|
||||
{
|
||||
return $this->respond($this->service->showBatch($kodcaw, $batchId));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}/batches/submit
|
||||
*/
|
||||
public function submitBatch($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->submitBatch(
|
||||
$kodcaw,
|
||||
$request->input('ids', []),
|
||||
$request->input('pc_submitted_by', ''),
|
||||
$request->input('slot')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/operasi/batches
|
||||
*/
|
||||
public function operasiListBatches(Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiListBatches(
|
||||
$request->input('status', 'SUBMITTED'),
|
||||
$request->input('tarikh')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}
|
||||
*/
|
||||
public function operasiShowBatch($kodcaw, $batchId)
|
||||
{
|
||||
return $this->showBatch($kodcaw, $batchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/approve
|
||||
*/
|
||||
public function operasiApproveLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiApproveLine(
|
||||
$kodcaw,
|
||||
$id,
|
||||
$request->input('ops_by', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/reject
|
||||
*/
|
||||
public function operasiRejectLine($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiRejectLine(
|
||||
$kodcaw,
|
||||
$id,
|
||||
$request->input('ops_by', ''),
|
||||
$request->input('reject_reason', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/approve
|
||||
*/
|
||||
public function operasiApproveBatch($kodcaw, $batchId, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiApproveBatch(
|
||||
$kodcaw,
|
||||
$batchId,
|
||||
$request->input('ops_by', '')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/lines/{id}/paid
|
||||
* Body: ops_by, no_rujukan_bayaran, tarikh_bayaran?,
|
||||
* bukti_data + bukti_filename + bukti_type OR bukti_file_id
|
||||
*/
|
||||
public function operasiMarkPaid($kodcaw, $id, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiMarkPaid($kodcaw, $id, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/operasi/{kodcaw}/batches/{batchId}/paid
|
||||
*/
|
||||
public function operasiMarkPaidBatch($kodcaw, $batchId, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->operasiMarkPaidBatch($kodcaw, $batchId, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/bukti
|
||||
*/
|
||||
public function getBukti($kodcaw, $id)
|
||||
{
|
||||
return $this->respond($this->service->getBukti($kodcaw, $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
||||
*/
|
||||
public function paidQueue($kodcaw, Request $request)
|
||||
{
|
||||
return $this->respond($this->service->paidQueue(
|
||||
$kodcaw,
|
||||
$request->input('blast_sent')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/pembiayaan-online/{kodcaw}/paid/blast
|
||||
* Body: ids[] (or ids), blast_by?
|
||||
*/
|
||||
public function markBlastSent($kodcaw, Request $request)
|
||||
{
|
||||
$ids = $request->input('ids', $request->input('id'));
|
||||
return $this->respond($this->service->markBlastSent(
|
||||
$kodcaw,
|
||||
$ids,
|
||||
$request->input('blast_by')
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user