credit_gateway 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -9
- data/lib/credit_gateway/authenticate.rb +1 -1
- 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 +12 -7
- 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 -15
- 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: 8be5d186d64558a4355ba31d404b309493544f9a224a356d5a0227ca3652b789
|
4
|
+
data.tar.gz: b4948de2c3a8ddf854a18635c64f6af00fb10bbd92e91837f36f9a4fe81b3b9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427b05375218dbcbbda7d21bfc93894fd10606eb14ef67c0db215d3e1e5e11033e443bab26bbcddb41a31d0fae4285f5f9baa3a1f399ba68e6bf89f2a03541be
|
7
|
+
data.tar.gz: fe361e745ad10b9f34dcd2575371dc0ce5eb81d8c240ed2f58d1a5804be1753afccf1fdbc16602bfdb8eb417fbc64da71b6a9d6ba3b0af7cdfa5619112060383
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
credit_gateway (0.
|
4
|
+
credit_gateway (0.3.0)
|
5
5
|
faraday
|
6
6
|
faraday_middleware
|
7
7
|
faraday_middleware-multi_json
|
@@ -17,16 +17,30 @@ GEM
|
|
17
17
|
rexml
|
18
18
|
diff-lcs (1.4.4)
|
19
19
|
dotenv (2.7.6)
|
20
|
-
faraday (1.
|
20
|
+
faraday (1.10.0)
|
21
|
+
faraday-em_http (~> 1.0)
|
22
|
+
faraday-em_synchrony (~> 1.0)
|
21
23
|
faraday-excon (~> 1.1)
|
24
|
+
faraday-httpclient (~> 1.0)
|
25
|
+
faraday-multipart (~> 1.0)
|
22
26
|
faraday-net_http (~> 1.0)
|
23
|
-
faraday-net_http_persistent (~> 1.
|
24
|
-
|
27
|
+
faraday-net_http_persistent (~> 1.0)
|
28
|
+
faraday-patron (~> 1.0)
|
29
|
+
faraday-rack (~> 1.0)
|
30
|
+
faraday-retry (~> 1.0)
|
25
31
|
ruby2_keywords (>= 0.0.4)
|
32
|
+
faraday-em_http (1.0.0)
|
33
|
+
faraday-em_synchrony (1.0.0)
|
26
34
|
faraday-excon (1.1.0)
|
35
|
+
faraday-httpclient (1.0.1)
|
36
|
+
faraday-multipart (1.0.4)
|
37
|
+
multipart-post (~> 2)
|
27
38
|
faraday-net_http (1.0.1)
|
28
|
-
faraday-net_http_persistent (1.
|
29
|
-
|
39
|
+
faraday-net_http_persistent (1.2.0)
|
40
|
+
faraday-patron (1.0.0)
|
41
|
+
faraday-rack (1.0.0)
|
42
|
+
faraday-retry (1.0.3)
|
43
|
+
faraday_middleware (1.2.0)
|
30
44
|
faraday (~> 1.0)
|
31
45
|
faraday_middleware-multi_json (0.0.6)
|
32
46
|
faraday_middleware
|
@@ -34,7 +48,7 @@ GEM
|
|
34
48
|
hashdiff (1.0.1)
|
35
49
|
method_source (1.0.0)
|
36
50
|
multi_json (1.15.0)
|
37
|
-
multipart-post (2.
|
51
|
+
multipart-post (2.2.3)
|
38
52
|
pry (0.13.1)
|
39
53
|
coderay (~> 1.1)
|
40
54
|
method_source (~> 1.0)
|
@@ -54,7 +68,7 @@ GEM
|
|
54
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
69
|
rspec-support (~> 3.10.0)
|
56
70
|
rspec-support (3.10.2)
|
57
|
-
ruby2_keywords (0.0.
|
71
|
+
ruby2_keywords (0.0.5)
|
58
72
|
vcr (6.0.0)
|
59
73
|
webmock (3.12.1)
|
60
74
|
addressable (>= 2.3.6)
|
@@ -62,6 +76,7 @@ GEM
|
|
62
76
|
hashdiff (>= 0.4.0, < 2.0.0)
|
63
77
|
|
64
78
|
PLATFORMS
|
79
|
+
-darwin-21
|
65
80
|
x86_64-darwin-19
|
66
81
|
x86_64-linux
|
67
82
|
|
@@ -76,4 +91,4 @@ DEPENDENCIES
|
|
76
91
|
webmock
|
77
92
|
|
78
93
|
BUNDLED WITH
|
79
|
-
2.
|
94
|
+
2.3.10
|
@@ -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
|
@@ -30,7 +30,8 @@ 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
|
33
|
+
CreditGateway.configuration.client_secret,
|
34
|
+
CreditGateway.configuration.country
|
34
35
|
conn.response :multi_json, symbolize_keys: true
|
35
36
|
if CreditGateway.configuration.debug
|
36
37
|
conn.response :logger, nil, { headers: true, bodies: CreditGateway.configuration.verbose }
|
@@ -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.0
|
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: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -187,31 +187,35 @@ files:
|
|
187
187
|
- lib/credit_gateway/balance.rb
|
188
188
|
- lib/credit_gateway/bank_account.rb
|
189
189
|
- lib/credit_gateway/bank_account_scheme.rb
|
190
|
+
- lib/credit_gateway/bank_connection.rb
|
191
|
+
- lib/credit_gateway/bank_connection_params.rb
|
190
192
|
- lib/credit_gateway/bank_data.rb
|
191
193
|
- lib/credit_gateway/bank_data_request.rb
|
194
|
+
- lib/credit_gateway/bank_repository.rb
|
195
|
+
- lib/credit_gateway/bank_subject.rb
|
192
196
|
- lib/credit_gateway/base_model.rb
|
193
197
|
- 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
|
198
|
+
- lib/credit_gateway/camelizer_lower.rb
|
197
199
|
- lib/credit_gateway/camelizer_upper.rb
|
198
200
|
- lib/credit_gateway/client.rb
|
201
|
+
- lib/credit_gateway/company.rb
|
202
|
+
- lib/credit_gateway/company_repository.rb
|
199
203
|
- lib/credit_gateway/configuration.rb
|
200
204
|
- lib/credit_gateway/errors.rb
|
201
205
|
- 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
206
|
- lib/credit_gateway/rating.rb
|
206
|
-
- lib/credit_gateway/
|
207
|
-
- lib/credit_gateway/
|
208
|
-
- lib/credit_gateway/
|
207
|
+
- lib/credit_gateway/rating_component.rb
|
208
|
+
- lib/credit_gateway/rating_metadata.rb
|
209
|
+
- lib/credit_gateway/rating_status.rb
|
210
|
+
- lib/credit_gateway/score.rb
|
211
|
+
- lib/credit_gateway/score_badge.rb
|
212
|
+
- lib/credit_gateway/score_repository.rb
|
209
213
|
- lib/credit_gateway/transaction.rb
|
210
214
|
- lib/credit_gateway/version.rb
|
211
215
|
homepage: https://www.finpoint.co.uk
|
212
216
|
licenses: []
|
213
217
|
metadata: {}
|
214
|
-
post_install_message:
|
218
|
+
post_install_message:
|
215
219
|
rdoc_options: []
|
216
220
|
require_paths:
|
217
221
|
- lib
|
@@ -226,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
230
|
- !ruby/object:Gem::Version
|
227
231
|
version: '0'
|
228
232
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
230
|
-
signing_key:
|
233
|
+
rubygems_version: 3.0.3
|
234
|
+
signing_key:
|
231
235
|
specification_version: 4
|
232
236
|
summary: CRIF CreditGateway client
|
233
237
|
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
|