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

  # GET /settings/membership_settings
  # GET /settings/membership_settings.json
  def index
    @settings_membership_settings = MembershipSetting.all
  end

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

  # GET /settings/membership_settings/new
  def new
    @settings_membership_setting = MembershipSetting.new
  end

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

  # POST /settings/membership_settings
  # POST /settings/membership_settings.json
  def create
    @settings_membership_setting = MembershipSetting.new(settings_membership_setting_params)

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

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

  # DELETE /settings/membership_settings/1
  # DELETE /settings/membership_settings/1.json
  def destroy
    @settings_membership_setting.destroy
    respond_to do |format|
      format.html { redirect_to settings_membership_settings_path, notice: 'Membership setting 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_setting
      @settings_membership_setting = MembershipSetting.find(params[:id])
    end

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