ruby-experian 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -24
- data/lib/experian/client.rb +25 -3
- data/lib/experian/credit_report.rb +57 -0
- data/lib/experian/report.rb +11 -43
- data/lib/experian/trade_report.rb +56 -0
- data/lib/experian/version.rb +1 -1
- data/lib/experian.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04ddcec7c703945c2b63eba47acdcfb84ee3a09a851ffbf527d7f790f443b0a8
|
4
|
+
data.tar.gz: 28c7e6edeefed2f402092a6e556e80944a6a20ed84efa57231fe2d84f5c8d70a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73af74282469e11505a92dde059eac50d225c627bc788a8ab20d7d113ec118061bb3c1e4722c8059dc0d689fdeddb543912f14a0e34b9d48b1c68c026d72307d
|
7
|
+
data.tar.gz: 6d86f7ef7e91008a09bf5b8fc723ad89ea230acc4aa767f24a33dc52035b9319dad79a85b7cc4653d9bee2655acf47ff0167f9b2df04fcf1574a16aae069f86f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-experian (0.0.
|
4
|
+
ruby-experian (0.0.9)
|
5
5
|
faraday (>= 1)
|
6
6
|
multi_xml (>= 0.6.0)
|
7
7
|
rexml (>= 3.2)
|
@@ -13,6 +13,7 @@ GEM
|
|
13
13
|
addressable (2.8.6)
|
14
14
|
public_suffix (>= 2.0.2, < 6.0)
|
15
15
|
ast (2.4.2)
|
16
|
+
base64 (0.2.0)
|
16
17
|
bigdecimal (3.1.6)
|
17
18
|
binding_of_caller (1.0.0)
|
18
19
|
debug_inspector (>= 0.0.1)
|
@@ -25,35 +26,16 @@ GEM
|
|
25
26
|
diff-lcs (1.5.1)
|
26
27
|
docile (1.4.0)
|
27
28
|
dotenv (2.8.1)
|
28
|
-
faraday (
|
29
|
-
|
30
|
-
faraday-
|
31
|
-
faraday-excon (~> 1.1)
|
32
|
-
faraday-httpclient (~> 1.0)
|
33
|
-
faraday-multipart (~> 1.0)
|
34
|
-
faraday-net_http (~> 1.0)
|
35
|
-
faraday-net_http_persistent (~> 1.0)
|
36
|
-
faraday-patron (~> 1.0)
|
37
|
-
faraday-rack (~> 1.0)
|
38
|
-
faraday-retry (~> 1.0)
|
29
|
+
faraday (2.8.1)
|
30
|
+
base64
|
31
|
+
faraday-net_http (>= 2.0, < 3.1)
|
39
32
|
ruby2_keywords (>= 0.0.4)
|
40
|
-
faraday-
|
41
|
-
faraday-em_synchrony (1.0.0)
|
42
|
-
faraday-excon (1.1.0)
|
43
|
-
faraday-httpclient (1.0.1)
|
44
|
-
faraday-multipart (1.0.4)
|
45
|
-
multipart-post (~> 2)
|
46
|
-
faraday-net_http (1.0.1)
|
47
|
-
faraday-net_http_persistent (1.2.0)
|
48
|
-
faraday-patron (1.0.0)
|
49
|
-
faraday-rack (1.0.0)
|
50
|
-
faraday-retry (1.0.3)
|
33
|
+
faraday-net_http (3.0.2)
|
51
34
|
hashdiff (1.1.0)
|
52
35
|
interception (0.5)
|
53
36
|
json (2.7.1)
|
54
37
|
method_source (1.0.0)
|
55
38
|
multi_xml (0.6.0)
|
56
|
-
multipart-post (2.3.0)
|
57
39
|
parallel (1.24.0)
|
58
40
|
parser (3.2.2.4)
|
59
41
|
ast (~> 2.4.1)
|
data/lib/experian/client.rb
CHANGED
@@ -2,6 +2,9 @@ module Experian
|
|
2
2
|
class Client
|
3
3
|
include Experian::HTTP
|
4
4
|
|
5
|
+
TRADE_REPORT = 388
|
6
|
+
CREDIT_REPORT = 57
|
7
|
+
|
5
8
|
CONFIG_KEYS = %i[
|
6
9
|
user_code password request_timeout base_uri extra_headers
|
7
10
|
].freeze
|
@@ -16,10 +19,29 @@ module Experian
|
|
16
19
|
@faraday_middleware = faraday_middleware
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
20
|
-
response = get(
|
22
|
+
def credit_report(cif:, format: :xml, as_response: false)
|
23
|
+
response = get(
|
24
|
+
path: "/informe",
|
25
|
+
format:,
|
26
|
+
cif:,
|
27
|
+
cod_servicio: CREDIT_REPORT
|
28
|
+
)
|
29
|
+
|
30
|
+
return Experian::CreditReport.new(response) if format == :xml && !as_response
|
31
|
+
|
32
|
+
response
|
33
|
+
end
|
34
|
+
|
35
|
+
def trade_report(cif:, format: :xml, request_update: true, as_response: false)
|
36
|
+
response = get(
|
37
|
+
path: "/informe",
|
38
|
+
format:,
|
39
|
+
cif:,
|
40
|
+
garantizar_bajo_demanda: request_update ? 1 : 0,
|
41
|
+
cod_servicio: TRADE_REPORT,
|
42
|
+
)
|
21
43
|
|
22
|
-
return Experian::
|
44
|
+
return Experian::TradeReport.new(response) if format == :xml && !as_response
|
23
45
|
|
24
46
|
response
|
25
47
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "multi_xml"
|
2
|
+
require "rexml"
|
3
|
+
|
4
|
+
module Experian
|
5
|
+
class CreditReport < Report
|
6
|
+
def id
|
7
|
+
if (id_xml = data["DatosIdentificativos"])
|
8
|
+
OpenStruct.new(
|
9
|
+
cif: id_xml["Cif"],
|
10
|
+
name: id_xml["Nombre"],
|
11
|
+
infotel_code: id_xml["CodigoInfotel"],
|
12
|
+
incorporation_date: Date.parse(id_xml["FechaFundacion"]),
|
13
|
+
social_form: id_xml["FormaSocial"]["__content__"],
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def address
|
19
|
+
if (address_xml = data["DomicilioComercial"])
|
20
|
+
OpenStruct.new(
|
21
|
+
line: address_xml["Domicilio"],
|
22
|
+
city: address_xml["Poblacion"],
|
23
|
+
province: address_xml["Provincia"],
|
24
|
+
postal_code: address_xml["CodigoPostal"],
|
25
|
+
municipality: address_xml["Municipio"],
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Number of employees in the last recorded excercise
|
31
|
+
def number_of_employees
|
32
|
+
data.dig("ListaAnualEmpleados", "Empleado")&.first&.dig("EmpleadoFijo")&.to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def rating
|
36
|
+
if (rating_xml = data["Rating"])
|
37
|
+
return unless rating_xml["RatingAxesorDef"]
|
38
|
+
|
39
|
+
OpenStruct.new(
|
40
|
+
score: rating_xml["RatingAxesorDef"]&.strip&.to_i,
|
41
|
+
default_probability: rating_xml["ProbImpago"]&.to_f,
|
42
|
+
risk: rating_xml["GrupoRiesgo"],
|
43
|
+
size: rating_xml["Tamaño"],
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def cnae
|
49
|
+
data.dig("ActividadComercial", "Cnae")&.first&.dig("Codigo")&.to_i
|
50
|
+
end
|
51
|
+
|
52
|
+
def constitution_date
|
53
|
+
date = data.dig("DatosConstitutivos", "FechaConstitucion")
|
54
|
+
date && Date.parse(date)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/experian/report.rb
CHANGED
@@ -12,59 +12,27 @@ module Experian
|
|
12
12
|
MultiXml.parser = :rexml
|
13
13
|
@xml = MultiXml.parse(@raw_xml)
|
14
14
|
|
15
|
-
raise
|
15
|
+
raise error, error_message if error
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
if (id_xml = data["DatosIdentificativos"])
|
20
|
-
OpenStruct.new(
|
21
|
-
cif: id_xml["Cif"],
|
22
|
-
name: id_xml["Nombre"],
|
23
|
-
infotel_code: id_xml["CodigoInfotel"],
|
24
|
-
incorporation_date: Date.parse(id_xml["FechaFundacion"]),
|
25
|
-
social_form: id_xml["FormaSocial"]["__content__"],
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def address
|
31
|
-
if (address_xml = data["DomicilioComercial"])
|
32
|
-
OpenStruct.new(
|
33
|
-
line: address_xml["Domicilio"],
|
34
|
-
city: address_xml["Poblacion"],
|
35
|
-
province: address_xml["Provincia"],
|
36
|
-
postal_code: address_xml["CodigoPostal"],
|
37
|
-
municipality: address_xml["Municipio"],
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
18
|
+
protected
|
41
19
|
|
42
|
-
|
43
|
-
|
44
|
-
data.dig("ListaAnualEmpleados", "Empleado")&.first&.dig("EmpleadoFijo")&.to_i
|
20
|
+
def data
|
21
|
+
xml.dig("ServicioWebAxesor", "ListaPaquetesNegocio")
|
45
22
|
end
|
46
23
|
|
47
|
-
def
|
48
|
-
|
49
|
-
return unless rating_xml["RatingAxesorDef"]
|
24
|
+
def error
|
25
|
+
return Experian::AuthenticationError if authentication_error?
|
50
26
|
|
51
|
-
|
52
|
-
score: rating_xml["RatingAxesorDef"]&.strip&.to_i,
|
53
|
-
default_probability: rating_xml["ProbImpago"]&.to_f,
|
54
|
-
risk: rating_xml["GrupoRiesgo"],
|
55
|
-
size: rating_xml["Tamaño"],
|
56
|
-
)
|
57
|
-
end
|
27
|
+
Experian::Error if any_other_error?
|
58
28
|
end
|
59
29
|
|
60
|
-
def
|
61
|
-
|
30
|
+
def error_message
|
31
|
+
xml.dig("DatosError", "DesError")
|
62
32
|
end
|
63
33
|
|
64
|
-
|
65
|
-
|
66
|
-
def data
|
67
|
-
xml.dig("ServicioWebAxesor", "ListaPaquetesNegocio")
|
34
|
+
def any_other_error?
|
35
|
+
xml.dig("DatosError", "CodError")
|
68
36
|
end
|
69
37
|
|
70
38
|
def authentication_error?
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Experian
|
2
|
+
class TradeReport < Report
|
3
|
+
def model_200(period: last_submitted_year)
|
4
|
+
{
|
5
|
+
# Balance Sheet - Assets
|
6
|
+
"00101" => financial_data("Activo", "11000", period:), # ACTIVO NO CORRIENTE
|
7
|
+
"00102" => financial_data("Activo", "11100", period:), # Inmovilizado intangible
|
8
|
+
"00136" => financial_data("Activo", "12000", period:), # ACTIVO CORRIENTE
|
9
|
+
"00138" => financial_data("Activo", "12200", period:), # Existencias
|
10
|
+
"00149" => financial_data("Activo", "12300", period:), # Deudores comerciales y otras cuentas a cobrar
|
11
|
+
"00177" => financial_data("Activo", "12700", period:), # Efectivo y otros activos líquidos equivalentes
|
12
|
+
"00180" => financial_data("Activo", "10000", period:), # TOTAL ACTIVO
|
13
|
+
|
14
|
+
# Balance Sheet - Liabilities
|
15
|
+
"00185" => financial_data("Pasivo", "20000", period:), # PATRIMONIO NETO
|
16
|
+
"00210" => financial_data("Pasivo", "31000", period:), # PASIVO NO CORRIENTE
|
17
|
+
"00216" => financial_data("Pasivo", "31200", period:), # Deudas a largo plazo
|
18
|
+
"00228" => financial_data("Pasivo", "32000", period:), # PASIVO CORRIENTE
|
19
|
+
"00231" => financial_data("Pasivo", "32300", period:), # Deudas a corto plazo
|
20
|
+
"00239" => financial_data("Pasivo", "32500", period:), # Acreedores comerciales y otras cuentas a pagar
|
21
|
+
|
22
|
+
# P&L
|
23
|
+
"00255" => financial_data("PerdidasGanancias", "40100", period:), # Importe neto de la cifra de negocios
|
24
|
+
"00260" => financial_data("PerdidasGanancias", "40400", period:), # Aprovisionamientos
|
25
|
+
"00265" => financial_data("PerdidasGanancias", "40500", period:), # Otros ingresos de explotación
|
26
|
+
"00284" => financial_data("PerdidasGanancias", "40800", period:), # Amortización del inmovilizado
|
27
|
+
"00285" => financial_data("PerdidasGanancias", "40900", period:), # Imputación de subvenciones de inmovilizado no financiero y otras
|
28
|
+
"00286" => financial_data("PerdidasGanancias", "41000", period:), # Excesos de provisiones
|
29
|
+
"00287" => financial_data("PerdidasGanancias", "41100", period:), # Deterioro y resultado por enajenaciones del inmovilizad
|
30
|
+
"00295" => financial_data("PerdidasGanancias", "41300", period:), # Otros resultados
|
31
|
+
"00296" => financial_data("PerdidasGanancias", "49100", period:), # Resultado de explotacion
|
32
|
+
"00305" => financial_data("PerdidasGanancias", "41500", period:), # Gastos Financieros
|
33
|
+
"00326" => financial_data("PerdidasGanancias", "41900", period:), # Impuestos Sobre Beneficios
|
34
|
+
"00327" => financial_data("PerdidasGanancias", "49500", period:), # RESULTADO DEL EJERCICIO PROCEDENTE DE OPERACIONES CONTINUADAS
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def last_submitted_year
|
41
|
+
(Date.today << 18).year
|
42
|
+
end
|
43
|
+
|
44
|
+
def financial_data(section_name, value_name, period:)
|
45
|
+
value_section = section(section_name)
|
46
|
+
|
47
|
+
if value_name
|
48
|
+
value_section&.find { |d| d["Tipo"] == value_name }&.dig("ListaValores", "Valor")&.find { |v| v["Periodo"] == period.to_s }&.dig("Individual")&.to_i
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def section(section_name)
|
53
|
+
data.dig("InformeEconomicoFinanciero")&.first&.dig("ListaGrupos", "Grupo").find { |d| d["Tipo"][section_name] }&.dig("ListaColumnas", "Columna", "ListaDatos", "Dato")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/experian/version.rb
CHANGED
data/lib/experian.rb
CHANGED
@@ -4,6 +4,8 @@ require_relative "experian/http"
|
|
4
4
|
require_relative "experian/client"
|
5
5
|
require_relative "experian/version"
|
6
6
|
require_relative "experian/report"
|
7
|
+
require_relative "experian/credit_report"
|
8
|
+
require_relative "experian/trade_report"
|
7
9
|
|
8
10
|
module Experian
|
9
11
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-experian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Mochetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -92,8 +92,10 @@ files:
|
|
92
92
|
- bin/setup
|
93
93
|
- lib/experian.rb
|
94
94
|
- lib/experian/client.rb
|
95
|
+
- lib/experian/credit_report.rb
|
95
96
|
- lib/experian/http.rb
|
96
97
|
- lib/experian/report.rb
|
98
|
+
- lib/experian/trade_report.rb
|
97
99
|
- lib/experian/version.rb
|
98
100
|
- lib/ruby/experian.rb
|
99
101
|
- ruby-experian.gemspec
|