module Idv
  module Steps
    class DocAuthBaseStep < Flow::BaseStep
      def initialize(context)
        @assure_id = nil
        super(context, :doc_auth)
      end

      private

      def image
        flow_params[:image]
      end

      def assure_id
        @assure_id ||= new_assure_id
        @assure_id.instance_id = flow_session[:instance_id]
        @assure_id
      end

      def new_assure_id
        klass = simulate? ? Idv::Acuant::FakeAssureId : Idv::Acuant::AssureId
        klass.new
      end

      def simulate?
        Figaro.env.acuant_simulator == 'true'
      end

      delegate :idv_session, to: :@context
    end
  end
end
