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

  # GET /settings/payment_method_settings
  # GET /settings/payment_method_settings.json
  def index
    @settings_payment_method_settings = PaymentMethodSetting.all
  end

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

  # GET /settings/payment_method_settings/new
  def new
    @settings_payment_method_setting = PaymentMethodSetting.new
  end

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

  # POST /settings/payment_method_settings
  # POST /settings/payment_method_settings.json
  def create
    @settings_payment_method_setting = PaymentMethodSetting.new(settings_payment_method_setting_params)

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

  # PATCH/PUT /settings/payment_method_settings/1
  # PATCH/PUT /settings/payment_method_settings/1.json
  def update
    respond_to do |format|
      if @settings_payment_method_setting.update(settings_payment_method_setting_params)
        format.html { redirect_to settings_payment_method_setting_path(@settings_payment_method_setting), notice: 'Payment method setting was successfully updated.' }
        format.json { render :show, status: :ok, location: @settings_payment_method_setting }
      else
        format.html { render :edit }
        format.json { render json: @settings_payment_method_setting.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /settings/payment_method_settings/1
  # DELETE /settings/payment_method_settings/1.json
  def destroy
    @settings_payment_method_setting.destroy
    respond_to do |format|
      format.html { redirect_to settings_payment_method_settings_path, notice: 'Payment method 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_payment_method_setting
      @settings_payment_method_setting = PaymentMethodSetting.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def settings_payment_method_setting_params
      params.require(:payment_method_setting).permit(:payment_method, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :additional_parameters)
    end
end
