class Settings::MembershipActionsController < ApplicationController
  load_and_authorize_resource except: [:create]
  before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy]

  # GET /settings/membership_actions
  # GET /settings/membership_actions.json
  def index
        @settings_membership_actions = MembershipAction.all
  end

  # GET /settings/membership_actions/1
  # GET /settings/membership_actions/1.json
  def show
  end

  # GET /settings/membership_actions/new
  def new
    @settings_membership_action = MembershipAction.new
  end

  # GET /settings/membership_actions/1/edit
  def edit
  end

  # POST /settings/membership_actions
  # POST /settings/membership_actions.json
  def create
    @settings_membership_action = MembershipAction.new(settings_membership_action_params)

    respond_to do |format|
      if @settings_membership_action.save
        format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' }
        format.json { render :show, status: :created, location: @settings_membership_action }
      else
        format.html { render :new }
        format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /settings/membership_actions/1
  # PATCH/PUT /settings/membership_actions/1.json
  def update
    respond_to do |format|
      if @settings_membership_action.update(settings_membership_action_params)
        format.html { redirect_to settings_membership_action_path, notice: 'Membership action was successfully updated.' }
        format.json { render :show, status: :ok, location: @settings_membership_action }
      else
        format.html { render :edit }
        format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /settings/membership_actions/1
  # DELETE /settings/membership_actions/1.json
  def destroy
    @settings_membership_action.destroy
    respond_to do |format|
      format.html { redirect_to settings_membership_actions_url, notice: 'Membership action was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_settings_membership_action
      @settings_membership_action = MembershipAction.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def settings_membership_action_params
      params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter)
    end
end
