creditsafe 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8efad9c046062a13533c0b1d9b6952e8bc3322d4
4
- data.tar.gz: 4e3c8602dbeda52622424508c17fe77b85680df3
3
+ metadata.gz: 3cf10bbe9d25943eba61401c89e707d6d67d9c0a
4
+ data.tar.gz: 974f5a3dcfc5fd49d2d129785455e8985522a145
5
5
  SHA512:
6
- metadata.gz: e05840b5d34c6952eff251ca34c57fcb5587197a212780a9e55d52d4dd99a9927d0c855b4021b9a8772ad800850df59a482397add073ea3a815a796bfd769bad
7
- data.tar.gz: a1e3ce8720cae12415215fa4affdee2864f873267077d84fd4b98ddc591236b02ea16eb78f28367b12bc39f302c9bd790b8cbea043aa8080876be28b42809b28
6
+ metadata.gz: 75e79d97a4eea7b884d5a185c5cdbce1546c46bdb010c6c2a75b8fc23929169a7b2d64714ca42085b26b6649b1cc1e03852fc9609f3b8a99e09df5d359dd917b
7
+ data.tar.gz: 4589ea126e0f5056668a73853f166853b90427d28bd411c94e0cd140061659d081884f9f51f96313f13111607beb0810a81b10b007af418c7106258aff5da904
data/.rubocop.yml CHANGED
@@ -1,24 +1,11 @@
1
- inherit_from: .rubocop_todo.yml
1
+ inherit_gem:
2
+ gc_ruboconfig: rubocop.yml
2
3
 
3
- # Avoid single-line methods.
4
- SingleLineMethods:
5
- AllowIfMethodIsEmpty: true
4
+ RSpec/NestedGroups:
5
+ Max: 5
6
6
 
7
- StringLiterals:
8
- Enabled: false
7
+ RSpec/ExampleLength:
8
+ Max: 20
9
9
 
10
- Style/SignalException:
11
- EnforcedStyle: 'only_raise'
12
-
13
- # Use trailing rather than leading dots on multi-line call chains
14
- Style/DotPosition:
15
- EnforcedStyle: trailing
16
-
17
- Style/Documentation:
18
- Enabled: false
19
-
20
- Metrics/LineLength:
21
- Max: 90
22
-
23
- Metrics/ModuleLength:
24
- Max: 120
10
+ RSpec/MultipleExpectations:
11
+ Max: 2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.5.1, 1 March 2018
2
+
3
+ - Update allowed MatchTypes for some geos to reflect real world tests
4
+
1
5
  ## v0.5.0, 27 February 2018
2
6
 
3
7
  - Automatically chooses a valid MatchType when searching for companies by name
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source 'https://rubygems.org'
3
4
 
4
5
  gemspec
5
-
6
- gem 'pry'
7
- gem 'pry-byebug'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- creditsafe (0.5.0)
4
+ creditsafe (0.5.1)
5
5
  activesupport (>= 4.2.0)
6
6
  excon (~> 0.45)
7
7
  savon (~> 2.8)
@@ -18,10 +18,9 @@ GEM
18
18
  akami (1.3.1)
19
19
  gyoku (>= 0.4.0)
20
20
  nokogiri
21
- ast (2.3.0)
21
+ ast (2.4.0)
22
22
  builder (3.2.3)
23
- byebug (9.0.5)
24
- coderay (1.1.1)
23
+ coderay (1.1.2)
25
24
  compare-xml (0.65)
26
25
  nokogiri (~> 1.8)
27
26
  concurrent-ruby (1.0.5)
@@ -29,25 +28,9 @@ GEM
29
28
  safe_yaml (~> 1.0.0)
30
29
  diff-lcs (1.3)
31
30
  excon (0.60.0)
32
- ffi (1.9.14)
33
- formatador (0.2.5)
34
- guard (2.14.0)
35
- formatador (>= 0.2.4)
36
- listen (>= 2.7, < 4.0)
37
- lumberjack (~> 1.0)
38
- nenv (~> 0.1)
39
- notiffany (~> 0.0)
40
- pry (>= 0.9.12)
41
- shellany (~> 0.0)
42
- thor (>= 0.18.1)
43
- guard-compat (1.2.1)
44
- guard-rspec (4.7.3)
45
- guard (~> 2.1)
46
- guard-compat (~> 1.1)
47
- rspec (>= 2.99.0, < 4.0)
48
- guard-rubocop (1.2.0)
49
- guard (~> 2.0)
50
- rubocop (~> 0.20)
31
+ gc_ruboconfig (2.3.2)
32
+ rubocop (~> 0.52.1)
33
+ rubocop-rspec (~> 1.22.0)
51
34
  gyoku (1.3.1)
52
35
  builder (>= 2.1.2)
53
36
  hashdiff (0.3.0)
@@ -56,36 +39,21 @@ GEM
56
39
  socksify
57
40
  i18n (0.9.5)
58
41
  concurrent-ruby (~> 1.0)
59
- listen (3.1.5)
60
- rb-fsevent (~> 0.9, >= 0.9.4)
61
- rb-inotify (~> 0.9, >= 0.9.7)
62
- ruby_dep (~> 1.2)
63
- lumberjack (1.0.10)
64
- method_source (0.8.2)
42
+ method_source (0.9.0)
65
43
  mini_portile2 (2.3.0)
66
44
  minitest (5.11.3)
67
- nenv (0.3.0)
68
45
  nokogiri (1.8.2)
69
46
  mini_portile2 (~> 2.3.0)
70
47
  nori (2.6.0)
71
- notiffany (0.1.1)
72
- nenv (~> 0.1)
73
- shellany (~> 0.0)
74
- parser (2.3.1.2)
75
- ast (~> 2.2)
48
+ parallel (1.12.1)
49
+ parser (2.5.0.2)
50
+ ast (~> 2.4.0)
76
51
  powerpack (0.1.1)
77
- pry (0.10.4)
52
+ pry (0.11.3)
78
53
  coderay (~> 1.1.0)
79
- method_source (~> 0.8.1)
80
- slop (~> 3.4)
81
- pry-byebug (3.4.0)
82
- byebug (~> 9.0)
83
- pry (~> 0.10)
54
+ method_source (~> 0.9.0)
84
55
  rack (2.0.4)
85
- rainbow (2.1.0)
86
- rb-fsevent (0.9.7)
87
- rb-inotify (0.9.7)
88
- ffi (>= 0.5.0)
56
+ rainbow (3.0.0)
89
57
  rspec (3.7.0)
90
58
  rspec-core (~> 3.7.0)
91
59
  rspec-expectations (~> 3.7.0)
@@ -104,14 +72,16 @@ GEM
104
72
  rspec-support (3.7.1)
105
73
  rspec_junit_formatter (0.3.0)
106
74
  rspec-core (>= 2, < 4, != 2.12.0)
107
- rubocop (0.42.0)
108
- parser (>= 2.3.1.1, < 3.0)
75
+ rubocop (0.52.1)
76
+ parallel (~> 1.10)
77
+ parser (>= 2.4.0.2, < 3.0)
109
78
  powerpack (~> 0.1)
110
- rainbow (>= 1.99.1, < 3.0)
79
+ rainbow (>= 2.2.2, < 4.0)
111
80
  ruby-progressbar (~> 1.7)
112
81
  unicode-display_width (~> 1.0, >= 1.0.1)
113
- ruby-progressbar (1.8.1)
114
- ruby_dep (1.4.0)
82
+ rubocop-rspec (1.22.2)
83
+ rubocop (>= 0.52.1)
84
+ ruby-progressbar (1.9.0)
115
85
  safe_yaml (1.0.4)
116
86
  savon (2.12.0)
117
87
  akami (~> 1.2)
@@ -121,15 +91,12 @@ GEM
121
91
  nokogiri (>= 1.8.1)
122
92
  nori (~> 2.4)
123
93
  wasabi (~> 3.4)
124
- shellany (0.0.1)
125
- slop (3.6.0)
126
94
  socksify (1.7.1)
127
- thor (0.19.1)
128
95
  thread_safe (0.3.6)
129
- timecop (0.8.1)
96
+ timecop (0.9.1)
130
97
  tzinfo (1.2.5)
131
98
  thread_safe (~> 0.1)
132
- unicode-display_width (1.1.0)
99
+ unicode-display_width (1.3.0)
133
100
  wasabi (3.5.0)
134
101
  httpi (~> 2.0)
135
102
  nokogiri (>= 1.4.2)
@@ -145,14 +112,12 @@ DEPENDENCIES
145
112
  bundler (~> 1.3)
146
113
  compare-xml (~> 0.5)
147
114
  creditsafe!
148
- guard-rspec (~> 4.5)
149
- guard-rubocop (~> 1.2)
150
- pry
151
- pry-byebug
115
+ gc_ruboconfig (~> 2.3)
116
+ pry (~> 0.11)
152
117
  rspec (~> 3.1)
153
118
  rspec-its (~> 1.2)
154
119
  rspec_junit_formatter (~> 0.3)
155
- rubocop (~> 0.37)
120
+ rubocop (~> 0.52)
156
121
  timecop (~> 0.8)
157
122
  webmock (~> 1.20)
158
123
 
data/creditsafe.gemspec CHANGED
@@ -1,35 +1,35 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'creditsafe/version'
5
+ require "creditsafe/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'creditsafe'
8
+ spec.name = "creditsafe"
9
9
  spec.version = Creditsafe::VERSION
10
- spec.authors = ['GoCardless Engineering']
11
- spec.email = ['engineering@gocardless.com']
12
- spec.summary = 'Ruby client for the Creditsafe SOAP API'
13
- spec.description = 'Ruby client for the Creditsafe SOAP API'
14
- spec.homepage = 'https://github.com/gocardless/creditsafe-ruby'
10
+ spec.authors = ["GoCardless Engineering"]
11
+ spec.email = ["engineering@gocardless.com"]
12
+ spec.summary = "Ruby client for the Creditsafe SOAP API"
13
+ spec.description = "Ruby client for the Creditsafe SOAP API"
14
+ spec.homepage = "https://github.com/gocardless/creditsafe-ruby"
15
15
 
16
16
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
19
+ spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency 'savon', '~> 2.8'
22
- spec.add_runtime_dependency 'excon', '~> 0.45'
23
- spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
21
+ spec.add_runtime_dependency "activesupport", ">= 4.2.0"
22
+ spec.add_runtime_dependency "excon", "~> 0.45"
23
+ spec.add_runtime_dependency "savon", "~> 2.8"
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.3'
26
- spec.add_development_dependency 'rspec', '~> 3.1'
27
- spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3'
28
- spec.add_development_dependency 'rspec-its', '~> 1.2'
29
- spec.add_development_dependency 'guard-rspec', '~> 4.5'
30
- spec.add_development_dependency 'guard-rubocop', '~> 1.2'
31
- spec.add_development_dependency 'rubocop', '~> 0.37'
32
- spec.add_development_dependency 'webmock', '~> 1.20'
33
- spec.add_development_dependency 'timecop', '~> 0.8'
34
- spec.add_development_dependency 'compare-xml', '~> 0.5'
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "compare-xml", "~> 0.5"
27
+ spec.add_development_dependency "gc_ruboconfig", "~> 2.3"
28
+ spec.add_development_dependency "pry", "~> 0.11"
29
+ spec.add_development_dependency "rspec", "~> 3.1"
30
+ spec.add_development_dependency "rspec-its", "~> 1.2"
31
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.3"
32
+ spec.add_development_dependency "rubocop", "~> 0.52"
33
+ spec.add_development_dependency "timecop", "~> 0.8"
34
+ spec.add_development_dependency "webmock", "~> 1.20"
35
35
  end
@@ -1,20 +1,21 @@
1
1
  # frozen_string_literal: true
2
- require 'securerandom'
3
- require 'savon'
4
- require 'excon'
5
2
 
6
- require 'creditsafe/errors'
7
- require 'creditsafe/messages'
8
- require 'creditsafe/namespace'
3
+ require "securerandom"
4
+ require "savon"
5
+ require "excon"
9
6
 
10
- require 'creditsafe/request/company_report'
11
- require 'creditsafe/request/find_company'
7
+ require "creditsafe/errors"
8
+ require "creditsafe/messages"
9
+ require "creditsafe/namespace"
12
10
 
13
- require 'active_support/notifications'
11
+ require "creditsafe/request/company_report"
12
+ require "creditsafe/request/find_company"
13
+
14
+ require "active_support/notifications"
14
15
 
15
16
  module Creditsafe
16
17
  class Client
17
- ENVIRONMENTS = %i(live test).freeze
18
+ ENVIRONMENTS = %i[live test].freeze
18
19
 
19
20
  def initialize(username: nil, password: nil, savon_opts: {},
20
21
  environment: :live, log_level: :warn)
@@ -37,9 +38,9 @@ module Creditsafe
37
38
  response = invoke_soap(:find_companies, request.message)
38
39
 
39
40
  companies = response.
40
- fetch(:find_companies_response).
41
- fetch(:find_companies_result).
42
- fetch(:companies)
41
+ fetch(:find_companies_response).
42
+ fetch(:find_companies_result).
43
+ fetch(:companies)
43
44
 
44
45
  companies.nil? ? nil : companies.fetch(:company)
45
46
  end
@@ -64,11 +65,10 @@ module Creditsafe
64
65
 
65
66
  def handle_message_for_response(response)
66
67
  [
67
- *response.xpath('//q1:Message'),
68
- *response.xpath('//xmlns:Message')
68
+ *response.xpath("//q1:Message"),
69
+ *response.xpath("//xmlns:Message"),
69
70
  ].each do |message|
70
- api_message = Creditsafe::Messages.
71
- for_code(message.attributes['Code'].value)
71
+ api_message = Creditsafe::Messages.for_code(message.attributes["Code"].value)
72
72
 
73
73
  api_error_message = api_message.message
74
74
  api_error_message += " (#{message.text})" unless message.text.blank?
@@ -77,6 +77,8 @@ module Creditsafe
77
77
  end
78
78
  end
79
79
 
80
+ # rubocop:disable Style/RescueStandardError
81
+ # rubocop:disable Metrics/MethodLength
80
82
  def invoke_soap(message_type, message)
81
83
  started = Time.now
82
84
  notification_payload = { request: message }
@@ -92,6 +94,8 @@ module Creditsafe
92
94
  publish("creditsafe.#{message_type}", started, Time.now,
93
95
  SecureRandom.hex(10), notification_payload)
94
96
  end
97
+ # rubocop:enable Metrics/MethodLength
98
+ # rubocop:enable Style/RescueStandardError
95
99
 
96
100
  def publish(*args)
97
101
  ActiveSupport::Notifications.publish(*args)
@@ -99,13 +103,15 @@ module Creditsafe
99
103
 
100
104
  # There's a potential bug in the creditsafe API where they actually return
101
105
  # an HTTP 401 if you're unauthorized, hence the sad special case below
106
+ #
107
+ # rubocop:disable Metrics/MethodLength
102
108
  def handle_error(error)
103
109
  case error
104
110
  when Savon::SOAPFault
105
111
  return UnknownApiError.new(error.message)
106
112
  when Savon::HTTPError
107
113
  if error.to_hash[:code] == 401
108
- return AccountError.new('Unauthorized: invalid credentials')
114
+ return AccountError.new("Unauthorized: invalid credentials")
109
115
  end
110
116
  return UnknownApiError.new(error.message)
111
117
  when Excon::Errors::Error
@@ -113,19 +119,21 @@ module Creditsafe
113
119
  end
114
120
  error
115
121
  end
122
+ # rubocop:enable Metrics/MethodLength
116
123
 
117
124
  def client
118
125
  @client ||= build_savon_client
119
126
  end
120
127
 
121
128
  def auth_header
122
- auth_value = 'Basic ' + Base64.encode64("#{@username}:#{@password}").chomp
123
- { 'Authorization' => auth_value }
129
+ auth_value = "Basic " + Base64.encode64("#{@username}:#{@password}").chomp
130
+ { "Authorization" => auth_value }
124
131
  end
125
132
 
133
+ # rubocop:disable Metrics/MethodLength
126
134
  def build_savon_client
127
135
  options = {
128
- env_namespace: 'soapenv',
136
+ env_namespace: "soapenv",
129
137
  namespace_identifier: Creditsafe::Namespace::OPER,
130
138
  namespaces: Creditsafe::Namespace::ALL,
131
139
  wsdl: wsdl_path,
@@ -134,14 +142,15 @@ module Creditsafe
134
142
  adapter: :excon,
135
143
  log: true,
136
144
  log_level: @log_level,
137
- pretty_print_xml: true
145
+ pretty_print_xml: true,
138
146
  }
139
147
  Savon.client(options.merge(@savon_opts))
140
148
  end
149
+ # rubocop:enable Metrics/MethodLength
141
150
 
142
151
  def wsdl_path
143
- root_dir = File.join(File.dirname(__FILE__), '..', '..')
144
- File.join(root_dir, 'data', "creditsafe-#{@environment}.xml")
152
+ root_dir = File.join(File.dirname(__FILE__), "..", "..")
153
+ File.join(root_dir, "data", "creditsafe-#{@environment}.xml")
145
154
  end
146
155
  end
147
156
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Creditsafe
3
4
  class Error < StandardError; end
4
5
 
@@ -14,16 +14,16 @@ module Creditsafe
14
14
  DE: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE, MATCH_WORDS],
15
15
  FR: [MATCH_BEGINNING, CLOSEST_KEYWORDS, EXACT_VALUE],
16
16
  GB: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, EXACT_VALUE],
17
- IE: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
17
+ IE: [MATCH_BEGINNING, MATCH_BLOCK, MATCH_WORDS],
18
18
  GL: [MATCH_BEGINNING],
19
19
  CH: [CLOSEST_KEYWORDS],
20
20
  LI: [CLOSEST_KEYWORDS],
21
21
  NL: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
22
- CZ: [MATCH_BEGINNING, MATCH_BLOCK],
22
+ CZ: [MATCH_BLOCK_OR_WORDS],
23
23
  IS: [MATCH_BEGINNING],
24
24
  LT: [MATCH_ANY_PARTS],
25
25
  MT: [MATCH_BEGINNING, MATCH_BLOCK],
26
- SK: [MATCH_BEGINNING, MATCH_BLOCK],
26
+ SK: [MATCH_BLOCK_OR_WORDS],
27
27
  BE: [MATCH_BEGINNING, MATCH_BLOCK_OR_WORDS, MATCH_WORDS],
28
28
  SE: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
29
29
  PL: [CLOSEST_KEYWORDS],
@@ -31,7 +31,7 @@ module Creditsafe
31
31
  PT: [MATCH_BEGINNING],
32
32
  LU: [MATCH_BEGINNING, MATCH_BLOCK, EXACT_VALUE],
33
33
  CA: [MATCH_BEGINNING],
34
- ES: [CLOSEST_KEYWORDS],
34
+ ES: [EXACT_VALUE, CLOSEST_KEYWORDS],
35
35
  US: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
36
36
  PR: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
37
37
  AS: [MATCH_BEGINNING, CLOSEST_KEYWORDS],
@@ -67,7 +67,7 @@ module Creditsafe
67
67
  KM: [MATCH_BLOCK_OR_WORDS],
68
68
  HK: [MATCH_BLOCK_OR_WORDS],
69
69
  AT: [MATCH_WORDS],
70
- IT: [CLOSEST_KEYWORDS],
70
+ IT: [CLOSEST_KEYWORDS, EXACT_VALUE],
71
71
  BR: [CLOSEST_KEYWORDS],
72
72
  HU: [MATCH_BEGINNING],
73
73
  TW: [MATCH_BEGINNING],
@@ -109,7 +109,7 @@ module Creditsafe
109
109
  AE: [CLOSEST_KEYWORDS],
110
110
  EH: [CLOSEST_KEYWORDS],
111
111
  YE: [CLOSEST_KEYWORDS],
112
- GR: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS]
112
+ GR: [MATCH_BLOCK_OR_WORDS, CLOSEST_KEYWORDS],
113
113
  }.freeze
114
114
  end
115
115
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'creditsafe/errors'
2
+
3
+ require "creditsafe/errors"
3
4
 
4
5
  module Creditsafe
5
6
  module Messages
@@ -14,7 +15,7 @@ module Creditsafe
14
15
  @error = error
15
16
  end
16
17
 
17
- alias error? error
18
+ alias_method :error?, :error
18
19
 
19
20
  def error_class
20
21
  return unless error?
@@ -30,28 +31,28 @@ module Creditsafe
30
31
  end
31
32
 
32
33
  # rubocop:disable Metrics/LineLength
33
- NO_RESULTS = Message.new(code: '010101', message: 'No results')
34
- TOO_MANY_RESULTS = Message.new(code: '010102', message: 'Too many results')
35
- REPORT_UNAVAILABLE = Message.new(code: '010103', message: 'Report unavailable', error: true)
36
- REPORT_UNAVAILABLE_LEGAL = Message.new(code: '010104', message: 'Report unavailable due to legal causes', error: true)
37
- REPORT_UNAVAILABLE_ONLINE = Message.new(code: '010105', message: 'Report unavailable online', error: true)
38
- LEGAL_NOTICE = Message.new(code: '010106', message: 'Legal notice')
39
- INVALID_CREDENTIALS = Message.new(code: '020101', message: 'Invalid credentials', error: true)
40
- ACCESS_RESTRICTED = Message.new(code: '020102', message: 'Access restricted', error: true)
41
- ACCESS_LIMITS_NEARING = Message.new(code: '020103', message: 'Access limits nearing')
42
- REPORTBOX_ALMOST_FULL = Message.new(code: '020201', message: 'Reportbox almost full', error: true)
43
- REPORTBOX_FULL = Message.new(code: '020202', message: 'Reportbox full', error: true)
44
- INVALID_REQUEST_XML = Message.new(code: '030101', message: 'Invalid request XML', error: true)
45
- INVALID_OPERATION_PARAMS = Message.new(code: '030102', message: 'Invalid operation parameters', error: true)
46
- OPERATION_NOT_SUPPORTED = Message.new(code: '030103', message: 'Operation not supported', error: true)
47
- INVALID_CUSTOM_DATA_SPECIFIED = Message.new(code: '030104', message: 'Invalid custom data specified', error: true)
48
- CHANGE_NOTIFICATION = Message.new(code: '030201', message: 'Change notification')
49
- TEMPORARY_SYSTEM_PROBLEM = Message.new(code: '030202', message: 'Temporary system problem', error: true)
50
- ENDPOINT_SHUTDOWN = Message.new(code: '030203', message: 'Endpoint shutdown', error: true)
51
- UNEXPECTED_INTERNAL_ERROR = Message.new(code: '040101', message: 'Unexpected internal error', error: true)
52
- OTHER_ERROR = Message.new(code: '040102', message: 'Other', error: true)
53
- DATA_SERVICE_PROBLEMS = Message.new(code: '040103', message: 'Data service access problems', error: true)
54
- DATA_SERVICE_INVALID_RESPONSE = Message.new(code: '040104', message: 'Data service invalid response', error: true)
34
+ NO_RESULTS = Message.new(code: "010101", message: "No results")
35
+ TOO_MANY_RESULTS = Message.new(code: "010102", message: "Too many results")
36
+ REPORT_UNAVAILABLE = Message.new(code: "010103", message: "Report unavailable", error: true)
37
+ REPORT_UNAVAILABLE_LEGAL = Message.new(code: "010104", message: "Report unavailable due to legal causes", error: true)
38
+ REPORT_UNAVAILABLE_ONLINE = Message.new(code: "010105", message: "Report unavailable online", error: true)
39
+ LEGAL_NOTICE = Message.new(code: "010106", message: "Legal notice")
40
+ INVALID_CREDENTIALS = Message.new(code: "020101", message: "Invalid credentials", error: true)
41
+ ACCESS_RESTRICTED = Message.new(code: "020102", message: "Access restricted", error: true)
42
+ ACCESS_LIMITS_NEARING = Message.new(code: "020103", message: "Access limits nearing")
43
+ REPORTBOX_ALMOST_FULL = Message.new(code: "020201", message: "Reportbox almost full", error: true)
44
+ REPORTBOX_FULL = Message.new(code: "020202", message: "Reportbox full", error: true)
45
+ INVALID_REQUEST_XML = Message.new(code: "030101", message: "Invalid request XML", error: true)
46
+ INVALID_OPERATION_PARAMS = Message.new(code: "030102", message: "Invalid operation parameters", error: true)
47
+ OPERATION_NOT_SUPPORTED = Message.new(code: "030103", message: "Operation not supported", error: true)
48
+ INVALID_CUSTOM_DATA_SPECIFIED = Message.new(code: "030104", message: "Invalid custom data specified", error: true)
49
+ CHANGE_NOTIFICATION = Message.new(code: "030201", message: "Change notification")
50
+ TEMPORARY_SYSTEM_PROBLEM = Message.new(code: "030202", message: "Temporary system problem", error: true)
51
+ ENDPOINT_SHUTDOWN = Message.new(code: "030203", message: "Endpoint shutdown", error: true)
52
+ UNEXPECTED_INTERNAL_ERROR = Message.new(code: "040101", message: "Unexpected internal error", error: true)
53
+ OTHER_ERROR = Message.new(code: "040102", message: "Other", error: true)
54
+ DATA_SERVICE_PROBLEMS = Message.new(code: "040103", message: "Data service access problems", error: true)
55
+ DATA_SERVICE_INVALID_RESPONSE = Message.new(code: "040104", message: "Data service invalid response", error: true)
55
56
  # rubocop:enable Metrics/LineLength
56
57
 
57
58
  ALL = [
@@ -76,18 +77,18 @@ module Creditsafe
76
77
  UNEXPECTED_INTERNAL_ERROR,
77
78
  OTHER_ERROR,
78
79
  DATA_SERVICE_PROBLEMS,
79
- DATA_SERVICE_INVALID_RESPONSE
80
+ DATA_SERVICE_INVALID_RESPONSE,
80
81
  ].freeze
81
82
 
82
83
  # Creditsafe documentation shows a 6 digit error code, however their API
83
84
  # strips the leading 0. To comply with the docs, we pad the API code here to
84
85
  # ensure we find the right match
85
86
  def self.for_code(code)
86
- padded_code = code.rjust(6, '0')
87
+ padded_code = code.rjust(6, "0")
87
88
  message = ALL.find { |msg| msg.code == padded_code }
88
89
 
89
90
  if message.nil?
90
- message = Message.new(code: code, message: 'Unknown error', error: true)
91
+ message = Message.new(code: code, message: "Unknown error", error: true)
91
92
  end
92
93
 
93
94
  message
@@ -2,19 +2,19 @@
2
2
 
3
3
  module Creditsafe
4
4
  module Namespace
5
- OPER = 'oper'
6
- OPER_VAL = 'http://www.creditsafe.com/globaldata/operations'
5
+ OPER = "oper"
6
+ OPER_VAL = "http://www.creditsafe.com/globaldata/operations"
7
7
 
8
- DAT = 'dat'
9
- DAT_VAL = 'http://www.creditsafe.com/globaldata/datatypes'
8
+ DAT = "dat"
9
+ DAT_VAL = "http://www.creditsafe.com/globaldata/datatypes"
10
10
 
11
- CRED = 'cred'
12
- CRED_VAL = 'http://schemas.datacontract.org/2004/07/Creditsafe.GlobalData'
11
+ CRED = "cred"
12
+ CRED_VAL = "http://schemas.datacontract.org/2004/07/Creditsafe.GlobalData"
13
13
 
14
14
  ALL = {
15
15
  "xmlns:#{Creditsafe::Namespace::OPER}" => Creditsafe::Namespace::OPER_VAL,
16
16
  "xmlns:#{Creditsafe::Namespace::DAT}" => Creditsafe::Namespace::DAT_VAL,
17
- "xmlns:#{Creditsafe::Namespace::CRED}" => Creditsafe::Namespace::CRED_VAL
17
+ "xmlns:#{Creditsafe::Namespace::CRED}" => Creditsafe::Namespace::CRED_VAL,
18
18
  }.freeze
19
19
  end
20
20
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'creditsafe/namespace'
3
+ require "creditsafe/namespace"
4
4
 
5
5
  module Creditsafe
6
6
  module Request
@@ -10,23 +10,25 @@ module Creditsafe
10
10
  @custom_data = custom_data
11
11
  end
12
12
 
13
+ # rubocop:disable Metrics/MethodLength
13
14
  def message
14
15
  message = {
15
16
  "#{Creditsafe::Namespace::OPER}:companyId" => company_id.to_s,
16
- "#{Creditsafe::Namespace::OPER}:reportType" => 'Full',
17
- "#{Creditsafe::Namespace::OPER}:language" => "EN"
17
+ "#{Creditsafe::Namespace::OPER}:reportType" => "Full",
18
+ "#{Creditsafe::Namespace::OPER}:language" => "EN",
18
19
  }
19
20
 
20
21
  unless custom_data.nil?
21
22
  message["#{Creditsafe::Namespace::OPER}:customData"] = {
22
23
  "#{Creditsafe::Namespace::DAT}:Entries" => {
23
- "#{Creditsafe::Namespace::DAT}:Entry" => custom_data_entries
24
- }
24
+ "#{Creditsafe::Namespace::DAT}:Entry" => custom_data_entries,
25
+ },
25
26
  }
26
27
  end
27
28
 
28
29
  message
29
30
  end
31
+ # rubocop:enable Metrics/MethodLength
30
32
 
31
33
  private
32
34