creditsafe 0.6.2 → 0.6.3
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 +4 -3
- data/.rspec +1 -1
- data/.rubocop.yml +14 -11
- data/.ruby-version +1 -1
- data/CHANGELOG.md +57 -53
- data/Gemfile +5 -5
- data/LICENSE.txt +22 -22
- data/README.md +175 -175
- data/creditsafe.gemspec +34 -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 +165 -165
- data/lib/creditsafe/constants.rb +49 -49
- data/lib/creditsafe/errors.rb +17 -17
- data/lib/creditsafe/match_type.rb +115 -115
- data/lib/creditsafe/messages.rb +98 -98
- data/lib/creditsafe/namespace.rb +20 -20
- data/lib/creditsafe/request/company_report.rb +42 -42
- data/lib/creditsafe/request/find_company.rb +120 -120
- data/lib/creditsafe/version.rb +5 -5
- data/spec/creditsafe/client_spec.rb +431 -431
- 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 +39 -40
- data/Gemfile.lock +0 -129
@@ -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
|
data/lib/creditsafe/messages.rb
CHANGED
@@ -1,98 +1,98 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "creditsafe/errors"
|
4
|
-
|
5
|
-
module Creditsafe
|
6
|
-
module Messages
|
7
|
-
class Message
|
8
|
-
attr_reader :code, :message, :error
|
9
|
-
|
10
|
-
def initialize(code: nil, message: nil, error: false)
|
11
|
-
raise ArgumentError, "Parameters 'code' and 'message' are mandatory" \
|
12
|
-
unless code && message
|
13
|
-
|
14
|
-
@code = code
|
15
|
-
@message = message
|
16
|
-
@error = error
|
17
|
-
end
|
18
|
-
|
19
|
-
alias_method :error?, :error
|
20
|
-
|
21
|
-
def error_class
|
22
|
-
return unless error?
|
23
|
-
|
24
|
-
case code[1].to_i
|
25
|
-
when 1 then Creditsafe::DataError
|
26
|
-
when 2 then Creditsafe::AccountError
|
27
|
-
when 3 then Creditsafe::RequestError
|
28
|
-
when 4 then Creditsafe::ProcessingError
|
29
|
-
else Creditsafe::UnknownApiError
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# rubocop:disable Metrics/LineLength
|
35
|
-
NO_RESULTS = Message.new(code: "010101", message: "No results")
|
36
|
-
TOO_MANY_RESULTS = Message.new(code: "010102", message: "Too many results")
|
37
|
-
REPORT_UNAVAILABLE = Message.new(code: "010103", message: "Report unavailable", error: true)
|
38
|
-
REPORT_UNAVAILABLE_LEGAL = Message.new(code: "010104", message: "Report unavailable due to legal causes", error: true)
|
39
|
-
REPORT_UNAVAILABLE_ONLINE = Message.new(code: "010105", message: "Report unavailable online", error: true)
|
40
|
-
LEGAL_NOTICE = Message.new(code: "010106", message: "Legal notice")
|
41
|
-
INVALID_CREDENTIALS = Message.new(code: "020101", message: "Invalid credentials", error: true)
|
42
|
-
ACCESS_RESTRICTED = Message.new(code: "020102", message: "Access restricted", error: true)
|
43
|
-
ACCESS_LIMITS_NEARING = Message.new(code: "020103", message: "Access limits nearing")
|
44
|
-
REPORTBOX_ALMOST_FULL = Message.new(code: "020201", message: "Reportbox almost full", error: true)
|
45
|
-
REPORTBOX_FULL = Message.new(code: "020202", message: "Reportbox full", error: true)
|
46
|
-
INVALID_REQUEST_XML = Message.new(code: "030101", message: "Invalid request XML", error: true)
|
47
|
-
INVALID_OPERATION_PARAMS = Message.new(code: "030102", message: "Invalid operation parameters", error: true)
|
48
|
-
OPERATION_NOT_SUPPORTED = Message.new(code: "030103", message: "Operation not supported", error: true)
|
49
|
-
INVALID_CUSTOM_DATA_SPECIFIED = Message.new(code: "030104", message: "Invalid custom data specified", error: true)
|
50
|
-
CHANGE_NOTIFICATION = Message.new(code: "030201", message: "Change notification")
|
51
|
-
TEMPORARY_SYSTEM_PROBLEM = Message.new(code: "030202", message: "Temporary system problem", error: true)
|
52
|
-
ENDPOINT_SHUTDOWN = Message.new(code: "030203", message: "Endpoint shutdown", error: true)
|
53
|
-
UNEXPECTED_INTERNAL_ERROR = Message.new(code: "040101", message: "Unexpected internal error", error: true)
|
54
|
-
OTHER_ERROR = Message.new(code: "040102", message: "Other", error: true)
|
55
|
-
DATA_SERVICE_PROBLEMS = Message.new(code: "040103", message: "Data service access problems", error: true)
|
56
|
-
DATA_SERVICE_INVALID_RESPONSE = Message.new(code: "040104", message: "Data service invalid response", error: true)
|
57
|
-
# rubocop:enable Metrics/LineLength
|
58
|
-
|
59
|
-
ALL = [
|
60
|
-
NO_RESULTS,
|
61
|
-
TOO_MANY_RESULTS,
|
62
|
-
REPORT_UNAVAILABLE,
|
63
|
-
REPORT_UNAVAILABLE_LEGAL,
|
64
|
-
REPORT_UNAVAILABLE_ONLINE,
|
65
|
-
LEGAL_NOTICE,
|
66
|
-
INVALID_CREDENTIALS,
|
67
|
-
ACCESS_RESTRICTED,
|
68
|
-
ACCESS_LIMITS_NEARING,
|
69
|
-
REPORTBOX_ALMOST_FULL,
|
70
|
-
REPORTBOX_FULL,
|
71
|
-
INVALID_REQUEST_XML,
|
72
|
-
INVALID_OPERATION_PARAMS,
|
73
|
-
OPERATION_NOT_SUPPORTED,
|
74
|
-
INVALID_CUSTOM_DATA_SPECIFIED,
|
75
|
-
CHANGE_NOTIFICATION,
|
76
|
-
TEMPORARY_SYSTEM_PROBLEM,
|
77
|
-
ENDPOINT_SHUTDOWN,
|
78
|
-
UNEXPECTED_INTERNAL_ERROR,
|
79
|
-
OTHER_ERROR,
|
80
|
-
DATA_SERVICE_PROBLEMS,
|
81
|
-
DATA_SERVICE_INVALID_RESPONSE,
|
82
|
-
].freeze
|
83
|
-
|
84
|
-
# Creditsafe documentation shows a 6 digit error code, however their API
|
85
|
-
# strips the leading 0. To comply with the docs, we pad the API code here to
|
86
|
-
# ensure we find the right match
|
87
|
-
def self.for_code(code)
|
88
|
-
padded_code = code.rjust(6, "0")
|
89
|
-
message = ALL.find { |msg| msg.code == padded_code }
|
90
|
-
|
91
|
-
if message.nil?
|
92
|
-
message = Message.new(code: code, message: "Unknown error", error: true)
|
93
|
-
end
|
94
|
-
|
95
|
-
message
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "creditsafe/errors"
|
4
|
+
|
5
|
+
module Creditsafe
|
6
|
+
module Messages
|
7
|
+
class Message
|
8
|
+
attr_reader :code, :message, :error
|
9
|
+
|
10
|
+
def initialize(code: nil, message: nil, error: false)
|
11
|
+
raise ArgumentError, "Parameters 'code' and 'message' are mandatory" \
|
12
|
+
unless code && message
|
13
|
+
|
14
|
+
@code = code
|
15
|
+
@message = message
|
16
|
+
@error = error
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method :error?, :error
|
20
|
+
|
21
|
+
def error_class
|
22
|
+
return unless error?
|
23
|
+
|
24
|
+
case code[1].to_i
|
25
|
+
when 1 then Creditsafe::DataError
|
26
|
+
when 2 then Creditsafe::AccountError
|
27
|
+
when 3 then Creditsafe::RequestError
|
28
|
+
when 4 then Creditsafe::ProcessingError
|
29
|
+
else Creditsafe::UnknownApiError
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# rubocop:disable Metrics/LineLength
|
35
|
+
NO_RESULTS = Message.new(code: "010101", message: "No results")
|
36
|
+
TOO_MANY_RESULTS = Message.new(code: "010102", message: "Too many results")
|
37
|
+
REPORT_UNAVAILABLE = Message.new(code: "010103", message: "Report unavailable", error: true)
|
38
|
+
REPORT_UNAVAILABLE_LEGAL = Message.new(code: "010104", message: "Report unavailable due to legal causes", error: true)
|
39
|
+
REPORT_UNAVAILABLE_ONLINE = Message.new(code: "010105", message: "Report unavailable online", error: true)
|
40
|
+
LEGAL_NOTICE = Message.new(code: "010106", message: "Legal notice")
|
41
|
+
INVALID_CREDENTIALS = Message.new(code: "020101", message: "Invalid credentials", error: true)
|
42
|
+
ACCESS_RESTRICTED = Message.new(code: "020102", message: "Access restricted", error: true)
|
43
|
+
ACCESS_LIMITS_NEARING = Message.new(code: "020103", message: "Access limits nearing")
|
44
|
+
REPORTBOX_ALMOST_FULL = Message.new(code: "020201", message: "Reportbox almost full", error: true)
|
45
|
+
REPORTBOX_FULL = Message.new(code: "020202", message: "Reportbox full", error: true)
|
46
|
+
INVALID_REQUEST_XML = Message.new(code: "030101", message: "Invalid request XML", error: true)
|
47
|
+
INVALID_OPERATION_PARAMS = Message.new(code: "030102", message: "Invalid operation parameters", error: true)
|
48
|
+
OPERATION_NOT_SUPPORTED = Message.new(code: "030103", message: "Operation not supported", error: true)
|
49
|
+
INVALID_CUSTOM_DATA_SPECIFIED = Message.new(code: "030104", message: "Invalid custom data specified", error: true)
|
50
|
+
CHANGE_NOTIFICATION = Message.new(code: "030201", message: "Change notification")
|
51
|
+
TEMPORARY_SYSTEM_PROBLEM = Message.new(code: "030202", message: "Temporary system problem", error: true)
|
52
|
+
ENDPOINT_SHUTDOWN = Message.new(code: "030203", message: "Endpoint shutdown", error: true)
|
53
|
+
UNEXPECTED_INTERNAL_ERROR = Message.new(code: "040101", message: "Unexpected internal error", error: true)
|
54
|
+
OTHER_ERROR = Message.new(code: "040102", message: "Other", error: true)
|
55
|
+
DATA_SERVICE_PROBLEMS = Message.new(code: "040103", message: "Data service access problems", error: true)
|
56
|
+
DATA_SERVICE_INVALID_RESPONSE = Message.new(code: "040104", message: "Data service invalid response", error: true)
|
57
|
+
# rubocop:enable Metrics/LineLength
|
58
|
+
|
59
|
+
ALL = [
|
60
|
+
NO_RESULTS,
|
61
|
+
TOO_MANY_RESULTS,
|
62
|
+
REPORT_UNAVAILABLE,
|
63
|
+
REPORT_UNAVAILABLE_LEGAL,
|
64
|
+
REPORT_UNAVAILABLE_ONLINE,
|
65
|
+
LEGAL_NOTICE,
|
66
|
+
INVALID_CREDENTIALS,
|
67
|
+
ACCESS_RESTRICTED,
|
68
|
+
ACCESS_LIMITS_NEARING,
|
69
|
+
REPORTBOX_ALMOST_FULL,
|
70
|
+
REPORTBOX_FULL,
|
71
|
+
INVALID_REQUEST_XML,
|
72
|
+
INVALID_OPERATION_PARAMS,
|
73
|
+
OPERATION_NOT_SUPPORTED,
|
74
|
+
INVALID_CUSTOM_DATA_SPECIFIED,
|
75
|
+
CHANGE_NOTIFICATION,
|
76
|
+
TEMPORARY_SYSTEM_PROBLEM,
|
77
|
+
ENDPOINT_SHUTDOWN,
|
78
|
+
UNEXPECTED_INTERNAL_ERROR,
|
79
|
+
OTHER_ERROR,
|
80
|
+
DATA_SERVICE_PROBLEMS,
|
81
|
+
DATA_SERVICE_INVALID_RESPONSE,
|
82
|
+
].freeze
|
83
|
+
|
84
|
+
# Creditsafe documentation shows a 6 digit error code, however their API
|
85
|
+
# strips the leading 0. To comply with the docs, we pad the API code here to
|
86
|
+
# ensure we find the right match
|
87
|
+
def self.for_code(code)
|
88
|
+
padded_code = code.rjust(6, "0")
|
89
|
+
message = ALL.find { |msg| msg.code == padded_code }
|
90
|
+
|
91
|
+
if message.nil?
|
92
|
+
message = Message.new(code: code, message: "Unknown error", error: true)
|
93
|
+
end
|
94
|
+
|
95
|
+
message
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/creditsafe/namespace.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Creditsafe
|
4
|
-
module Namespace
|
5
|
-
OPER = "oper"
|
6
|
-
OPER_VAL = "http://www.creditsafe.com/globaldata/operations"
|
7
|
-
|
8
|
-
DAT = "dat"
|
9
|
-
DAT_VAL = "http://www.creditsafe.com/globaldata/datatypes"
|
10
|
-
|
11
|
-
CRED = "cred"
|
12
|
-
CRED_VAL = "http://schemas.datacontract.org/2004/07/Creditsafe.GlobalData"
|
13
|
-
|
14
|
-
ALL = {
|
15
|
-
"xmlns:#{Creditsafe::Namespace::OPER}" => Creditsafe::Namespace::OPER_VAL,
|
16
|
-
"xmlns:#{Creditsafe::Namespace::DAT}" => Creditsafe::Namespace::DAT_VAL,
|
17
|
-
"xmlns:#{Creditsafe::Namespace::CRED}" => Creditsafe::Namespace::CRED_VAL,
|
18
|
-
}.freeze
|
19
|
-
end
|
20
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditsafe
|
4
|
+
module Namespace
|
5
|
+
OPER = "oper"
|
6
|
+
OPER_VAL = "http://www.creditsafe.com/globaldata/operations"
|
7
|
+
|
8
|
+
DAT = "dat"
|
9
|
+
DAT_VAL = "http://www.creditsafe.com/globaldata/datatypes"
|
10
|
+
|
11
|
+
CRED = "cred"
|
12
|
+
CRED_VAL = "http://schemas.datacontract.org/2004/07/Creditsafe.GlobalData"
|
13
|
+
|
14
|
+
ALL = {
|
15
|
+
"xmlns:#{Creditsafe::Namespace::OPER}" => Creditsafe::Namespace::OPER_VAL,
|
16
|
+
"xmlns:#{Creditsafe::Namespace::DAT}" => Creditsafe::Namespace::DAT_VAL,
|
17
|
+
"xmlns:#{Creditsafe::Namespace::CRED}" => Creditsafe::Namespace::CRED_VAL,
|
18
|
+
}.freeze
|
19
|
+
end
|
20
|
+
end
|