Create APIResponse class for responses from api bundle #164

This commit is contained in:
Kendrick Chan 2018-10-24 21:13:23 +08:00
parent 005f5091af
commit 4309fea954
4 changed files with 82 additions and 15 deletions

View file

@ -0,0 +1,20 @@
<?php
namespace Catalyst\APIBundle\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
class APIResponse extends JsonResponse
{
public function __construct($success = true, $message = '', $data = null, $status = 200, $headers = [])
{
$data = [
'success' => (bool) $success,
'message' => (string) $message,
'data' => $data,
];
parent::__construct($data, $status, $headers);
}
}

View file

@ -1,9 +0,0 @@
<?php
namespace Catalyst\APIBundle\Response;
class Response
{
}

View file

@ -1,6 +0,0 @@
# api test
api_test_test:
path: /capi/test
controller: App\Controller\APITestController::test

View file

@ -0,0 +1,62 @@
# api test
capi_test:
path: /capi/test
controller: App\Controller\CAPI\TestController::test
# battery api
# find battery
capi_battery_find:
path: /capi/battery/{id}
controller: App\Controller\CAPI\BatteryController::find
methods: [GET]
# search battery
capi_battery_search:
path: /capi/battery/search
controller: App\Controller\CAPI\BatteryController::search
methods: [GET]
# warranty api
# check warranty by serial
capi_warranty_find:
path: /capi/warranty/{serial}
controller: App\Controller\CAPI\WarrantyController::find
methods: [GET]
# register battery
capi_warranty_register:
path: /capi/warranty
controller: App\Controller\CAPI\WarrantyController::register
methods: [POST]
# claim warranty
capi_warranty_claim:
path: /capi/warranty/{serial}
controller: App\Controller\CAPI\WarrantyController::claim
methods: [POST]
# customer vehicle api
# find customer vehicle by id
capi_cv_find_by_id:
path: /capi/customer_vehicle/id/{id}
controller: App\Controller\::findByID
methods: [GET]
# find customer vehicle by plate
capi_cv_find_by_plate:
path: /capi/customer_vehicle/plate/{plate}
controller: App\Controller\CAPI\CustomerVehicle::findByPlate
methods: [GET]
# register customer vehicle
capi_cv_register:
path: /capi/customer_vehicle
controller: App\Controller\CAPI\CustomerVehicle::register
methods: [POST]