class CardProvidersController < ApplicationController
  before_action :set_card_provider, only: %i[ show edit update destroy ]

  # GET /card_providers or /card_providers.json
  def index
    @card_providers = CardProvider.all
  end

  # GET /card_providers/1 or /card_providers/1.json
  def show
  end

  # GET /card_providers/new
  def new
    @card_provider = CardProvider.new
  end

  # GET /card_providers/1/edit
  def edit
  end

  # POST /card_providers or /card_providers.json
  def create
    @card_provider = CardProvider.new(card_provider_params)

    respond_to do |format|
      if @card_provider.save
        format.html { redirect_to @card_provider, notice: "Card provider was successfully created." }
        format.json { render :show, status: :created, location: @card_provider }
      else
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @card_provider.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /card_providers/1 or /card_providers/1.json
  def update
    respond_to do |format|
      if @card_provider.update(card_provider_params)
        format.html { redirect_to @card_provider, notice: "Card provider was successfully updated.", status: :see_other }
        format.json { render :show, status: :ok, location: @card_provider }
      else
        format.html { render :edit, status: :unprocessable_entity }
        format.json { render json: @card_provider.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /card_providers/1 or /card_providers/1.json
  def destroy
    @card_provider.destroy!

    respond_to do |format|
      format.html { redirect_to card_providers_path, notice: "Card provider was successfully destroyed.", status: :see_other }
      format.json { head :no_content }
    end
  end

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

    # Only allow a list of trusted parameters through.
    def card_provider_params
      params.require(:card_provider).permit(:provider_code, :provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :mail_to, :mail_to_2, :contact_line_1, :contact_line_2, :contact_line_3, :group_number, :claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6, :claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :provider_line_6, :provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :rx_group_id, :rx_contact, :provider_lookup_1, :provider_lookup_2, :precert_1, :precert_2, :precert_3, :precert_4, :precert_5, :precert_6, :provider_line_12, :claim_to_12)
    end
end
