diff --git a/config/routes/apiv2.yaml b/config/routes/apiv2.yaml index e0010864..3fe9d9be 100644 --- a/config/routes/apiv2.yaml +++ b/config/routes/apiv2.yaml @@ -234,5 +234,14 @@ apiv2_customer_hash_get: # motolite events apiv2_motolite_events: path: /apiv2/motolite_events - controller: App\Controller\CustomerAppAPI\MotoliteEventController:getEvents - methods: [GET] \ No newline at end of file + controller: App\Controller\CustomerAppAPI\MotoliteEventController::getEvents + methods: [GET] + +# review tags +apiv2_partner_review_tags: + path: /apiv2/review_tags/partner + controller: App\Controller\CustomerAppAPI\ReviewTagController::getPartnerReviewTags + +apiv2_rider_review_tags: + path: /apiv2/review_tags/rider + controller: App\Controller\CustomerAppAPI\ReviewTagController::getPartnerReviewTags \ No newline at end of file diff --git a/src/Controller/CustomerAppAPI/ReviewTagController.php b/src/Controller/CustomerAppAPI/ReviewTagController.php new file mode 100644 index 00000000..76f68bef --- /dev/null +++ b/src/Controller/CustomerAppAPI/ReviewTagController.php @@ -0,0 +1,46 @@ +getTags($req, "partner"); + } + + public function getRiderReviewTags(Request $req) + { + return $this->getTags($req, "rider"); + } + + protected function getTags(Request $req, $tag_type) + { + // validate params + $validity = $this->validateRequest($req); + + if (!$validity['is_valid']) { + return new ApiResponse(false, $validity['error']); + } + + // get manufacturer list + $tags = $this->em->getRepository(ReviewTag::class)->findBy(['type' => $tag_type], ['name' => 'asc']); + $tag_list = []; + + foreach ($tags as $tag) { + $tag_list[] = [ + 'id' => $tag->getID(), + 'name' => $tag->getName(), + ]; + } + + return new ApiResponse(true, '', [ + 'tags' => $tag_list, + ]); + } +} diff --git a/src/Entity/ReviewTag.php b/src/Entity/ReviewTag.php new file mode 100644 index 00000000..577686ff --- /dev/null +++ b/src/Entity/ReviewTag.php @@ -0,0 +1,62 @@ +id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function setType($type) + { + $this->type = $type; + return $this; + } + + public function getType() + { + return $this->type; + } + +}