Class: Experian::Report
- Inherits:
-
Object
- Object
- Experian::Report
- Defined in:
- lib/experian/report.rb
Instance Attribute Summary collapse
-
#raw_xml ⇒ Object
readonly
Returns the value of attribute raw_xml.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #address ⇒ Object
- #cnae ⇒ Object
- #id ⇒ Object
-
#initialize(response) ⇒ Report
constructor
A new instance of Report.
-
#number_of_employees ⇒ Object
Number of employees in the last recorded excercise.
- #rating ⇒ Object
Constructor Details
#initialize(response) ⇒ Report
Returns a new instance of Report.
8 9 10 11 12 13 14 15 16 |
# File 'lib/experian/report.rb', line 8 def initialize(response) @response = response @url = response.env.url.to_s @raw_xml = response.body MultiXml.parser = :rexml @xml = MultiXml.parse(@raw_xml) raise Experian::AuthenticationError if authentication_error? end |
Instance Attribute Details
#raw_xml ⇒ Object (readonly)
Returns the value of attribute raw_xml.
6 7 8 |
# File 'lib/experian/report.rb', line 6 def raw_xml @raw_xml end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/experian/report.rb', line 6 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/experian/report.rb', line 6 def url @url end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
6 7 8 |
# File 'lib/experian/report.rb', line 6 def xml @xml end |
Instance Method Details
#address ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/experian/report.rb', line 30 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 |
#cnae ⇒ Object
60 61 62 |
# File 'lib/experian/report.rb', line 60 def cnae data.dig("ActividadComercial", "Cnae")&.first&.dig("Codigo")&.to_i end |
#id ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/experian/report.rb', line 18 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 |
#number_of_employees ⇒ Object
Number of employees in the last recorded excercise
43 44 45 |
# File 'lib/experian/report.rb', line 43 def number_of_employees data.dig("ListaAnualEmpleados", "Empleado")&.first&.dig("EmpleadoFijo")&.to_i end |
#rating ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/experian/report.rb', line 47 def if ( = data["Rating"]) return unless ["RatingAxesorDef"] OpenStruct.new( score: ["RatingAxesorDef"]&.strip&.to_i, default_probability: ["ProbImpago"]&.to_f, risk: ["GrupoRiesgo"], size: ["Tamaño"], ) end end |