Sha256: 13d95edf09ceb864c800e36b87166267c36c2bdff36ea1bf32f42562de529651

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require "faraday"

require_relative "experian/http"
require_relative "experian/client"
require_relative "experian/version"
require_relative "experian/report"
require_relative "experian/credit_report"
require_relative "experian/trade_report"

module Experian
  class Error < StandardError; end
  class AuthenticationError < Error; end
  class ConfigurationError < Error; end

  class Configuration
    attr_writer :user_code, :password, :version, :request_timeout, :base_uri, :extra_headers
    attr_reader :base_uri, :request_timeout, :version, :extra_headers

    DEFAULT_BASE_URI = "https://informes.axesor.es".freeze
    DEFAULT_VERSION = "9.0".freeze
    DEFAULT_REQUEST_TIMEOUT = 120

    def initialize
      @user_code = nil
      @password = nil
      @version = DEFAULT_VERSION
      @request_timeout = DEFAULT_REQUEST_TIMEOUT
      @base_uri = DEFAULT_BASE_URI
      @extra_headers = {}
    end

    def user_code
      return @user_code if @user_code
      raise ConfigurationError, "Experian user_code missing!"
    end

    def password
      return @password if @password
      raise ConfigurationError, "Experian password missing!"
    end
  end

  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Experian::Configuration.new
  end

  def self.configure
    yield(configuration)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-experian-0.0.9 lib/experian.rb
ruby-experian-0.0.8 lib/experian.rb