<?php
namespace App\Controller;
use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use App\Services\ApiService;
use Pimcore\Translation\Translator;
class CustomerCareController extends FrontendController
{
private $apiService;
protected $translator;
public function __construct(Translator $translator)
{
$this->apiService = new ApiService();
$this->translator = $translator;
}
/**
* @param Request $request
* @return Response
*/
public function defaultAction(Request $request): Response
{
return $this->render('customer-care/customer-service-flow.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function listPartnerWorkshopsAction(Request $request): Response
{
return $this->render('customer-care/list-partner-workshops.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function listOfProvidersAction(Request $request): Response
{
return $this->render('customer-care/list-of-providers.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function cekPolisAction(Request $request): Response
{
return $this->render('customer-care/cek-polis.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function complaintResolutionMechanismAction(Request $request): Response
{
return $this->render('customer-care/complaint-resolution-mechanism.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function complaintHandlingAction(Request $request): Response
{
return $this->render('customer-care/complaint-handling.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function complaintHandlingPublicationAction(Request $request): Response
{
return $this->render('customer-care/complaint-handling-publication.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function serviceProcedureAction(Request $request): Response
{
return $this->render('customer-care/service-procedure.html.twig');
}
/**
* @param Request $request
* @return Response
*/
public function faqAction(Request $request): Response
{
return $this->render('customer-care/faq.html.twig');
}
/**
* @Route("api/customer-care/list-bengkel")
* @Method("GET")
*/
public function apiListBengkelAction(Request $request)
{
$data = $this->apiService->getListBengkel($request);
$response = [];
foreach($data->data as $value => $res){
$response[] = [
'nama' => $res->Nama,
'alamat' => $res->Alamat,
'phone' => $res->Telp,
'contact_person' => $res->Contact_Person,
];
}
if ($response) {
return $this->json(array(
'code' => 200,
'status' => 'success',
'message' => 'Success get list bengkel',
'data' => $response,
));
} else {
return $this->json(array(
'code' => 404,
'status' => 'failed',
'message' => 'Failed get list bengkel ',
'data' => []
));
}
}
/**
* @Route("api/customer-care/list-provider")
* @Method("GET")
*/
public function apiListProviderAction(Request $request)
{
$data = $this->apiService->getListProvider($request);
$response = [];
foreach($data->data as $value => $res){
$response[] = [
'nama' => $res->Nama,
'kota' => $res->Kota,
'provinsi' => $res->Provinsi,
'alamat' => $res->Alamat,
];
}
if ($response) {
return $this->json(array(
'code' => 200,
'status' => 'success',
'message' => 'Success get list provider',
'data' => $response,
));
} else {
return $this->json(array(
'code' => 404,
'status' => 'failed',
'message' => 'Failed get list provider ',
'data' => []
));
}
}
/**
* @Route("api/cek-polis")
* @Method("GET")
*/
public function apiCekPolisAction(Request $request)
{
$data = $this->apiService->getCekPolis($request);
if ($data) {
$response = [
'policyno' => $data->PolicyNo,
'insured' => $data->Insured,
'payment_status' => $data->PaymentStatus,
'start_date' => $data->StartDate,
'expired_date' => $data->ExpiredDate,
'field_policy_name' => $this->translator->trans('check-policy.field_policy_name'),
'field_policy_number' => $this->translator->trans('check-policy.field_policy_number'),
'field_policy_period_start' => $this->translator->trans('check-policy.field_policy_period_start'),
'field_policy_period_end' => $this->translator->trans('check-policy.field_policy_period_end'),
];
return $this->json(array(
'code' => 200,
'status' => 'success',
'message' => 'Success get polis',
'data' => $response,
));
}else{
return $this->json(array(
'code' => 404,
'status' => 'failed',
'message' => $this->translator->trans('check-policy.message_not_found'),
));
}
}
}