credit_gateway 0.1.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/Gemfile.lock +57 -44
- data/credit_gateway.gemspec +0 -10
- data/lib/credit_gateway/authenticate.rb +2 -2
- data/lib/credit_gateway/bank_connection.rb +21 -0
- data/lib/credit_gateway/bank_connection_params.rb +9 -0
- data/lib/credit_gateway/bank_repository.rb +48 -0
- data/lib/credit_gateway/bank_subject.rb +21 -0
- data/lib/credit_gateway/base_model.rb +2 -2
- data/lib/credit_gateway/base_repository.rb +4 -6
- data/lib/credit_gateway/camelizer_lower.rb +14 -0
- data/lib/credit_gateway/client.rb +15 -10
- data/lib/credit_gateway/{score_data_response.rb → company.rb} +2 -2
- data/lib/credit_gateway/company_repository.rb +16 -0
- data/lib/credit_gateway/configuration.rb +5 -4
- data/lib/credit_gateway/errors.rb +2 -0
- data/lib/credit_gateway/faraday_auth.rb +3 -1
- data/lib/credit_gateway/rating.rb +8 -2
- data/lib/credit_gateway/rating_component.rb +18 -0
- data/lib/credit_gateway/rating_metadata.rb +16 -0
- data/lib/credit_gateway/rating_status.rb +21 -0
- data/lib/credit_gateway/score.rb +22 -0
- data/lib/credit_gateway/{behavioral_badge.rb → score_badge.rb} +6 -1
- data/lib/credit_gateway/score_repository.rb +31 -0
- data/lib/credit_gateway/version.rb +1 -1
- data/lib/credit_gateway.rb +3 -4
- metadata +19 -155
- data/lib/credit_gateway/behavioral_score.rb +0 -21
- data/lib/credit_gateway/behavioral_score_repository.rb +0 -38
- data/lib/credit_gateway/financial_score_repository.rb +0 -16
- data/lib/credit_gateway/full_score.rb +0 -20
- data/lib/credit_gateway/identity.rb +0 -9
- data/lib/credit_gateway/score_data_repository.rb +0 -17
- data/lib/credit_gateway/score_data_request.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9c2b122ea81ef5f3ad7615a43bf703a2867d9222751de5147d63c681efe5bb5
|
4
|
+
data.tar.gz: 9950ee7f4c3af522103725a003bb94b613e4956f609ac37b653b42826cb7305d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1214957a90c04f78a7a135d4d152fc2a49a94667f077d64f7b933a9785783e352a21b45cf6d9298f766246ebbb2374f4f59b8d82e1f1e7078823f6ac1d2da7b
|
7
|
+
data.tar.gz: d3e7885b2095b5521f2731a4bee6e5ddde384c5a06aa3de35a7cb710c8e38db39347df147c120315a0ccfae83d8ffdfe56638809f4f54b1ae6fa40e657df207d
|
data/Gemfile
CHANGED
@@ -6,3 +6,13 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
# Specify your gem's dependencies in credit_gateway.gemspec
|
8
8
|
gemspec
|
9
|
+
|
10
|
+
# Dev dependencies
|
11
|
+
gem 'dotenv'
|
12
|
+
gem 'pry'
|
13
|
+
gem 'rake'
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'vcr'
|
16
|
+
gem 'webmock'
|
17
|
+
gem 'rubocop'
|
18
|
+
gem 'rubocop-rspec'
|
data/Gemfile.lock
CHANGED
@@ -1,79 +1,92 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
credit_gateway (0.
|
4
|
+
credit_gateway (0.3.1)
|
5
5
|
faraday
|
6
|
-
faraday_middleware
|
7
|
-
faraday_middleware-multi_json
|
8
|
-
multi_json
|
9
6
|
|
10
7
|
GEM
|
11
8
|
remote: https://rubygems.org/
|
12
9
|
specs:
|
13
|
-
addressable (2.
|
14
|
-
public_suffix (>= 2.0.2, <
|
10
|
+
addressable (2.8.1)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
|
+
ast (2.4.2)
|
15
13
|
coderay (1.1.3)
|
16
14
|
crack (0.4.5)
|
17
15
|
rexml
|
18
|
-
diff-lcs (1.
|
19
|
-
dotenv (2.
|
20
|
-
faraday (
|
21
|
-
faraday-
|
22
|
-
faraday-net_http (~> 1.0)
|
23
|
-
faraday-net_http_persistent (~> 1.1)
|
24
|
-
multipart-post (>= 1.2, < 3)
|
16
|
+
diff-lcs (1.5.0)
|
17
|
+
dotenv (2.8.1)
|
18
|
+
faraday (2.7.4)
|
19
|
+
faraday-net_http (>= 2.0, < 3.1)
|
25
20
|
ruby2_keywords (>= 0.0.4)
|
26
|
-
faraday-
|
27
|
-
faraday-net_http (1.0.1)
|
28
|
-
faraday-net_http_persistent (1.1.0)
|
29
|
-
faraday_middleware (1.0.0)
|
30
|
-
faraday (~> 1.0)
|
31
|
-
faraday_middleware-multi_json (0.0.6)
|
32
|
-
faraday_middleware
|
33
|
-
multi_json
|
21
|
+
faraday-net_http (3.0.2)
|
34
22
|
hashdiff (1.0.1)
|
23
|
+
json (2.6.3)
|
35
24
|
method_source (1.0.0)
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
parallel (1.22.1)
|
26
|
+
parser (3.2.1.0)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
pry (0.14.2)
|
39
29
|
coderay (~> 1.1)
|
40
30
|
method_source (~> 1.0)
|
41
|
-
public_suffix (
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
rspec-
|
48
|
-
|
49
|
-
rspec-
|
50
|
-
rspec-
|
31
|
+
public_suffix (5.0.1)
|
32
|
+
rainbow (3.1.1)
|
33
|
+
rake (13.0.6)
|
34
|
+
regexp_parser (2.7.0)
|
35
|
+
rexml (3.2.5)
|
36
|
+
rspec (3.12.0)
|
37
|
+
rspec-core (~> 3.12.0)
|
38
|
+
rspec-expectations (~> 3.12.0)
|
39
|
+
rspec-mocks (~> 3.12.0)
|
40
|
+
rspec-core (3.12.1)
|
41
|
+
rspec-support (~> 3.12.0)
|
42
|
+
rspec-expectations (3.12.2)
|
51
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.
|
53
|
-
rspec-mocks (3.
|
44
|
+
rspec-support (~> 3.12.0)
|
45
|
+
rspec-mocks (3.12.3)
|
54
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.
|
56
|
-
rspec-support (3.
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
rspec-support (~> 3.12.0)
|
48
|
+
rspec-support (3.12.0)
|
49
|
+
rubocop (1.47.0)
|
50
|
+
json (~> 2.3)
|
51
|
+
parallel (~> 1.10)
|
52
|
+
parser (>= 3.2.0.0)
|
53
|
+
rainbow (>= 2.2.2, < 4.0)
|
54
|
+
regexp_parser (>= 1.8, < 3.0)
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
57
|
+
ruby-progressbar (~> 1.7)
|
58
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
59
|
+
rubocop-ast (1.27.0)
|
60
|
+
parser (>= 3.2.1.0)
|
61
|
+
rubocop-capybara (2.17.1)
|
62
|
+
rubocop (~> 1.41)
|
63
|
+
rubocop-rspec (2.18.1)
|
64
|
+
rubocop (~> 1.33)
|
65
|
+
rubocop-capybara (~> 2.17)
|
66
|
+
ruby-progressbar (1.12.0)
|
67
|
+
ruby2_keywords (0.0.5)
|
68
|
+
unicode-display_width (2.4.2)
|
69
|
+
vcr (6.1.0)
|
70
|
+
webmock (3.18.1)
|
71
|
+
addressable (>= 2.8.0)
|
61
72
|
crack (>= 0.3.2)
|
62
73
|
hashdiff (>= 0.4.0, < 2.0.0)
|
63
74
|
|
64
75
|
PLATFORMS
|
76
|
+
-darwin-21
|
65
77
|
x86_64-darwin-19
|
66
78
|
x86_64-linux
|
67
79
|
|
68
80
|
DEPENDENCIES
|
69
|
-
bundler (~> 2.2)
|
70
81
|
credit_gateway!
|
71
82
|
dotenv
|
72
83
|
pry
|
73
84
|
rake
|
74
85
|
rspec
|
86
|
+
rubocop
|
87
|
+
rubocop-rspec
|
75
88
|
vcr
|
76
89
|
webmock
|
77
90
|
|
78
91
|
BUNDLED WITH
|
79
|
-
2.
|
92
|
+
2.3.10
|
data/credit_gateway.gemspec
CHANGED
@@ -24,14 +24,4 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
26
|
spec.add_dependency 'faraday'
|
27
|
-
spec.add_dependency 'faraday_middleware'
|
28
|
-
spec.add_dependency 'faraday_middleware-multi_json'
|
29
|
-
spec.add_dependency 'multi_json'
|
30
|
-
spec.add_development_dependency 'bundler', '~> 2.2'
|
31
|
-
spec.add_development_dependency 'dotenv'
|
32
|
-
spec.add_development_dependency 'pry'
|
33
|
-
spec.add_development_dependency 'rake'
|
34
|
-
spec.add_development_dependency 'rspec'
|
35
|
-
spec.add_development_dependency 'vcr'
|
36
|
-
spec.add_development_dependency 'webmock'
|
37
27
|
end
|
@@ -8,7 +8,7 @@ module CreditGateway
|
|
8
8
|
class Authenticate
|
9
9
|
def call(client_id, client_secret)
|
10
10
|
response = post(
|
11
|
-
'/connect/token',
|
11
|
+
'/auth/connect/token',
|
12
12
|
client_id: client_id,
|
13
13
|
client_secret: client_secret,
|
14
14
|
grant_type: 'client_credentials'
|
@@ -38,7 +38,7 @@ module CreditGateway
|
|
38
38
|
conn.headers.merge!(
|
39
39
|
user_agent: "finpoint/#{CreditGateway::VERSION}"
|
40
40
|
)
|
41
|
-
conn.response :
|
41
|
+
conn.response :json, parser_options: { symbolize_names: true }
|
42
42
|
conn.response :logger if CreditGateway.configuration.debug
|
43
43
|
conn.adapter Faraday.default_adapter
|
44
44
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'credit_gateway/base_model'
|
5
|
+
|
6
|
+
module CreditGateway
|
7
|
+
class BankConnection < BaseModel
|
8
|
+
attributes :connection_id, :provider_id, :status, :creation_date_time, :status_update_date_time
|
9
|
+
|
10
|
+
def self.build(json:)
|
11
|
+
super.tap do |record|
|
12
|
+
if record.creation_date_time
|
13
|
+
record.creation_date_time = Time.parse(record.creation_date_time)
|
14
|
+
end
|
15
|
+
if record.status_update_date_time
|
16
|
+
record.status_update_date_time = Time.parse(record.status_update_date_time)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_repository'
|
4
|
+
require 'credit_gateway/bank_subject'
|
5
|
+
require 'credit_gateway/bank_connection'
|
6
|
+
require 'credit_gateway/bank_connection_params'
|
7
|
+
|
8
|
+
module CreditGateway
|
9
|
+
class BankRepository < BaseRepository
|
10
|
+
def create_subject(company_id)
|
11
|
+
result = post('/bank/subjects', params: { companyId: company_id })
|
12
|
+
|
13
|
+
BankSubject.build(json: result.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
def lookup_subjects(company_id)
|
17
|
+
result = get('/bank/subjects', params: { companyId: company_id })
|
18
|
+
|
19
|
+
result.body.fetch(:data, []).map do |subject|
|
20
|
+
BankSubject.build(json: subject)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# connection_params - CreditGateway::BankConnectionParams
|
25
|
+
def create_connection(subject_id, connection_params:)
|
26
|
+
url = format_url(
|
27
|
+
'/bank/subjects/:subject_id/connections',
|
28
|
+
subject_id: subject_id.to_s
|
29
|
+
)
|
30
|
+
result = post(url, params: connection_params.as_json)
|
31
|
+
|
32
|
+
BankConnection.build(json: result.body)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Submits bank data to prepare the report
|
36
|
+
# bank_data_request - CreditGateway::BankDataRequest
|
37
|
+
def upload_bank_data(subject_id, connection_id, bank_data_request)
|
38
|
+
url = format_url(
|
39
|
+
'/bank/subjects/:subject_id/connections/:connection_id/upload',
|
40
|
+
subject_id: subject_id.to_s,
|
41
|
+
connection_id: connection_id.to_s
|
42
|
+
)
|
43
|
+
post(url, params: bank_data_request.as_json)
|
44
|
+
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'credit_gateway/base_model'
|
5
|
+
|
6
|
+
module CreditGateway
|
7
|
+
class BankSubject < BaseModel
|
8
|
+
attributes :subject_id, :company_id, :status, :creation_date_time, :status_update_date_time
|
9
|
+
|
10
|
+
def self.build(json:)
|
11
|
+
super.tap do |record|
|
12
|
+
if record.creation_date_time
|
13
|
+
record.creation_date_time = Time.parse(record.creation_date_time)
|
14
|
+
end
|
15
|
+
if record.status_update_date_time
|
16
|
+
record.status_update_date_time = Time.parse(record.status_update_date_time)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'credit_gateway/errors'
|
4
|
-
require 'credit_gateway/
|
4
|
+
require 'credit_gateway/camelizer_lower'
|
5
5
|
|
6
6
|
module CreditGateway
|
7
7
|
class BaseModel
|
@@ -25,7 +25,7 @@ module CreditGateway
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def key_transformer
|
28
|
-
|
28
|
+
CamelizerLower
|
29
29
|
end
|
30
30
|
|
31
31
|
# Sets all the instance variables by reading the JSON from CreditGateway and converting the keys from
|
@@ -13,18 +13,16 @@ module CreditGateway
|
|
13
13
|
|
14
14
|
attr_reader :client
|
15
15
|
|
16
|
-
def get(path, params: {}
|
17
|
-
|
18
|
-
result = client.get(path.strip, headers: headers, params: params)
|
16
|
+
def get(path, params: {})
|
17
|
+
result = client.get(path.strip, params: params)
|
19
18
|
|
20
19
|
raise APIKeyError, result.body[:error] if result.status == 401
|
21
20
|
|
22
21
|
result
|
23
22
|
end
|
24
23
|
|
25
|
-
def post(path, params: {}
|
26
|
-
|
27
|
-
result = client.post(path.strip, headers: headers, params: params)
|
24
|
+
def post(path, params: {})
|
25
|
+
result = client.post(path.strip, params: params)
|
28
26
|
|
29
27
|
raise APIKeyError, result.body[:error] if result.status == 401
|
30
28
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CreditGateway
|
4
|
+
class CamelizerLower
|
5
|
+
# Converts this_is_my_string to thisIsMyString and returns it as a symbol.
|
6
|
+
def self.transform(underscore_string)
|
7
|
+
parts = underscore_string.to_s.split('_')
|
8
|
+
|
9
|
+
rest = parts[1..].map(&:capitalize)
|
10
|
+
|
11
|
+
rest.unshift(parts[0]).join.to_sym
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
-
|
4
|
+
|
5
5
|
require 'credit_gateway/configuration'
|
6
6
|
require 'credit_gateway/faraday_auth'
|
7
7
|
require 'credit_gateway/errors'
|
@@ -21,7 +21,7 @@ module CreditGateway
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def post(path, headers: {}, params: {})
|
24
|
-
connection.post(path,
|
24
|
+
connection.post(path, JSON.parse(params), headers).tap do |response|
|
25
25
|
handle_response(response)
|
26
26
|
end
|
27
27
|
end
|
@@ -30,8 +30,9 @@ module CreditGateway
|
|
30
30
|
@connection ||= Faraday.new(url: api_url) do |conn|
|
31
31
|
conn.request :credit_gateway_auth,
|
32
32
|
CreditGateway.configuration.client_id,
|
33
|
-
CreditGateway.configuration.client_secret
|
34
|
-
|
33
|
+
CreditGateway.configuration.client_secret,
|
34
|
+
CreditGateway.configuration.country
|
35
|
+
conn.response :json, parser_options: { symbolize_names: true }
|
35
36
|
if CreditGateway.configuration.debug
|
36
37
|
conn.response :logger, nil, { headers: true, bodies: CreditGateway.configuration.verbose }
|
37
38
|
end
|
@@ -48,18 +49,22 @@ module CreditGateway
|
|
48
49
|
|
49
50
|
case response.status
|
50
51
|
when 400
|
51
|
-
|
52
|
-
raise CompanyNotFoundError, response.body.dig(:Errors, 0, :ErrorMessage)
|
53
|
-
else
|
54
|
-
raise InvalidRequestError, response.body
|
55
|
-
end
|
52
|
+
handle_company_not_found(response.body, InvalidRequestError)
|
56
53
|
when 401
|
57
54
|
raise UnauthorizedError, response.body
|
58
55
|
when 404
|
59
|
-
|
56
|
+
handle_company_not_found(response.body, NotFoundError)
|
57
|
+
when 409
|
58
|
+
raise ConflictError, response.body
|
60
59
|
else
|
61
60
|
raise GenericError, "#{response.status}: #{response.body}"
|
62
61
|
end
|
63
62
|
end
|
63
|
+
|
64
|
+
def handle_company_not_found(body, alternative_exception)
|
65
|
+
raise CompanyNotFoundError, body.dig(0, :message) if body.dig(0, :code) == 'company_not_found'
|
66
|
+
|
67
|
+
raise alternative_exception, body
|
68
|
+
end
|
64
69
|
end
|
65
70
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_repository'
|
4
|
+
require 'credit_gateway/company'
|
5
|
+
|
6
|
+
module CreditGateway
|
7
|
+
class CompanyRepository < BaseRepository
|
8
|
+
# Params:
|
9
|
+
# document_token - Token retrieved from ScoreDataRepository#prepare
|
10
|
+
def find(name, number)
|
11
|
+
result = post('/companies', params: { name: name, number: number })
|
12
|
+
|
13
|
+
Company.build(json: result.body)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -4,18 +4,19 @@ module CreditGateway
|
|
4
4
|
class Configuration
|
5
5
|
BASE_URLS = {
|
6
6
|
production: 'https://api.connector.crifrealtime.com',
|
7
|
-
sandbox: 'https://
|
7
|
+
sandbox: 'https://api-sandbox.connector.crifrealtime.com'
|
8
8
|
}.freeze
|
9
9
|
AUTH_URLS = {
|
10
|
-
production: 'https://
|
11
|
-
sandbox: 'https://
|
10
|
+
production: 'https://api.connector.crifrealtime.com',
|
11
|
+
sandbox: 'https://api-sandbox.connector.crifrealtime.com'
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
attr_accessor :client_id, :client_secret, :environment, :debug, :verbose
|
14
|
+
attr_accessor :client_id, :client_secret, :country, :environment, :debug, :verbose
|
15
15
|
|
16
16
|
def initialize
|
17
17
|
@client_id = ''
|
18
18
|
@client_secret = ''
|
19
|
+
@country = nil
|
19
20
|
@environment = :sandbox # can be either :sandbox or :production
|
20
21
|
@debug = false
|
21
22
|
@verbose = false
|
@@ -6,10 +6,11 @@ require 'credit_gateway/errors'
|
|
6
6
|
|
7
7
|
module CreditGateway
|
8
8
|
class FaradayAuth < Faraday::Middleware
|
9
|
-
def initialize(app, client_id, client_secret, options = {})
|
9
|
+
def initialize(app, client_id, client_secret, country, options = {})
|
10
10
|
super(app)
|
11
11
|
@client_id = client_id
|
12
12
|
@client_secret = client_secret
|
13
|
+
@country = country
|
13
14
|
@options = options
|
14
15
|
@token = nil
|
15
16
|
end
|
@@ -18,6 +19,7 @@ module CreditGateway
|
|
18
19
|
@token ||= authenticate
|
19
20
|
|
20
21
|
env[:request_headers]['Authorization'] = "Bearer #{@token}"
|
22
|
+
env[:request_headers]['X-Country'] = @country
|
21
23
|
env[:request_headers]['Content-Type'] = 'application/json'
|
22
24
|
env[:request_headers]['User-Agent'] = "finpoint/#{CreditGateway::VERSION}"
|
23
25
|
|
@@ -1,10 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'credit_gateway/base_model'
|
4
|
+
require 'credit_gateway/rating_metadata'
|
4
5
|
|
5
6
|
module CreditGateway
|
6
7
|
class Rating < BaseModel
|
7
|
-
attributes :
|
8
|
-
|
8
|
+
attributes :score, :algorithm_type, :algorithm_version, :metadata
|
9
|
+
|
10
|
+
def self.build(json:)
|
11
|
+
super.tap do |record|
|
12
|
+
record.metadata = RatingMetadata.build(json: (record.metadata || {}))
|
13
|
+
end
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_model'
|
4
|
+
require 'credit_gateway/rating'
|
5
|
+
require 'credit_gateway/rating_status'
|
6
|
+
|
7
|
+
module CreditGateway
|
8
|
+
class RatingComponent < BaseModel
|
9
|
+
attributes :type, :ids, :rating, :confidence, :algorithm, :optional, :status, :additional_data
|
10
|
+
|
11
|
+
def self.build(json:)
|
12
|
+
super.tap do |record|
|
13
|
+
record.status = RatingStatus.build(json: (record.status || {}))
|
14
|
+
record.rating = Rating.build(json: (record.rating || {}))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'credit_gateway/base_model'
|
5
|
+
|
6
|
+
module CreditGateway
|
7
|
+
class RatingMetadata < BaseModel
|
8
|
+
attributes :description, :class, :scale, :label, :implied_rating, :frequency, :created_at
|
9
|
+
|
10
|
+
def self.build(json:)
|
11
|
+
super.tap do |record|
|
12
|
+
record.created_at = Time.parse(record.created_at) if record.created_at
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_model'
|
4
|
+
|
5
|
+
module CreditGateway
|
6
|
+
class RatingStatus < BaseModel
|
7
|
+
attributes :status, :description
|
8
|
+
|
9
|
+
def complete?
|
10
|
+
status == 'complete'
|
11
|
+
end
|
12
|
+
|
13
|
+
def pending?
|
14
|
+
status == 'pending'
|
15
|
+
end
|
16
|
+
|
17
|
+
def unprocessable?
|
18
|
+
status == 'unprocessable'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_model'
|
4
|
+
require 'credit_gateway/rating'
|
5
|
+
require 'credit_gateway/rating_status'
|
6
|
+
require 'credit_gateway/rating_component'
|
7
|
+
|
8
|
+
module CreditGateway
|
9
|
+
class Score < BaseModel
|
10
|
+
attributes :id, :company_id, :status, :rating, :components
|
11
|
+
|
12
|
+
def self.build(json:)
|
13
|
+
super.tap do |record|
|
14
|
+
record.status = RatingStatus.build(json: (record.status || {}))
|
15
|
+
record.rating = Rating.build(json: (record.rating || {}))
|
16
|
+
record.components = (record.components || []).map do |component|
|
17
|
+
RatingComponent.build(json: component)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'credit_gateway/base_model'
|
4
|
+
require 'credit_gateway/camelizer_upper'
|
4
5
|
|
5
6
|
module CreditGateway
|
6
|
-
class
|
7
|
+
class ScoreBadge < BaseModel
|
7
8
|
attributes :badge_url, :badge_tiny_url, :badge_long_url, :upgrade_url
|
9
|
+
|
10
|
+
def self.key_transformer
|
11
|
+
CamelizerUpper
|
12
|
+
end
|
8
13
|
end
|
9
14
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'credit_gateway/base_repository'
|
4
|
+
require 'credit_gateway/score'
|
5
|
+
require 'credit_gateway/score_badge'
|
6
|
+
|
7
|
+
module CreditGateway
|
8
|
+
class ScoreRepository < BaseRepository
|
9
|
+
def fetch(company_id)
|
10
|
+
res = post('/score', params: { companyId: company_id })
|
11
|
+
|
12
|
+
Score.build(json: res.body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(score_id)
|
16
|
+
res = get(format_url('/score/:id', { id: score_id }))
|
17
|
+
|
18
|
+
Score.build(json: res.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def badge(company_id)
|
22
|
+
url = format_url(
|
23
|
+
'/insights/data/badge/:company_id',
|
24
|
+
company_id: company_id.to_s
|
25
|
+
)
|
26
|
+
result = get(url)
|
27
|
+
|
28
|
+
ScoreBadge.build(json: result.body)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/credit_gateway.rb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'credit_gateway/version'
|
4
4
|
require 'credit_gateway/configuration'
|
5
|
-
require 'credit_gateway/
|
6
|
-
require 'credit_gateway/
|
7
|
-
require 'credit_gateway/
|
8
|
-
require 'credit_gateway/score_data_repository'
|
5
|
+
require 'credit_gateway/company_repository'
|
6
|
+
require 'credit_gateway/bank_repository'
|
7
|
+
require 'credit_gateway/score_repository'
|
9
8
|
require 'credit_gateway/bank_data_request'
|
10
9
|
require 'credit_gateway/balance'
|
11
10
|
require 'credit_gateway/bank_account'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finpoint
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,146 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
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: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday_middleware-multi_json
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: multi_json
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '2.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: dotenv
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: vcr
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: webmock
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
27
|
description: CRIF CreditGateway client
|
168
28
|
email:
|
169
29
|
- nenad@finpoint.co.uk
|
@@ -187,31 +47,35 @@ files:
|
|
187
47
|
- lib/credit_gateway/balance.rb
|
188
48
|
- lib/credit_gateway/bank_account.rb
|
189
49
|
- lib/credit_gateway/bank_account_scheme.rb
|
50
|
+
- lib/credit_gateway/bank_connection.rb
|
51
|
+
- lib/credit_gateway/bank_connection_params.rb
|
190
52
|
- lib/credit_gateway/bank_data.rb
|
191
53
|
- lib/credit_gateway/bank_data_request.rb
|
54
|
+
- lib/credit_gateway/bank_repository.rb
|
55
|
+
- lib/credit_gateway/bank_subject.rb
|
192
56
|
- lib/credit_gateway/base_model.rb
|
193
57
|
- lib/credit_gateway/base_repository.rb
|
194
|
-
- lib/credit_gateway/
|
195
|
-
- lib/credit_gateway/behavioral_score.rb
|
196
|
-
- lib/credit_gateway/behavioral_score_repository.rb
|
58
|
+
- lib/credit_gateway/camelizer_lower.rb
|
197
59
|
- lib/credit_gateway/camelizer_upper.rb
|
198
60
|
- lib/credit_gateway/client.rb
|
61
|
+
- lib/credit_gateway/company.rb
|
62
|
+
- lib/credit_gateway/company_repository.rb
|
199
63
|
- lib/credit_gateway/configuration.rb
|
200
64
|
- lib/credit_gateway/errors.rb
|
201
65
|
- lib/credit_gateway/faraday_auth.rb
|
202
|
-
- lib/credit_gateway/financial_score_repository.rb
|
203
|
-
- lib/credit_gateway/full_score.rb
|
204
|
-
- lib/credit_gateway/identity.rb
|
205
66
|
- lib/credit_gateway/rating.rb
|
206
|
-
- lib/credit_gateway/
|
207
|
-
- lib/credit_gateway/
|
208
|
-
- lib/credit_gateway/
|
67
|
+
- lib/credit_gateway/rating_component.rb
|
68
|
+
- lib/credit_gateway/rating_metadata.rb
|
69
|
+
- lib/credit_gateway/rating_status.rb
|
70
|
+
- lib/credit_gateway/score.rb
|
71
|
+
- lib/credit_gateway/score_badge.rb
|
72
|
+
- lib/credit_gateway/score_repository.rb
|
209
73
|
- lib/credit_gateway/transaction.rb
|
210
74
|
- lib/credit_gateway/version.rb
|
211
75
|
homepage: https://www.finpoint.co.uk
|
212
76
|
licenses: []
|
213
77
|
metadata: {}
|
214
|
-
post_install_message:
|
78
|
+
post_install_message:
|
215
79
|
rdoc_options: []
|
216
80
|
require_paths:
|
217
81
|
- lib
|
@@ -226,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
90
|
- !ruby/object:Gem::Version
|
227
91
|
version: '0'
|
228
92
|
requirements: []
|
229
|
-
rubygems_version: 3.2.
|
230
|
-
signing_key:
|
93
|
+
rubygems_version: 3.2.3
|
94
|
+
signing_key:
|
231
95
|
specification_version: 4
|
232
96
|
summary: CRIF CreditGateway client
|
233
97
|
test_files: []
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'time'
|
4
|
-
require 'credit_gateway/base_model'
|
5
|
-
require 'credit_gateway/rating'
|
6
|
-
|
7
|
-
module CreditGateway
|
8
|
-
class BehavioralScore < BaseModel
|
9
|
-
attributes :frequency, :calculated, :main_rating, :component_ratings
|
10
|
-
|
11
|
-
def self.build(json:)
|
12
|
-
super.tap do |record|
|
13
|
-
record.calculated = Time.parse(record.calculated) if record.calculated
|
14
|
-
record.main_rating = Rating.build(json: (record.main_rating || {}))
|
15
|
-
record.component_ratings = (record.component_ratings || []).map do |rating|
|
16
|
-
Rating.build(json: rating)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'credit_gateway/base_repository'
|
4
|
-
require 'credit_gateway/behavioral_score'
|
5
|
-
require 'credit_gateway/behavioral_badge'
|
6
|
-
require 'credit_gateway/full_score'
|
7
|
-
|
8
|
-
module CreditGateway
|
9
|
-
class BehavioralScoreRepository < BaseRepository
|
10
|
-
# Params:
|
11
|
-
# document_token - Token retrieved from ScoreDataRepository#prepare
|
12
|
-
def specific_rating(document_token)
|
13
|
-
result = post('/score/behavioralscore', params: { token: document_token })
|
14
|
-
|
15
|
-
FullScore.build(json: result.body)
|
16
|
-
end
|
17
|
-
|
18
|
-
def latest_rating(company_id)
|
19
|
-
url = format_url(
|
20
|
-
'/score/behavioralscore/rating/:company_id',
|
21
|
-
company_id: company_id.to_s
|
22
|
-
)
|
23
|
-
result = get(url)
|
24
|
-
|
25
|
-
BehavioralScore.build(json: result.body)
|
26
|
-
end
|
27
|
-
|
28
|
-
def badge(company_id)
|
29
|
-
url = format_url(
|
30
|
-
'/score/behavioralscore/badge/:company_id',
|
31
|
-
company_id: company_id.to_s
|
32
|
-
)
|
33
|
-
result = get(url)
|
34
|
-
|
35
|
-
BehavioralBadge.build(json: result.body)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'credit_gateway/base_repository'
|
4
|
-
require 'credit_gateway/full_score'
|
5
|
-
|
6
|
-
module CreditGateway
|
7
|
-
class FinancialScoreRepository < BaseRepository
|
8
|
-
# Fetch financial score for given company
|
9
|
-
# identity - CreditGateway::Identity
|
10
|
-
def find(identity)
|
11
|
-
result = get('/score/financialscore', identity: identity)
|
12
|
-
|
13
|
-
FullScore.build(json: result.body)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'time'
|
4
|
-
require 'credit_gateway/base_model'
|
5
|
-
require 'credit_gateway/rating'
|
6
|
-
|
7
|
-
module CreditGateway
|
8
|
-
class FullScore < BaseModel
|
9
|
-
attributes :frequency, :calculated, :full_score, :behavioral_score, :financial_score
|
10
|
-
|
11
|
-
def self.build(json:)
|
12
|
-
super.tap do |record|
|
13
|
-
record.full_score = Rating.build(json: (record.full_score || {}))
|
14
|
-
record.behavioral_score = Rating.build(json: (record.behavioral_score || {}))
|
15
|
-
record.financial_score = Rating.build(json: (record.financial_score || {}))
|
16
|
-
record.calculated = Time.parse(record.calculated) if record.calculated
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'credit_gateway/base_repository'
|
4
|
-
require 'credit_gateway/score_data_response'
|
5
|
-
|
6
|
-
module CreditGateway
|
7
|
-
class ScoreDataRepository < BaseRepository
|
8
|
-
# Submits bank data to prepare the report
|
9
|
-
# identity - CreditGateway::Identity
|
10
|
-
# bank_data_request - CreditGateway::BankDataRequest
|
11
|
-
def prepare(identity, bank_data_request)
|
12
|
-
res = post('/score/data/prepare', params: bank_data_request.as_json, identity: identity)
|
13
|
-
|
14
|
-
ScoreDataResponse.build(json: res.body)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'credit_gateway/base_model'
|
4
|
-
require 'credit_gateway/bank_data'
|
5
|
-
|
6
|
-
module CreditGateway
|
7
|
-
class ScoreDataRequest < BaseModel
|
8
|
-
attributes :banks_account_data
|
9
|
-
|
10
|
-
def self.build(json:)
|
11
|
-
super.tap do |record|
|
12
|
-
record.banks_account_data = (record.banks_account_data || []).compact.map do |bad|
|
13
|
-
BankData.build(json: bad)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|