ruby-experian 0.0.4 → 0.0.6
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 +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +45 -26
- data/README.md +5 -5
- data/lib/experian/http.rb +3 -66
- data/lib/experian/version.rb +1 -1
- data/lib/experian.rb +0 -17
- data/ruby-experian.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 041bb49fb2e7d162140687eb325980b61d82e6a9912bdb8133f4597476575e91
|
4
|
+
data.tar.gz: 7acd5b94f54997d5b01930c6ca063b8bd8869c3870311500e675ecb3cd832926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc7aa87e5cdb45bd69c3f190c4b4d407105b8a418ea9509a068e88c09406e50e02eef7ba06ebf6d07dd0361518a98c3aa09b316b627a9c9ea4ed089ff5178680
|
7
|
+
data.tar.gz: 4e3d8b6f4872434bcd30b1205d832751a20b30211f2a5b53c5dd0a463bbd3361bcfdb68cfdf0d3cea515042bae30f074f6d3844c3d3dd59b2f3aae5a5987bd54
|
data/Gemfile
CHANGED
@@ -5,16 +5,16 @@ gemspec
|
|
5
5
|
|
6
6
|
gem "dotenv", "~> 2.8.1"
|
7
7
|
gem "rake", "~> 13.1"
|
8
|
-
gem "rspec", "~> 3.
|
8
|
+
gem "rspec", "~> 3.13"
|
9
9
|
gem "rubocop", "~> 1.50.2"
|
10
10
|
gem "vcr", "~> 6.1.0"
|
11
|
-
gem "webmock", "~> 3.
|
11
|
+
gem "webmock", "~> 3.23.0"
|
12
12
|
|
13
13
|
group :development, :test do
|
14
14
|
gem "byebug", "~> 11.1"
|
15
15
|
gem "pry", "~> 0.14.2"
|
16
16
|
gem "pry-byebug", "~> 3.10"
|
17
|
-
gem "pry-rescue", "~> 1.
|
17
|
+
gem "pry-rescue", "~> 1.6"
|
18
18
|
gem "pry-stack_explorer", "~> 0.6.1"
|
19
19
|
end
|
20
20
|
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-experian (0.0.
|
4
|
+
ruby-experian (0.0.6)
|
5
5
|
faraday (>= 1)
|
6
|
-
faraday_middleware (>= 1)
|
7
6
|
multi_xml (>= 0.6.0)
|
8
7
|
rexml (>= 3.2)
|
9
8
|
sha3 (>= 1)
|
@@ -14,21 +13,41 @@ GEM
|
|
14
13
|
addressable (2.8.6)
|
15
14
|
public_suffix (>= 2.0.2, < 6.0)
|
16
15
|
ast (2.4.2)
|
16
|
+
bigdecimal (3.1.6)
|
17
17
|
binding_of_caller (1.0.0)
|
18
18
|
debug_inspector (>= 0.0.1)
|
19
19
|
byebug (11.1.3)
|
20
20
|
coderay (1.1.3)
|
21
|
-
crack (0.
|
21
|
+
crack (1.0.0)
|
22
|
+
bigdecimal
|
22
23
|
rexml
|
23
24
|
debug_inspector (1.2.0)
|
24
|
-
diff-lcs (1.5.
|
25
|
+
diff-lcs (1.5.1)
|
25
26
|
docile (1.4.0)
|
26
27
|
dotenv (2.8.1)
|
27
|
-
faraday (1.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
faraday (~> 1.0)
|
28
|
+
faraday (1.10.3)
|
29
|
+
faraday-em_http (~> 1.0)
|
30
|
+
faraday-em_synchrony (~> 1.0)
|
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)
|
39
|
+
ruby2_keywords (>= 0.0.4)
|
40
|
+
faraday-em_http (1.0.0)
|
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)
|
32
51
|
hashdiff (1.1.0)
|
33
52
|
interception (0.5)
|
34
53
|
json (2.7.1)
|
@@ -45,7 +64,7 @@ GEM
|
|
45
64
|
pry-byebug (3.10.1)
|
46
65
|
byebug (~> 11.0)
|
47
66
|
pry (>= 0.13, < 0.15)
|
48
|
-
pry-rescue (1.
|
67
|
+
pry-rescue (1.6.0)
|
49
68
|
interception (>= 0.5)
|
50
69
|
pry (>= 0.12.0)
|
51
70
|
pry-stack_explorer (0.6.1)
|
@@ -57,19 +76,19 @@ GEM
|
|
57
76
|
rake (13.1.0)
|
58
77
|
regexp_parser (2.8.3)
|
59
78
|
rexml (3.2.6)
|
60
|
-
rspec (3.
|
61
|
-
rspec-core (~> 3.
|
62
|
-
rspec-expectations (~> 3.
|
63
|
-
rspec-mocks (~> 3.
|
64
|
-
rspec-core (3.
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-expectations (3.
|
79
|
+
rspec (3.13.0)
|
80
|
+
rspec-core (~> 3.13.0)
|
81
|
+
rspec-expectations (~> 3.13.0)
|
82
|
+
rspec-mocks (~> 3.13.0)
|
83
|
+
rspec-core (3.13.0)
|
84
|
+
rspec-support (~> 3.13.0)
|
85
|
+
rspec-expectations (3.13.0)
|
67
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-mocks (3.
|
87
|
+
rspec-support (~> 3.13.0)
|
88
|
+
rspec-mocks (3.13.0)
|
70
89
|
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-support (3.
|
90
|
+
rspec-support (~> 3.13.0)
|
91
|
+
rspec-support (3.13.0)
|
73
92
|
rubocop (1.50.2)
|
74
93
|
json (~> 2.3)
|
75
94
|
parallel (~> 1.10)
|
@@ -85,7 +104,7 @@ GEM
|
|
85
104
|
ruby-progressbar (1.13.0)
|
86
105
|
ruby2_keywords (0.0.5)
|
87
106
|
sha3 (1.0.5)
|
88
|
-
simplecov (0.
|
107
|
+
simplecov (0.22.0)
|
89
108
|
docile (~> 1.1)
|
90
109
|
simplecov-html (~> 0.11)
|
91
110
|
simplecov_json_formatter (~> 0.1)
|
@@ -96,7 +115,7 @@ GEM
|
|
96
115
|
simplecov_json_formatter (0.1.4)
|
97
116
|
unicode-display_width (2.5.0)
|
98
117
|
vcr (6.1.0)
|
99
|
-
webmock (3.
|
118
|
+
webmock (3.23.0)
|
100
119
|
addressable (>= 2.8.0)
|
101
120
|
crack (>= 0.3.2)
|
102
121
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -109,16 +128,16 @@ DEPENDENCIES
|
|
109
128
|
dotenv (~> 2.8.1)
|
110
129
|
pry (~> 0.14.2)
|
111
130
|
pry-byebug (~> 3.10)
|
112
|
-
pry-rescue (~> 1.
|
131
|
+
pry-rescue (~> 1.6)
|
113
132
|
pry-stack_explorer (~> 0.6.1)
|
114
133
|
rake (~> 13.1)
|
115
|
-
rspec (~> 3.
|
134
|
+
rspec (~> 3.13)
|
116
135
|
rubocop (~> 1.50.2)
|
117
136
|
ruby-experian!
|
118
137
|
simplecov
|
119
138
|
simplecov-cobertura
|
120
139
|
vcr (~> 6.1.0)
|
121
|
-
webmock (~> 3.
|
140
|
+
webmock (~> 3.23.0)
|
122
141
|
|
123
142
|
BUNDLED WITH
|
124
143
|
2.4.22
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ require "experian"
|
|
44
44
|
|
45
45
|
### Quickstart
|
46
46
|
|
47
|
-
For a quick test you can pass your
|
47
|
+
For a quick test you can pass your user code and password directly to a new client:
|
48
48
|
|
49
49
|
```ruby
|
50
50
|
client = Experian::Client.new(user_code: "user code goes here", password: "password goes here")
|
@@ -67,7 +67,7 @@ Then you can create a client like this:
|
|
67
67
|
client = Experian::Client.new
|
68
68
|
```
|
69
69
|
|
70
|
-
You can still override the config defaults when making new clients; any options not included will fall back to any global config set with Experian.configure
|
70
|
+
You can still override the config defaults when making new clients; any options not included will fall back to any global config set with `Experian.configure`. e.g. in this example the base_uri, request_timeout, etc. will fallback to any set globally using `Experian.configure`, with only the password overridden:
|
71
71
|
|
72
72
|
```ruby
|
73
73
|
client = Experian::Client.new(password: "some other password")
|
@@ -105,7 +105,7 @@ end
|
|
105
105
|
|
106
106
|
#### Extra Headers per Client
|
107
107
|
|
108
|
-
You can dynamically pass headers per client object, which will be merged with any headers set globally with Experian.configure
|
108
|
+
You can dynamically pass headers per client object, which will be merged with any headers set globally with `Experian.configure`:
|
109
109
|
|
110
110
|
```ruby
|
111
111
|
client = Experian::Client.new(user_code: "code goes here", password: "password goes here")
|
@@ -114,7 +114,7 @@ client.add_headers("X-Proxy-TTL" => "43200")
|
|
114
114
|
|
115
115
|
#### Verbose Logging
|
116
116
|
|
117
|
-
You can
|
117
|
+
You can further configure the faraday connection by passing in a block to the client (e.g. to enable verbose logging with Ruby's [Logger](https://ruby-doc.org/3.2.2/stdlibs/logger/Logger.html)):
|
118
118
|
|
119
119
|
```ruby
|
120
120
|
client = Experian::Client.new do |f|
|
@@ -175,4 +175,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
175
175
|
|
176
176
|
## Code of Conduct
|
177
177
|
|
178
|
-
Everyone interacting in the Ruby
|
178
|
+
Everyone interacting in the Ruby Experian project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/moraki-finance/ruby-experian/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/experian/http.rb
CHANGED
@@ -1,72 +1,10 @@
|
|
1
1
|
require "base64"
|
2
2
|
require "sha3"
|
3
3
|
|
4
|
+
Faraday::FlatParamsEncoder.sort_params = false
|
5
|
+
|
4
6
|
module Experian
|
5
7
|
module HTTP
|
6
|
-
module FlatParamsEncoder
|
7
|
-
class << self
|
8
|
-
extend Forwardable
|
9
|
-
def_delegators :'Faraday::Utils', :escape, :unescape
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.encode(params)
|
13
|
-
return nil if params == nil
|
14
|
-
|
15
|
-
if !params.is_a?(Array)
|
16
|
-
if !params.respond_to?(:to_hash)
|
17
|
-
raise TypeError,
|
18
|
-
"Can't convert #{params.class} into Hash."
|
19
|
-
end
|
20
|
-
params = params.to_hash
|
21
|
-
params = params.map do |key, value|
|
22
|
-
key = key.to_s if key.kind_of?(Symbol)
|
23
|
-
[key, value]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# The params have form [['key1', 'value1'], ['key2', 'value2']].
|
28
|
-
buffer = ''
|
29
|
-
params.each do |key, value|
|
30
|
-
encoded_key = escape(key)
|
31
|
-
value = value.to_s if value == true || value == false
|
32
|
-
if value == nil
|
33
|
-
buffer << "#{encoded_key}&"
|
34
|
-
elsif value.kind_of?(Array)
|
35
|
-
value.each do |sub_value|
|
36
|
-
encoded_value = escape(sub_value)
|
37
|
-
buffer << "#{encoded_key}=#{encoded_value}&"
|
38
|
-
end
|
39
|
-
else
|
40
|
-
encoded_value = escape(value)
|
41
|
-
buffer << "#{encoded_key}=#{encoded_value}&"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
return buffer.chop
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.decode(query)
|
48
|
-
empty_accumulator = {}
|
49
|
-
return nil if query == nil
|
50
|
-
split_query = (query.split('&').map do |pair|
|
51
|
-
pair.split('=', 2) if pair && !pair.empty?
|
52
|
-
end).compact
|
53
|
-
return split_query.inject(empty_accumulator.dup) do |accu, pair|
|
54
|
-
pair[0] = unescape(pair[0])
|
55
|
-
pair[1] = true if pair[1].nil?
|
56
|
-
if pair[1].respond_to?(:to_str)
|
57
|
-
pair[1] = unescape(pair[1].to_str.gsub(/\+/, " "))
|
58
|
-
end
|
59
|
-
if accu[pair[0]].kind_of?(Array)
|
60
|
-
accu[pair[0]] << pair[1]
|
61
|
-
elsif accu[pair[0]]
|
62
|
-
accu[pair[0]] = [accu[pair[0]], pair[1]]
|
63
|
-
else
|
64
|
-
accu[pair[0]] = pair[1]
|
65
|
-
end
|
66
|
-
accu
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
8
|
|
71
9
|
def get(path:, format:, **query)
|
72
10
|
tip_formato = {
|
@@ -93,8 +31,7 @@ module Experian
|
|
93
31
|
def conn
|
94
32
|
connection = Faraday.new do |f|
|
95
33
|
f.options[:timeout] = request_timeout
|
96
|
-
f.options[:params_encoder] = FlatParamsEncoder
|
97
|
-
f.use MiddlewareErrors
|
34
|
+
f.options[:params_encoder] = Faraday::FlatParamsEncoder
|
98
35
|
f.response :raise_error
|
99
36
|
end
|
100
37
|
|
data/lib/experian/version.rb
CHANGED
data/lib/experian.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "faraday"
|
2
|
-
require "faraday_middleware"
|
3
2
|
|
4
3
|
require_relative "experian/http"
|
5
4
|
require_relative "experian/client"
|
@@ -11,22 +10,6 @@ module Experian
|
|
11
10
|
class AuthenticationError < Error; end
|
12
11
|
class ConfigurationError < Error; end
|
13
12
|
|
14
|
-
class MiddlewareErrors < Faraday::Middleware
|
15
|
-
def call(env)
|
16
|
-
@app.call(env)
|
17
|
-
rescue Faraday::Error => e
|
18
|
-
raise e unless e.response.is_a?(Hash)
|
19
|
-
|
20
|
-
logger = Logger.new($stdout)
|
21
|
-
logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
22
|
-
"\033[31mExperian HTTP Error (spotted in ruby-experian #{VERSION}): #{msg}\n\033[0m"
|
23
|
-
end
|
24
|
-
logger.error(e.response[:body])
|
25
|
-
|
26
|
-
raise e
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
13
|
class Configuration
|
31
14
|
attr_writer :user_code, :password, :version, :request_timeout, :base_uri, :extra_headers
|
32
15
|
attr_reader :base_uri, :request_timeout, :version, :extra_headers
|
data/ruby-experian.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_dependency "faraday", ">= 1"
|
21
|
-
s.add_dependency "faraday_middleware", ">= 1"
|
22
21
|
s.add_dependency "sha3", ">= 1"
|
23
22
|
s.add_dependency "multi_xml", ">= 0.6.0"
|
24
23
|
s.add_dependency "rexml", ">= 3.2"
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Mochetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: faraday_middleware
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: sha3
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|