From 417bd3c0e1b4ef2f90edbd9a49262704d1ee1cc9 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 6 Sep 2019 07:10:54 +0000 Subject: [PATCH] Add getPrivacyPolicy to third party API. #263 --- .../api-bundle/Command/TestAPICommand.php | 4 ++ config/api_acl.yaml | 5 +++ config/routes/capi.yaml | 8 ++++ .../CAPI/PrivacyPolicyController.php | 43 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/Controller/CAPI/PrivacyPolicyController.php diff --git a/catalyst/api-bundle/Command/TestAPICommand.php b/catalyst/api-bundle/Command/TestAPICommand.php index f76a8285..bf35ce1e 100644 --- a/catalyst/api-bundle/Command/TestAPICommand.php +++ b/catalyst/api-bundle/Command/TestAPICommand.php @@ -115,5 +115,9 @@ class TestAPICommand extends Command // vehicle $api->get('/capi/vehicle_manufacturers'); $api->get('/capi/vehicles'); + + // privacy policy + $privacy_policy_id = 2; + $api->get('/capi/privacy_policy/' . $privacy_policy_id ); } } diff --git a/config/api_acl.yaml b/config/api_acl.yaml index c3834bf9..39557cf6 100644 --- a/config/api_acl.yaml +++ b/config/api_acl.yaml @@ -45,3 +45,8 @@ access_keys: acls: - id: vehicle.list label: List + - id: privacypolicy + label: Privacy Policy + acls: + - id: privacypolicy.find + label: Find Privacy Policy diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 67509914..cf533814 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -127,3 +127,11 @@ capi_cv_register: path: /capi/customer_vehicle controller: App\Controller\CAPI\CustomerVehicle::register methods: [POST] + +# privacy policy + +# get privacy policy by id +capi_privacy_policy: + path: /capi/privacy_policy/{id} + controller: App\Controller\CAPI\PrivacyPolicyController::getPrivacyPolicy + methods: [GET] diff --git a/src/Controller/CAPI/PrivacyPolicyController.php b/src/Controller/CAPI/PrivacyPolicyController.php new file mode 100644 index 00000000..034d12ff --- /dev/null +++ b/src/Controller/CAPI/PrivacyPolicyController.php @@ -0,0 +1,43 @@ +acl_gen = $acl_gen; + } + + public function getPrivacyPolicy($id, EntityManagerInterface $em) + { + $this->denyAccessUnlessGranted('privacypolicy.find', null, 'No access.'); + + $privacy_policy = $em->getRepository(PrivacyPolicy::class)->find($id); + + if ($privacy_policy == null) + return new APIResponse(false, 'No privacy policy found with that number.', null, 404); + + $data = [ + 'privacy_policy' => (string) $privacy_policy->getContent(), + ]; + + return new APIResponse(true, 'Privacy policy found.', $data); + + } +}