ruby-experian 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f6c744efbe089056cb402d802ef84639284c6195156677fa9c9613cf5452d0b
4
- data.tar.gz: 93910e87df645330255fa3ca288fc73468d579c4837e95820788cf52141a8554
3
+ metadata.gz: 49f72214cb1be783e88337a4252fe8f43bae3094264009d8cb320ff6d16af3f6
4
+ data.tar.gz: f960aa5170a197c7094d69ec4249ce789197e835183cdd8b1f2182d84732e2ee
5
5
  SHA512:
6
- metadata.gz: '00099d053097cd37b7ad517a2054760b78fc28e99eb31eea03b226723b05950cd79b9eccd108490518b60955de22d5d7ae7f908fb7bfc02e10ae2db52a0fcd67'
7
- data.tar.gz: 56f76810e3ae4cc15f8daeb630ce97c76e26f670dcddacec5424eae55e05fd4bf070e9f873a2f5e4f05c49d751dc7029681dffe2ce29385467ea340e2892ce56
6
+ metadata.gz: 2a04cc506991c122892e4c53fc298cf9dfb710a993b426e3b5f225a624b45a2c785cb3eb719980355e0e0cbc3e41c329afe65d2946b78d3c61b81d5557b188e2
7
+ data.tar.gz: 68b312e16f9125b563cb862521b6473d135b610d5f95dd9620075fb46036e41acedd1d7af102e1d5c07eeaa79e5473f023f3040a82b0bd653aac38092a7657b9
data/.env.test ADDED
File without changes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-experian (0.1.0)
4
+ ruby-experian (0.1.1)
5
5
  faraday (>= 1)
6
6
  multi_xml (>= 0.6.0)
7
7
  rexml (>= 3.2)
data/README.md CHANGED
@@ -61,6 +61,8 @@ Experian.configure do |config|
61
61
  end
62
62
  ```
63
63
 
64
+ By default, this gem will look for the environment variables `EXPERIAN_USER_CODE` and `EXPERIAN_PASSWORD` to set the default values for user code and password.
65
+
64
66
  Then you can create a client like this:
65
67
 
66
68
  ```ruby
@@ -122,9 +124,9 @@ You can further configure the faraday connection by passing in a block to the cl
122
124
  end
123
125
  ```
124
126
 
125
- ### Report
127
+ ### Credit Report
126
128
 
127
- You can hit the report api to get the 360 credit report from Experian by passing in a CIF to the call. Note that only some sections of the report are exposed. Other sections will be exposed as needed / requested.
129
+ You can hit the credit report api to get the 360 credit report from Experian by passing in a CIF to the call. Note that only some sections of the report are exposed. Other sections will be exposed as needed / requested.
128
130
 
129
131
  The exposed sections for now are:
130
132
 
@@ -133,9 +135,29 @@ The exposed sections for now are:
133
135
  - rating
134
136
  - number_of_employees
135
137
  - cnae
138
+ - constitution_date
139
+
140
+ ```ruby
141
+ report = client.credit_report(cif: "cif goes here")
142
+ report.rating.inspect
143
+ # => "#<OpenStruct score=8, default_probability=0.529, risk=\"Mínimo\", size=\"Grande\">"
144
+ ```
145
+
146
+ ### Trade Report
147
+
148
+ You can hit the trade report api to get the 360 trade report from Experian by passing in a CIF to the call. Note that only some sections of the report are exposed. Other sections will be exposed as needed / requested.
149
+
150
+ The exposed sections for now are:
151
+
152
+ - model_200(period:)
153
+ - address
154
+ - rating
155
+ - most_recent_number_of_employees
156
+ - cnae
157
+ - constitution_date
136
158
 
137
159
  ```ruby
138
- report = client.report(cif: "cif goes here")
160
+ report = client.trade_report(cif: "cif goes here")
139
161
  report.rating.inspect
140
162
  # => "#<OpenStruct score=8, default_probability=0.529, risk=\"Mínimo\", size=\"Grande\">"
141
163
  ```
data/bin/console CHANGED
@@ -4,6 +4,7 @@ require "bundler/setup"
4
4
  require "experian"
5
5
  require "pry"
6
6
  require "pry-byebug"
7
+ require "dotenv/load"
7
8
 
8
9
  # You can add fixtures and/or initialization code here to make experimenting
9
10
  # with your gem easier. You can also use a different console, if you like.
@@ -38,6 +38,44 @@ module Experian
38
38
  }
39
39
  end
40
40
 
41
+ def constitution_date
42
+ date = data.dig("SeccionDatosRegistrales", "FechaConstitucion")
43
+ date && Date.parse(date)
44
+ end
45
+
46
+ def address
47
+ if (address_xml = data["SeccionDatosRegistrales"]["DomicilioSocial"])
48
+ OpenStruct.new(
49
+ line: address_xml["Domicilio"],
50
+ city: address_xml["Poblacion"] || address_xml["Provincia"],
51
+ province: address_xml["Provincia"],
52
+ postal_code: address_xml["CodigoPostal"],
53
+ municipality: address_xml["Municipio"],
54
+ )
55
+ end
56
+ end
57
+
58
+ def most_recent_number_of_employees
59
+ data.dig("ListaAnualEmpleados", "Empleado").first&.dig("EmpleadoFijo")&.to_i
60
+ end
61
+
62
+ def cnae
63
+ data.dig("ActividadComercial", "Cnae")&.first&.dig("Codigo")&.to_i
64
+ end
65
+
66
+ def rating
67
+ if (rating_xml = data["Rating"])
68
+ return unless rating_xml["RatingAxesorDef"]
69
+
70
+ OpenStruct.new(
71
+ score: rating_xml["RatingAxesorDef"]&.strip&.to_i,
72
+ default_probability: rating_xml["ProbImpago"]&.to_f,
73
+ risk: rating_xml["GrupoRiesgo"],
74
+ size: rating_xml["Tamaño"],
75
+ )
76
+ end
77
+ end
78
+
41
79
  private
42
80
 
43
81
  def last_submitted_year
@@ -1,3 +1,3 @@
1
1
  module Experian
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
data/lib/experian.rb CHANGED
@@ -21,8 +21,8 @@ module Experian
21
21
  DEFAULT_REQUEST_TIMEOUT = 120
22
22
 
23
23
  def initialize
24
- @user_code = nil
25
- @password = nil
24
+ @user_code = ENV.fetch("EXPERIAN_USER_CODE", nil)
25
+ @password = ENV.fetch("EXPERIAN_PASSWORD", nil)
26
26
  @version = DEFAULT_VERSION
27
27
  @request_timeout = DEFAULT_REQUEST_TIMEOUT
28
28
  @base_uri = DEFAULT_BASE_URI
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.1.0
4
+ version: 0.1.1
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-05-28 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -75,6 +75,7 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
+ - ".env.test"
78
79
  - ".github/dependabot.yml"
79
80
  - ".github/pull_request_template.md"
80
81
  - ".github/workflows/tests.yml"