ruby-experian 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f6c744efbe089056cb402d802ef84639284c6195156677fa9c9613cf5452d0b
4
- data.tar.gz: 93910e87df645330255fa3ca288fc73468d579c4837e95820788cf52141a8554
3
+ metadata.gz: 0e6f48cd5cc5a1e3d6297d4e1b49e8157191baa678372334f8cb7f4421d3b016
4
+ data.tar.gz: 59ce950b92934263c1c4e3ea110c1b1279a4be4e5a28dc36d87b8b9c647040f9
5
5
  SHA512:
6
- metadata.gz: '00099d053097cd37b7ad517a2054760b78fc28e99eb31eea03b226723b05950cd79b9eccd108490518b60955de22d5d7ae7f908fb7bfc02e10ae2db52a0fcd67'
7
- data.tar.gz: 56f76810e3ae4cc15f8daeb630ce97c76e26f670dcddacec5424eae55e05fd4bf070e9f873a2f5e4f05c49d751dc7029681dffe2ce29385467ea340e2892ce56
6
+ metadata.gz: b30f7f97476e672715767b2803c217c9995a2dd01ba61bd4735432e1f67ac845e53705ecaf12fcfc10a7ab29c4c279b7ef4581ba2426dbae04aa5119878fcec9
7
+ data.tar.gz: aa97405213f53b81b01f1c9c51d0bdfeac9e40c63bdce767433de8d7e073695596fac64c7787fc194f882ffedc28be844237f2ea42832fd70a9a0cbe75c7c8b0
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.2)
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.dig("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.2".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.2
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-16 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"