Sha256: be841b8a08f2a4d1aea31aff62a29e7ef0f4b6a62569f3917cce3af8d2a70307

Contents?: true

Size: 771 Bytes

Versions: 7

Compression:

Stored size: 771 Bytes

Contents

module Experian
  class Client
    include Experian::HTTP

    CONFIG_KEYS = %i[
      user_code password request_timeout base_uri extra_headers
    ].freeze
    attr_reader(*CONFIG_KEYS, :faraday_middleware)

    def initialize(config = {}, &faraday_middleware)
      CONFIG_KEYS.each do |key|
        # Set instance variables like api_type & access_token. Fall back to global config
        # if not present.
        instance_variable_set("@#{key}", config[key] || Experian.configuration.send(key))
      end
      @faraday_middleware = faraday_middleware
    end

    def report(cif:, format: :xml)
      response = get(path: "/informe", format:, cif:, cod_servicio: 57)

      return Experian::Report.new(response) if format == :xml

      response
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-experian-0.0.7 lib/experian/client.rb
ruby-experian-0.0.6 lib/experian/client.rb
ruby-experian-0.0.5 lib/experian/client.rb
ruby-experian-0.0.4 lib/experian/client.rb
ruby-experian-0.0.3 lib/experian/client.rb
ruby-experian-0.0.2 lib/experian/client.rb
ruby-experian-0.0.1 lib/experian/client.rb