From bc826f73a1f063c6f24edc3b99975b48edaef1f0 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 2 Oct 2019 01:44:00 +0100 Subject: [PATCH] Add temporary placeholder for API endpoint --- app/controllers/api/order_cycles_controller.rb | 14 ++++++++++++++ config/routes/api.rb | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 app/controllers/api/order_cycles_controller.rb diff --git a/app/controllers/api/order_cycles_controller.rb b/app/controllers/api/order_cycles_controller.rb new file mode 100644 index 0000000000..43e17f5745 --- /dev/null +++ b/app/controllers/api/order_cycles_controller.rb @@ -0,0 +1,14 @@ +module Api + class OrderCyclesController < BaseController + respond_to :json + + def products + products = OpenFoodNetwork::ProductsRenderer.new(current_distributor, current_order_cycle, params).products_json + # products = ::ProductsFilterer.new(current_distributor, current_customer, products_json).call # TBD + + render json: products + rescue OpenFoodNetwork::ProductsRenderer::NoProducts + render status: :not_found, json: '' + end + end +end diff --git a/config/routes/api.rb b/config/routes/api.rb index 94b9e180f0..c46a4abd76 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -44,6 +44,8 @@ Openfoodnetwork::Application.routes.draw do resources :order_cycles do get :managed, on: :collection get :accessible, on: :collection + + get :products, on: :member end resource :status do