Sha256: c2d2d957082afa9a34f84f5c9e968150f7481ea2b61b8da1c03a6d314e83df8a

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

module Crefo
  class Configuration
    CURRENT_KEYLISTVERSION = 21
    ENDPOINTS = {
      default: 'https://onlineservice.creditreform.de:443/webservice/0600-0021/soap12/messages.wsdl',
      test: 'https://ktu.onlineservice.creditreform.de:443/webservice/0600-0021/soap12/messages.wsdl'
    }.freeze

    attr_accessor :communicationlanguage, :keylistversion, :transactionreference
    attr_accessor :clientapplicationname, :clientapplicationversion
    attr_accessor :useraccount, :generalpassword, :individualpassword, :connection_options
    attr_writer :endpoint

    def initialize
      @keylistversion = CURRENT_KEYLISTVERSION
      @communicationlanguage = 'de'
      @clientapplicationversion = Crefo::VERSION.to_i
      @connection_options = {}
      @endpoint = :default
    end

    def endpoint
      ENDPOINTS.fetch(@endpoint, @endpoint)
    end

    module Builder
      def configure(&block)
        config.tap(&block)
      end

      def config
        @configuration ||= Crefo::Configuration.new
      end

      module TestHelper
        def mock_config!(&block)
          @old_configuration = @configuration
          @configuration = @configuration.dup.tap(&block)
        end

        def unmock_config!
          @configuration = @old_configuration
        end

        def test_time
          Time.new(2014, 12, 20, 4, 44, 44, "+01:00")
        end
      end
    end
  end
  extend Configuration::Builder
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crefo-0.3.0 lib/crefo/configuration.rb