Sha256: 65a498db1831d109835970fdc435ff2627a7c20264447e1983098e9e2db9f8c2

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require "multi_xml"
require "rexml"

module Experian
  class CreditReport < Report
    def id
      if (id_xml = data["DatosIdentificativos"])
        OpenStruct.new(
          cif: id_xml["Cif"],
          name: id_xml["Nombre"],
          infotel_code: id_xml["CodigoInfotel"],
          incorporation_date: Date.parse(id_xml["FechaFundacion"]),
          social_form: id_xml["FormaSocial"]["__content__"],
        )
      end
    end

    def address
      if (address_xml = data["DomicilioComercial"])
        OpenStruct.new(
          line: address_xml["Domicilio"],
          city: address_xml["Poblacion"],
          province: address_xml["Provincia"],
          postal_code: address_xml["CodigoPostal"],
          municipality: address_xml["Municipio"],
        )
      end
    end

    # Number of employees in the last recorded excercise
    def number_of_employees
      data.dig("ListaAnualEmpleados", "Empleado")&.first&.dig("EmpleadoFijo")&.to_i
    end

    def rating
      if (rating_xml = data["Rating"])
        return unless rating_xml["RatingAxesorDef"]

        OpenStruct.new(
          score: rating_xml["RatingAxesorDef"]&.strip&.to_i,
          default_probability: rating_xml["ProbImpago"]&.to_f,
          risk: rating_xml["GrupoRiesgo"],
          size: rating_xml["TamaƱo"],
        )
      end
    end

    def cnae
      data.dig("ActividadComercial", "Cnae")&.first&.dig("Codigo")&.to_i
    end

    def constitution_date
      date = data.dig("DatosConstitutivos", "FechaConstitucion")
      date && Date.parse(date)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-experian-0.1.3 lib/experian/credit_report.rb
ruby-experian-0.1.2 lib/experian/credit_report.rb
ruby-experian-0.1.1 lib/experian/credit_report.rb
ruby-experian-0.0.9 lib/experian/credit_report.rb
ruby-experian-0.0.8 lib/experian/credit_report.rb