module Mks module Rate class ServiceDeliveryUnitsController < ApplicationController before_action :set_service_delivery_unit, only: [:update] def index result = ServiceDeliveryUnit.all render json: result end def create sdu = ServiceDeliveryUnit.new(service_delivery_unit_params) if sdu.save render json: Mks::Common::MethodResponse.success_response(sdu, 'Service delivery unit saved successfully !') else render json: Mks::Common::MethodResponse.failure_response(sdu), status: :unprocessable_entity end end def update if @sdu.update(service_delivery_unit_params) render json: Mks::Common::MethodResponse.success_response(@sdu, 'Service delivery unit updated successfully !') else render json: Mks::Common::MethodResponse.failure_response(@sdu), status: :unprocessable_entity end end private def service_delivery_unit_params params.require(:service_delivery_unit).permit(:id, :code, :name, :address) end def set_service_delivery_unit @sdu = ServiceDeliveryUnit.find(params[:id]) end end end end