creditsafe 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +17 -17
- data/.gitignore +2 -2
- data/.rspec +1 -1
- data/.rubocop.yml +11 -11
- data/.ruby-version +1 -1
- data/CHANGELOG.md +41 -37
- data/Gemfile +5 -5
- data/Gemfile.lock +127 -125
- data/LICENSE.txt +22 -22
- data/README.md +138 -138
- data/creditsafe.gemspec +35 -35
- data/data/creditsafe-live.xml +342 -342
- data/data/creditsafe-test.xml +342 -342
- data/lib/creditsafe.rb +4 -4
- data/lib/creditsafe/client.rb +158 -156
- data/lib/creditsafe/errors.rb +16 -14
- data/lib/creditsafe/match_type.rb +115 -115
- data/lib/creditsafe/messages.rb +97 -97
- data/lib/creditsafe/namespace.rb +20 -20
- data/lib/creditsafe/request/company_report.rb +42 -42
- data/lib/creditsafe/request/find_company.rb +98 -98
- data/lib/creditsafe/version.rb +5 -5
- data/spec/creditsafe/client_spec.rb +369 -372
- data/spec/creditsafe/messages_spec.rb +76 -76
- data/spec/fixtures/company-report-not-found.xml +13 -13
- data/spec/fixtures/company-report-request.xml +1 -1
- data/spec/fixtures/company-report-successful.xml +582 -582
- data/spec/fixtures/error-fault.xml +8 -8
- data/spec/fixtures/error-invalid-credentials.html +31 -31
- data/spec/fixtures/find-companies-error-no-text.xml +11 -11
- data/spec/fixtures/find-companies-error.xml +11 -11
- data/spec/fixtures/find-companies-none-found.xml +13 -13
- data/spec/fixtures/find-companies-request.xml +1 -1
- data/spec/fixtures/find-companies-successful-multi.xml +493 -493
- data/spec/fixtures/find-companies-successful.xml +29 -29
- data/spec/spec_helper.rb +14 -14
- metadata +4 -4
data/lib/creditsafe.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "creditsafe/errors"
|
4
|
-
require "creditsafe/client"
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "creditsafe/errors"
|
4
|
+
require "creditsafe/client"
|
data/lib/creditsafe/client.rb
CHANGED
@@ -1,156 +1,158 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "securerandom"
|
4
|
-
require "savon"
|
5
|
-
require "excon"
|
6
|
-
|
7
|
-
require "creditsafe/errors"
|
8
|
-
require "creditsafe/messages"
|
9
|
-
require "creditsafe/namespace"
|
10
|
-
|
11
|
-
require "creditsafe/request/company_report"
|
12
|
-
require "creditsafe/request/find_company"
|
13
|
-
|
14
|
-
require "active_support/notifications"
|
15
|
-
|
16
|
-
module Creditsafe
|
17
|
-
class Client
|
18
|
-
ENVIRONMENTS = %i[live test].freeze
|
19
|
-
|
20
|
-
def initialize(username: nil, password: nil, savon_opts: {},
|
21
|
-
environment: :live, log_level: :warn)
|
22
|
-
raise ArgumentError, "Username must be provided" if username.nil?
|
23
|
-
raise ArgumentError, "Password must be provided" if password.nil?
|
24
|
-
|
25
|
-
unless ENVIRONMENTS.include?(environment.to_sym)
|
26
|
-
raise ArgumentError, "Environment needs to be one of #{ENVIRONMENTS.join('/')}"
|
27
|
-
end
|
28
|
-
|
29
|
-
@environment = environment.to_s
|
30
|
-
@log_level = log_level
|
31
|
-
@username = username
|
32
|
-
@password = password
|
33
|
-
@savon_opts = savon_opts
|
34
|
-
end
|
35
|
-
|
36
|
-
def find_company(search_criteria = {})
|
37
|
-
request = Creditsafe::Request::FindCompany.new(search_criteria)
|
38
|
-
response = invoke_soap(:find_companies, request.message)
|
39
|
-
|
40
|
-
companies = response.
|
41
|
-
fetch(:find_companies_response).
|
42
|
-
fetch(:find_companies_result).
|
43
|
-
fetch(:companies)
|
44
|
-
|
45
|
-
companies.nil? ? nil : companies.fetch(:company)
|
46
|
-
end
|
47
|
-
|
48
|
-
def company_report(creditsafe_id, custom_data: nil)
|
49
|
-
request =
|
50
|
-
Creditsafe::Request::CompanyReport.new(creditsafe_id, custom_data)
|
51
|
-
response = invoke_soap(:retrieve_company_online_report, request.message)
|
52
|
-
|
53
|
-
response.
|
54
|
-
fetch(:retrieve_company_online_report_response).
|
55
|
-
fetch(:retrieve_company_online_report_result).
|
56
|
-
fetch(:reports).
|
57
|
-
fetch(:report)
|
58
|
-
end
|
59
|
-
|
60
|
-
def inspect
|
61
|
-
"#<#{self.class} @username='#{@username}'>"
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def handle_message_for_response(response)
|
67
|
-
[
|
68
|
-
*response.xpath("//q1:Message"),
|
69
|
-
*response.xpath("//xmlns:Message"),
|
70
|
-
].each do |message|
|
71
|
-
api_message = Creditsafe::Messages.for_code(message.attributes["Code"].value)
|
72
|
-
|
73
|
-
api_error_message = api_message.message
|
74
|
-
api_error_message += " (#{message.text})" unless message.text.blank?
|
75
|
-
|
76
|
-
raise api_message.error_class, api_error_message if api_message.error?
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# rubocop:disable Style/RescueStandardError
|
81
|
-
# rubocop:disable Metrics/MethodLength
|
82
|
-
def invoke_soap(message_type, message)
|
83
|
-
started = Time.now
|
84
|
-
notification_payload = { request: message }
|
85
|
-
|
86
|
-
response = client.call(message_type, message: message)
|
87
|
-
handle_message_for_response(response)
|
88
|
-
notification_payload[:response] = response.body
|
89
|
-
rescue
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
when Savon::
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
return
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "securerandom"
|
4
|
+
require "savon"
|
5
|
+
require "excon"
|
6
|
+
|
7
|
+
require "creditsafe/errors"
|
8
|
+
require "creditsafe/messages"
|
9
|
+
require "creditsafe/namespace"
|
10
|
+
|
11
|
+
require "creditsafe/request/company_report"
|
12
|
+
require "creditsafe/request/find_company"
|
13
|
+
|
14
|
+
require "active_support/notifications"
|
15
|
+
|
16
|
+
module Creditsafe
|
17
|
+
class Client
|
18
|
+
ENVIRONMENTS = %i[live test].freeze
|
19
|
+
|
20
|
+
def initialize(username: nil, password: nil, savon_opts: {},
|
21
|
+
environment: :live, log_level: :warn)
|
22
|
+
raise ArgumentError, "Username must be provided" if username.nil?
|
23
|
+
raise ArgumentError, "Password must be provided" if password.nil?
|
24
|
+
|
25
|
+
unless ENVIRONMENTS.include?(environment.to_sym)
|
26
|
+
raise ArgumentError, "Environment needs to be one of #{ENVIRONMENTS.join('/')}"
|
27
|
+
end
|
28
|
+
|
29
|
+
@environment = environment.to_s
|
30
|
+
@log_level = log_level
|
31
|
+
@username = username
|
32
|
+
@password = password
|
33
|
+
@savon_opts = savon_opts
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_company(search_criteria = {})
|
37
|
+
request = Creditsafe::Request::FindCompany.new(search_criteria)
|
38
|
+
response = invoke_soap(:find_companies, request.message)
|
39
|
+
|
40
|
+
companies = response.
|
41
|
+
fetch(:find_companies_response).
|
42
|
+
fetch(:find_companies_result).
|
43
|
+
fetch(:companies)
|
44
|
+
|
45
|
+
companies.nil? ? nil : companies.fetch(:company)
|
46
|
+
end
|
47
|
+
|
48
|
+
def company_report(creditsafe_id, custom_data: nil)
|
49
|
+
request =
|
50
|
+
Creditsafe::Request::CompanyReport.new(creditsafe_id, custom_data)
|
51
|
+
response = invoke_soap(:retrieve_company_online_report, request.message)
|
52
|
+
|
53
|
+
response.
|
54
|
+
fetch(:retrieve_company_online_report_response).
|
55
|
+
fetch(:retrieve_company_online_report_result).
|
56
|
+
fetch(:reports).
|
57
|
+
fetch(:report)
|
58
|
+
end
|
59
|
+
|
60
|
+
def inspect
|
61
|
+
"#<#{self.class} @username='#{@username}'>"
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def handle_message_for_response(response)
|
67
|
+
[
|
68
|
+
*response.xpath("//q1:Message"),
|
69
|
+
*response.xpath("//xmlns:Message"),
|
70
|
+
].each do |message|
|
71
|
+
api_message = Creditsafe::Messages.for_code(message.attributes["Code"].value)
|
72
|
+
|
73
|
+
api_error_message = api_message.message
|
74
|
+
api_error_message += " (#{message.text})" unless message.text.blank?
|
75
|
+
|
76
|
+
raise api_message.error_class, api_error_message if api_message.error?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# rubocop:disable Style/RescueStandardError
|
81
|
+
# rubocop:disable Metrics/MethodLength
|
82
|
+
def invoke_soap(message_type, message)
|
83
|
+
started = Time.now
|
84
|
+
notification_payload = { request: message }
|
85
|
+
|
86
|
+
response = client.call(message_type, message: message)
|
87
|
+
handle_message_for_response(response)
|
88
|
+
notification_payload[:response] = response.body
|
89
|
+
rescue Excon::Errors::Timeout
|
90
|
+
raise TimeoutError
|
91
|
+
rescue => raw_error
|
92
|
+
processed_error = handle_error(raw_error)
|
93
|
+
notification_payload[:error] = processed_error
|
94
|
+
raise processed_error
|
95
|
+
ensure
|
96
|
+
publish("creditsafe.#{message_type}", started, Time.now,
|
97
|
+
SecureRandom.hex(10), notification_payload)
|
98
|
+
end
|
99
|
+
# rubocop:enable Metrics/MethodLength
|
100
|
+
# rubocop:enable Style/RescueStandardError
|
101
|
+
|
102
|
+
def publish(*args)
|
103
|
+
ActiveSupport::Notifications.publish(*args)
|
104
|
+
end
|
105
|
+
|
106
|
+
# There's a potential bug in the creditsafe API where they actually return
|
107
|
+
# an HTTP 401 if you're unauthorized, hence the sad special case below
|
108
|
+
#
|
109
|
+
# rubocop:disable Metrics/MethodLength
|
110
|
+
def handle_error(error)
|
111
|
+
case error
|
112
|
+
when Savon::SOAPFault
|
113
|
+
return UnknownApiError.new(error.message)
|
114
|
+
when Savon::HTTPError
|
115
|
+
if error.to_hash[:code] == 401
|
116
|
+
return AccountError.new("Unauthorized: invalid credentials")
|
117
|
+
end
|
118
|
+
return UnknownApiError.new(error.message)
|
119
|
+
when Excon::Errors::Error
|
120
|
+
return HttpError.new("Error making HTTP request: #{error.message}")
|
121
|
+
end
|
122
|
+
error
|
123
|
+
end
|
124
|
+
# rubocop:enable Metrics/MethodLength
|
125
|
+
|
126
|
+
def client
|
127
|
+
@client ||= build_savon_client
|
128
|
+
end
|
129
|
+
|
130
|
+
def auth_header
|
131
|
+
auth_value = "Basic " + Base64.encode64("#{@username}:#{@password}").chomp
|
132
|
+
{ "Authorization" => auth_value }
|
133
|
+
end
|
134
|
+
|
135
|
+
# rubocop:disable Metrics/MethodLength
|
136
|
+
def build_savon_client
|
137
|
+
options = {
|
138
|
+
env_namespace: "soapenv",
|
139
|
+
namespace_identifier: Creditsafe::Namespace::OPER,
|
140
|
+
namespaces: Creditsafe::Namespace::ALL,
|
141
|
+
wsdl: wsdl_path,
|
142
|
+
headers: auth_header,
|
143
|
+
convert_request_keys_to: :none,
|
144
|
+
adapter: :excon,
|
145
|
+
log: true,
|
146
|
+
log_level: @log_level,
|
147
|
+
pretty_print_xml: true,
|
148
|
+
}
|
149
|
+
Savon.client(options.merge(@savon_opts))
|
150
|
+
end
|
151
|
+
# rubocop:enable Metrics/MethodLength
|
152
|
+
|
153
|
+
def wsdl_path
|
154
|
+
root_dir = File.join(File.dirname(__FILE__), "..", "..")
|
155
|
+
File.join(root_dir, "data", "creditsafe-#{@environment}.xml")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
data/lib/creditsafe/errors.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Creditsafe
|
4
|
-
class Error < StandardError; end
|
5
|
-
|
6
|
-
class HttpError < Error; end
|
7
|
-
class ApiError < Error; end
|
8
|
-
|
9
|
-
class
|
10
|
-
|
11
|
-
class
|
12
|
-
class
|
13
|
-
class
|
14
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditsafe
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class HttpError < Error; end
|
7
|
+
class ApiError < Error; end
|
8
|
+
|
9
|
+
class TimeoutError < HttpError; end
|
10
|
+
|
11
|
+
class DataError < ApiError; end
|
12
|
+
class AccountError < ApiError; end
|
13
|
+
class RequestError < ApiError; end
|
14
|
+
class ProcessingError < ApiError; end
|
15
|
+
class UnknownApiError < ApiError; end
|
16
|
+
end
|
@@ -1,115 +1,115 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Creditsafe
|
4
|
-
module MatchType
|
5
|
-
MATCH_BEGINNING = "MatchBeginning"
|
6
|
-
MATCH_BLOCK = "MatchBlock"
|
7
|
-
EXACT_VALUE = "ExactValue"
|
8
|
-
MATCH_WORDS = "MatchWords"
|
9
|
-
CLOSEST_KEYWORDS = "ClosestKeywords"
|
10
|
-
MATCH_BLOCK_OR_WORDS = "MatchBlockOrWords"
|
11
|
-
MATCH_ANY_PARTS = "MatchAnyParts"
|
12
|
-
|
13
|
-
ALLOWED = {
|
14
|
-
DE: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE, MATCH_WORDS],
|
15
|
-
FR: [MATCH_BEGINNING, CLOSEST_KEYWORDS, EXACT_VALUE],
|
16
|
-
GB: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, EXACT_VALUE],
|
17
|
-
IE: [MATCH_BEGINNING, MATCH_BLOCK, MATCH_WORDS],
|
18
|
-
GL: [MATCH_BEGINNING],
|
19
|
-
CH: [CLOSEST_KEYWORDS],
|
20
|
-
LI: [CLOSEST_KEYWORDS],
|
21
|
-
NL: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
|
22
|
-
CZ: [MATCH_BLOCK_OR_WORDS],
|
23
|
-
IS: [MATCH_BEGINNING],
|
24
|
-
LT: [MATCH_ANY_PARTS],
|
25
|
-
MT: [MATCH_BEGINNING, MATCH_BLOCK],
|
26
|
-
SK: [MATCH_BLOCK_OR_WORDS],
|
27
|
-
BE: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
|
28
|
-
SE: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
|
29
|
-
PL: [CLOSEST_KEYWORDS],
|
30
|
-
NO: [CLOSEST_KEYWORDS],
|
31
|
-
PT: [MATCH_BEGINNING],
|
32
|
-
LU: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE],
|
33
|
-
CA: [MATCH_BEGINNING],
|
34
|
-
ES: [EXACT_VALUE, CLOSEST_KEYWORDS],
|
35
|
-
US: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
36
|
-
PR: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
37
|
-
AS: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
38
|
-
FM: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
39
|
-
GU: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
40
|
-
MH: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
41
|
-
MP: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
42
|
-
PW: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
43
|
-
VI: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
44
|
-
SI: [MATCH_BLOCK_OR_WORDS],
|
45
|
-
AL: [MATCH_BLOCK_OR_WORDS],
|
46
|
-
BA: [MATCH_BLOCK_OR_WORDS],
|
47
|
-
HR: [MATCH_BLOCK_OR_WORDS],
|
48
|
-
MK: [MATCH_BLOCK_OR_WORDS],
|
49
|
-
BG: [MATCH_BLOCK_OR_WORDS],
|
50
|
-
RO: [MATCH_BLOCK_OR_WORDS],
|
51
|
-
ME: [MATCH_BLOCK_OR_WORDS],
|
52
|
-
RS: [MATCH_BLOCK_OR_WORDS],
|
53
|
-
LV: [MATCH_BLOCK_OR_WORDS],
|
54
|
-
EE: [MATCH_BLOCK_OR_WORDS],
|
55
|
-
UA: [MATCH_BLOCK_OR_WORDS],
|
56
|
-
MD: [MATCH_BLOCK_OR_WORDS],
|
57
|
-
RU: [MATCH_BLOCK_OR_WORDS],
|
58
|
-
AM: [MATCH_BLOCK_OR_WORDS],
|
59
|
-
AZ: [MATCH_BLOCK_OR_WORDS],
|
60
|
-
BY: [MATCH_BLOCK_OR_WORDS],
|
61
|
-
GE: [MATCH_BLOCK_OR_WORDS],
|
62
|
-
KZ: [MATCH_BLOCK_OR_WORDS],
|
63
|
-
UZ: [MATCH_BLOCK_OR_WORDS],
|
64
|
-
TJ: [MATCH_BLOCK_OR_WORDS],
|
65
|
-
TM: [MATCH_BLOCK_OR_WORDS],
|
66
|
-
KG: [MATCH_BLOCK_OR_WORDS],
|
67
|
-
KM: [MATCH_BLOCK_OR_WORDS],
|
68
|
-
HK: [MATCH_BLOCK_OR_WORDS],
|
69
|
-
AT: [MATCH_WORDS],
|
70
|
-
IT: [CLOSEST_KEYWORDS, EXACT_VALUE],
|
71
|
-
BR: [CLOSEST_KEYWORDS],
|
72
|
-
HU: [MATCH_BEGINNING],
|
73
|
-
TW: [MATCH_BEGINNING],
|
74
|
-
KR: [MATCH_BLOCK_OR_WORDS],
|
75
|
-
FI: [CLOSEST_KEYWORDS],
|
76
|
-
MX: [CLOSEST_KEYWORDS],
|
77
|
-
DK: [MATCH_BEGINNING],
|
78
|
-
AU: [CLOSEST_KEYWORDS],
|
79
|
-
CN: [CLOSEST_KEYWORDS],
|
80
|
-
IN: [CLOSEST_KEYWORDS],
|
81
|
-
BD: [CLOSEST_KEYWORDS],
|
82
|
-
LK: [CLOSEST_KEYWORDS],
|
83
|
-
PK: [CLOSEST_KEYWORDS],
|
84
|
-
NP: [CLOSEST_KEYWORDS],
|
85
|
-
TH: [CLOSEST_KEYWORDS],
|
86
|
-
MY: [CLOSEST_KEYWORDS],
|
87
|
-
VN: [CLOSEST_KEYWORDS],
|
88
|
-
KH: [CLOSEST_KEYWORDS],
|
89
|
-
MM: [CLOSEST_KEYWORDS],
|
90
|
-
LA: [CLOSEST_KEYWORDS],
|
91
|
-
AF: [CLOSEST_KEYWORDS],
|
92
|
-
ID: [CLOSEST_KEYWORDS],
|
93
|
-
NZ: [CLOSEST_KEYWORDS],
|
94
|
-
SG: [CLOSEST_KEYWORDS],
|
95
|
-
BH: [CLOSEST_KEYWORDS],
|
96
|
-
BJ: [CLOSEST_KEYWORDS],
|
97
|
-
BF: [CLOSEST_KEYWORDS],
|
98
|
-
CD: [CLOSEST_KEYWORDS],
|
99
|
-
EG: [CLOSEST_KEYWORDS],
|
100
|
-
JO: [CLOSEST_KEYWORDS],
|
101
|
-
KW: [CLOSEST_KEYWORDS],
|
102
|
-
LB: [CLOSEST_KEYWORDS],
|
103
|
-
OM: [CLOSEST_KEYWORDS],
|
104
|
-
PS: [CLOSEST_KEYWORDS],
|
105
|
-
QA: [CLOSEST_KEYWORDS],
|
106
|
-
SA: [CLOSEST_KEYWORDS],
|
107
|
-
SD: [CLOSEST_KEYWORDS],
|
108
|
-
SY: [CLOSEST_KEYWORDS],
|
109
|
-
AE: [CLOSEST_KEYWORDS],
|
110
|
-
EH: [CLOSEST_KEYWORDS],
|
111
|
-
YE: [CLOSEST_KEYWORDS],
|
112
|
-
GR: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
|
113
|
-
}.freeze
|
114
|
-
end
|
115
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditsafe
|
4
|
+
module MatchType
|
5
|
+
MATCH_BEGINNING = "MatchBeginning"
|
6
|
+
MATCH_BLOCK = "MatchBlock"
|
7
|
+
EXACT_VALUE = "ExactValue"
|
8
|
+
MATCH_WORDS = "MatchWords"
|
9
|
+
CLOSEST_KEYWORDS = "ClosestKeywords"
|
10
|
+
MATCH_BLOCK_OR_WORDS = "MatchBlockOrWords"
|
11
|
+
MATCH_ANY_PARTS = "MatchAnyParts"
|
12
|
+
|
13
|
+
ALLOWED = {
|
14
|
+
DE: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE, MATCH_WORDS],
|
15
|
+
FR: [MATCH_BEGINNING, CLOSEST_KEYWORDS, EXACT_VALUE],
|
16
|
+
GB: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, EXACT_VALUE],
|
17
|
+
IE: [MATCH_BEGINNING, MATCH_BLOCK, MATCH_WORDS],
|
18
|
+
GL: [MATCH_BEGINNING],
|
19
|
+
CH: [CLOSEST_KEYWORDS],
|
20
|
+
LI: [CLOSEST_KEYWORDS],
|
21
|
+
NL: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
|
22
|
+
CZ: [MATCH_BLOCK_OR_WORDS],
|
23
|
+
IS: [MATCH_BEGINNING],
|
24
|
+
LT: [MATCH_ANY_PARTS],
|
25
|
+
MT: [MATCH_BEGINNING, MATCH_BLOCK],
|
26
|
+
SK: [MATCH_BLOCK_OR_WORDS],
|
27
|
+
BE: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
|
28
|
+
SE: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
|
29
|
+
PL: [CLOSEST_KEYWORDS],
|
30
|
+
NO: [CLOSEST_KEYWORDS],
|
31
|
+
PT: [MATCH_BEGINNING],
|
32
|
+
LU: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE],
|
33
|
+
CA: [MATCH_BEGINNING],
|
34
|
+
ES: [EXACT_VALUE, CLOSEST_KEYWORDS],
|
35
|
+
US: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
36
|
+
PR: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
37
|
+
AS: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
38
|
+
FM: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
39
|
+
GU: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
40
|
+
MH: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
41
|
+
MP: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
42
|
+
PW: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
43
|
+
VI: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
|
44
|
+
SI: [MATCH_BLOCK_OR_WORDS],
|
45
|
+
AL: [MATCH_BLOCK_OR_WORDS],
|
46
|
+
BA: [MATCH_BLOCK_OR_WORDS],
|
47
|
+
HR: [MATCH_BLOCK_OR_WORDS],
|
48
|
+
MK: [MATCH_BLOCK_OR_WORDS],
|
49
|
+
BG: [MATCH_BLOCK_OR_WORDS],
|
50
|
+
RO: [MATCH_BLOCK_OR_WORDS],
|
51
|
+
ME: [MATCH_BLOCK_OR_WORDS],
|
52
|
+
RS: [MATCH_BLOCK_OR_WORDS],
|
53
|
+
LV: [MATCH_BLOCK_OR_WORDS],
|
54
|
+
EE: [MATCH_BLOCK_OR_WORDS],
|
55
|
+
UA: [MATCH_BLOCK_OR_WORDS],
|
56
|
+
MD: [MATCH_BLOCK_OR_WORDS],
|
57
|
+
RU: [MATCH_BLOCK_OR_WORDS],
|
58
|
+
AM: [MATCH_BLOCK_OR_WORDS],
|
59
|
+
AZ: [MATCH_BLOCK_OR_WORDS],
|
60
|
+
BY: [MATCH_BLOCK_OR_WORDS],
|
61
|
+
GE: [MATCH_BLOCK_OR_WORDS],
|
62
|
+
KZ: [MATCH_BLOCK_OR_WORDS],
|
63
|
+
UZ: [MATCH_BLOCK_OR_WORDS],
|
64
|
+
TJ: [MATCH_BLOCK_OR_WORDS],
|
65
|
+
TM: [MATCH_BLOCK_OR_WORDS],
|
66
|
+
KG: [MATCH_BLOCK_OR_WORDS],
|
67
|
+
KM: [MATCH_BLOCK_OR_WORDS],
|
68
|
+
HK: [MATCH_BLOCK_OR_WORDS],
|
69
|
+
AT: [MATCH_WORDS],
|
70
|
+
IT: [CLOSEST_KEYWORDS, EXACT_VALUE],
|
71
|
+
BR: [CLOSEST_KEYWORDS],
|
72
|
+
HU: [MATCH_BEGINNING],
|
73
|
+
TW: [MATCH_BEGINNING],
|
74
|
+
KR: [MATCH_BLOCK_OR_WORDS],
|
75
|
+
FI: [CLOSEST_KEYWORDS],
|
76
|
+
MX: [CLOSEST_KEYWORDS],
|
77
|
+
DK: [MATCH_BEGINNING],
|
78
|
+
AU: [CLOSEST_KEYWORDS],
|
79
|
+
CN: [CLOSEST_KEYWORDS],
|
80
|
+
IN: [CLOSEST_KEYWORDS],
|
81
|
+
BD: [CLOSEST_KEYWORDS],
|
82
|
+
LK: [CLOSEST_KEYWORDS],
|
83
|
+
PK: [CLOSEST_KEYWORDS],
|
84
|
+
NP: [CLOSEST_KEYWORDS],
|
85
|
+
TH: [CLOSEST_KEYWORDS],
|
86
|
+
MY: [CLOSEST_KEYWORDS],
|
87
|
+
VN: [CLOSEST_KEYWORDS],
|
88
|
+
KH: [CLOSEST_KEYWORDS],
|
89
|
+
MM: [CLOSEST_KEYWORDS],
|
90
|
+
LA: [CLOSEST_KEYWORDS],
|
91
|
+
AF: [CLOSEST_KEYWORDS],
|
92
|
+
ID: [CLOSEST_KEYWORDS],
|
93
|
+
NZ: [CLOSEST_KEYWORDS],
|
94
|
+
SG: [CLOSEST_KEYWORDS],
|
95
|
+
BH: [CLOSEST_KEYWORDS],
|
96
|
+
BJ: [CLOSEST_KEYWORDS],
|
97
|
+
BF: [CLOSEST_KEYWORDS],
|
98
|
+
CD: [CLOSEST_KEYWORDS],
|
99
|
+
EG: [CLOSEST_KEYWORDS],
|
100
|
+
JO: [CLOSEST_KEYWORDS],
|
101
|
+
KW: [CLOSEST_KEYWORDS],
|
102
|
+
LB: [CLOSEST_KEYWORDS],
|
103
|
+
OM: [CLOSEST_KEYWORDS],
|
104
|
+
PS: [CLOSEST_KEYWORDS],
|
105
|
+
QA: [CLOSEST_KEYWORDS],
|
106
|
+
SA: [CLOSEST_KEYWORDS],
|
107
|
+
SD: [CLOSEST_KEYWORDS],
|
108
|
+
SY: [CLOSEST_KEYWORDS],
|
109
|
+
AE: [CLOSEST_KEYWORDS],
|
110
|
+
EH: [CLOSEST_KEYWORDS],
|
111
|
+
YE: [CLOSEST_KEYWORDS],
|
112
|
+
GR: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
|
113
|
+
}.freeze
|
114
|
+
end
|
115
|
+
end
|