creditsafe 0.4.0 → 0.5.0

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: ef933acd556b7da62f4479c61a255b488980db56
4
- data.tar.gz: 0b429f01c58df701cdfab8f917031794c9aaad1c
3
+ metadata.gz: 8efad9c046062a13533c0b1d9b6952e8bc3322d4
4
+ data.tar.gz: 4e3c8602dbeda52622424508c17fe77b85680df3
5
5
  SHA512:
6
- metadata.gz: e8f6379e8e4f0653a2694723512d8bf519aff20d27b272c7745915f39bfced01176bd6556312867a1709f25eaf75bce2618a80e00e08ef14062d9b5138db4202
7
- data.tar.gz: 95d9f34ab1f1f8c0b85e69cfa903a7f377f4d7c27e9000c157fcc51707191f1ba15f70097839fe87206ae2d9e70e646208a5c27cb0a031ab6c1d1bb061da16f4
6
+ metadata.gz: e05840b5d34c6952eff251ca34c57fcb5587197a212780a9e55d52d4dd99a9927d0c855b4021b9a8772ad800850df59a482397add073ea3a815a796bfd769bad
7
+ data.tar.gz: a1e3ce8720cae12415215fa4affdee2864f873267077d84fd4b98ddc591236b02ea16eb78f28367b12bc39f302c9bd790b8cbea043aa8080876be28b42809b28
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ working_directory: ~/creditsafe-ruby
5
+ docker:
6
+ - image: ruby:2.5.0
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ key: gemfile-{{ checksum "Gemfile" }}
11
+ - run: bundle install --path vendor/bundle
12
+ - save_cache:
13
+ key: gemfile-{{ checksum "Gemfile" }}
14
+ paths:
15
+ - "vendor/bundle"
16
+ - run: bundle exec rubocop
17
+ - run: bundle exec rspec --format RspecJunitFormatter
data/.rubocop.yml CHANGED
@@ -18,4 +18,7 @@ Style/Documentation:
18
18
  Enabled: false
19
19
 
20
20
  Metrics/LineLength:
21
- Max: 90
21
+ Max: 90
22
+
23
+ Metrics/ModuleLength:
24
+ Max: 120
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.5.0, 27 February 2018
2
+
3
+ - Automatically chooses a valid MatchType when searching for companies by name
4
+
1
5
  ## v0.4.0, 3 April 2017
2
6
 
3
7
  - Adds support for including a postal code when searching for German companies by name
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- creditsafe (0.3.2)
4
+ creditsafe (0.5.0)
5
5
  activesupport (>= 4.2.0)
6
6
  excon (~> 0.45)
7
7
  savon (~> 2.8)
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (5.0.1)
12
+ activesupport (5.1.5)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (~> 0.7)
15
15
  minitest (~> 5.1)
@@ -22,13 +22,13 @@ GEM
22
22
  builder (3.2.3)
23
23
  byebug (9.0.5)
24
24
  coderay (1.1.1)
25
- compare-xml (0.62)
26
- nokogiri (~> 1.6)
25
+ compare-xml (0.65)
26
+ nokogiri (~> 1.8)
27
27
  concurrent-ruby (1.0.5)
28
28
  crack (0.4.3)
29
29
  safe_yaml (~> 1.0.0)
30
- diff-lcs (1.2.5)
31
- excon (0.55.0)
30
+ diff-lcs (1.3)
31
+ excon (0.60.0)
32
32
  ffi (1.9.14)
33
33
  formatador (0.2.5)
34
34
  guard (2.14.0)
@@ -51,29 +51,28 @@ GEM
51
51
  gyoku (1.3.1)
52
52
  builder (>= 2.1.2)
53
53
  hashdiff (0.3.0)
54
- httpi (2.4.2)
54
+ httpi (2.4.3)
55
55
  rack
56
56
  socksify
57
- i18n (0.8.1)
57
+ i18n (0.9.5)
58
+ concurrent-ruby (~> 1.0)
58
59
  listen (3.1.5)
59
60
  rb-fsevent (~> 0.9, >= 0.9.4)
60
61
  rb-inotify (~> 0.9, >= 0.9.7)
61
62
  ruby_dep (~> 1.2)
62
63
  lumberjack (1.0.10)
63
64
  method_source (0.8.2)
64
- mini_portile2 (2.1.0)
65
- minitest (5.10.1)
65
+ mini_portile2 (2.3.0)
66
+ minitest (5.11.3)
66
67
  nenv (0.3.0)
67
- nokogiri (1.6.8)
68
- mini_portile2 (~> 2.1.0)
69
- pkg-config (~> 1.1.7)
68
+ nokogiri (1.8.2)
69
+ mini_portile2 (~> 2.3.0)
70
70
  nori (2.6.0)
71
71
  notiffany (0.1.1)
72
72
  nenv (~> 0.1)
73
73
  shellany (~> 0.0)
74
74
  parser (2.3.1.2)
75
75
  ast (~> 2.2)
76
- pkg-config (1.1.7)
77
76
  powerpack (0.1.1)
78
77
  pry (0.10.4)
79
78
  coderay (~> 1.1.0)
@@ -82,27 +81,29 @@ GEM
82
81
  pry-byebug (3.4.0)
83
82
  byebug (~> 9.0)
84
83
  pry (~> 0.10)
85
- rack (2.0.1)
84
+ rack (2.0.4)
86
85
  rainbow (2.1.0)
87
86
  rb-fsevent (0.9.7)
88
87
  rb-inotify (0.9.7)
89
88
  ffi (>= 0.5.0)
90
- rspec (3.5.0)
91
- rspec-core (~> 3.5.0)
92
- rspec-expectations (~> 3.5.0)
93
- rspec-mocks (~> 3.5.0)
94
- rspec-core (3.5.2)
95
- rspec-support (~> 3.5.0)
96
- rspec-expectations (3.5.0)
89
+ rspec (3.7.0)
90
+ rspec-core (~> 3.7.0)
91
+ rspec-expectations (~> 3.7.0)
92
+ rspec-mocks (~> 3.7.0)
93
+ rspec-core (3.7.1)
94
+ rspec-support (~> 3.7.0)
95
+ rspec-expectations (3.7.0)
97
96
  diff-lcs (>= 1.2.0, < 2.0)
98
- rspec-support (~> 3.5.0)
97
+ rspec-support (~> 3.7.0)
99
98
  rspec-its (1.2.0)
100
99
  rspec-core (>= 3.0.0)
101
100
  rspec-expectations (>= 3.0.0)
102
- rspec-mocks (3.5.0)
101
+ rspec-mocks (3.7.0)
103
102
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.5.0)
105
- rspec-support (3.5.0)
103
+ rspec-support (~> 3.7.0)
104
+ rspec-support (3.7.1)
105
+ rspec_junit_formatter (0.3.0)
106
+ rspec-core (>= 2, < 4, != 2.12.0)
106
107
  rubocop (0.42.0)
107
108
  parser (>= 2.3.1.1, < 3.0)
108
109
  powerpack (~> 0.1)
@@ -112,12 +113,12 @@ GEM
112
113
  ruby-progressbar (1.8.1)
113
114
  ruby_dep (1.4.0)
114
115
  safe_yaml (1.0.4)
115
- savon (2.11.1)
116
+ savon (2.12.0)
116
117
  akami (~> 1.2)
117
118
  builder (>= 2.1.2)
118
119
  gyoku (~> 1.2)
119
120
  httpi (~> 2.3)
120
- nokogiri (>= 1.4.0)
121
+ nokogiri (>= 1.8.1)
121
122
  nori (~> 2.4)
122
123
  wasabi (~> 3.4)
123
124
  shellany (0.0.1)
@@ -126,7 +127,7 @@ GEM
126
127
  thor (0.19.1)
127
128
  thread_safe (0.3.6)
128
129
  timecop (0.8.1)
129
- tzinfo (1.2.2)
130
+ tzinfo (1.2.5)
130
131
  thread_safe (~> 0.1)
131
132
  unicode-display_width (1.1.0)
132
133
  wasabi (3.5.0)
@@ -150,9 +151,10 @@ DEPENDENCIES
150
151
  pry-byebug
151
152
  rspec (~> 3.1)
152
153
  rspec-its (~> 1.2)
154
+ rspec_junit_formatter (~> 0.3)
153
155
  rubocop (~> 0.37)
154
156
  timecop (~> 0.8)
155
157
  webmock (~> 1.20)
156
158
 
157
159
  BUNDLED WITH
158
- 1.13.7
160
+ 1.16.1
data/creditsafe.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
26
  spec.add_development_dependency 'rspec', '~> 3.1'
27
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3'
27
28
  spec.add_development_dependency 'rspec-its', '~> 1.2'
28
29
  spec.add_development_dependency 'guard-rspec', '~> 4.5'
29
30
  spec.add_development_dependency 'guard-rubocop', '~> 1.2'
@@ -0,0 +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_OR_WORDS, 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_BEGINNING, MATCH_BLOCK],
23
+ IS: [MATCH_BEGINNING],
24
+ LT: [MATCH_ANY_PARTS],
25
+ MT: [MATCH_BEGINNING, MATCH_BLOCK],
26
+ SK: [MATCH_BEGINNING, MATCH_BLOCK],
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: [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],
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,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'creditsafe/namespace'
4
+ require 'creditsafe/match_type'
4
5
 
5
6
  module Creditsafe
6
7
  module Request
@@ -14,11 +15,13 @@ module Creditsafe
14
15
  @postal_code = search_criteria[:postal_code]
15
16
  end
16
17
 
18
+ # rubocop:disable Metrics/MethodLength
19
+ # rubocop:disable Metrics/AbcSize
17
20
  def message
18
21
  search_criteria = {}
19
22
 
20
23
  search_criteria["#{Creditsafe::Namespace::DAT}:Name"] = {
21
- '@MatchType' => 'MatchBlock',
24
+ '@MatchType' => match_type,
22
25
  :content! => company_name
23
26
  } unless company_name.nil?
24
27
 
@@ -37,11 +40,18 @@ module Creditsafe
37
40
 
38
41
  build_message(search_criteria)
39
42
  end
43
+ # rubocop:enable Metrics/AbcSize
44
+ # rubocop:enable Metrics/MethodLength
40
45
 
41
46
  private
42
47
 
43
48
  attr_reader :country_code, :registration_number, :city, :company_name, :postal_code
44
49
 
50
+ def match_type
51
+ Creditsafe::MatchType::ALLOWED[country_code.upcase.to_sym]&.first ||
52
+ Creditsafe::MatchType::MATCH_BLOCK
53
+ end
54
+
45
55
  def build_message(search_criteria)
46
56
  {
47
57
  "#{Creditsafe::Namespace::OPER}:countries" => {
@@ -51,16 +61,12 @@ module Creditsafe
51
61
  }
52
62
  end
53
63
 
54
- # rubocop:disable Style/CyclomaticComplexity, Metrics/AbcSize
64
+ # rubocop:disable Metrics/CyclomaticComplexity
55
65
  def check_search_criteria(search_criteria)
56
66
  if search_criteria[:country_code].nil?
57
67
  raise ArgumentError, "country_code is a required search criteria"
58
68
  end
59
69
 
60
- if search_criteria[:country_code] != 'DE' && !search_criteria[:company_name].nil?
61
- raise ArgumentError, "company name search is only possible for German searches"
62
- end
63
-
64
70
  unless only_registration_number_or_company_name_provided?(search_criteria)
65
71
  raise ArgumentError, "registration_number or company_name (not both) are " \
66
72
  "required search criteria"
@@ -74,7 +80,7 @@ module Creditsafe
74
80
  raise ArgumentError, "Postal code is only supported for German searches"
75
81
  end
76
82
  end
77
- # rubocop:enable Style/CyclomaticComplexity, Metrics/AbcSize
83
+ # rubocop:enable Metrics/CyclomaticComplexity
78
84
 
79
85
  def only_registration_number_or_company_name_provided?(search_criteria)
80
86
  search_criteria[:registration_number].nil? ^ search_criteria[:company_name].nil?
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Creditsafe
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  end
@@ -180,6 +180,24 @@ RSpec.describe(Creditsafe::Client) do
180
180
  end
181
181
  end
182
182
 
183
+ context "with a company name" do
184
+ let(:search_criteria) { { country_code: "FR", company_name: "Mimes Inc" } }
185
+
186
+ it { is_expected.to_not raise_error }
187
+
188
+ it "selects a valid match type for the country code" do
189
+ find_company
190
+
191
+ request = a_request(:post, URL).with do |req|
192
+ body = Nokogiri::XML(req.body)
193
+ expect(body.xpath("//dat:Name").first.attributes["MatchType"].value).
194
+ to eq("MatchBeginning")
195
+ end
196
+
197
+ expect(request).to have_been_made
198
+ end
199
+ end
200
+
183
201
  it 'requests the company deatils' do
184
202
  find_company
185
203
  expect(a_request(:post, URL).with do |req|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creditsafe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.3'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rspec-its
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -185,6 +199,7 @@ executables: []
185
199
  extensions: []
186
200
  extra_rdoc_files: []
187
201
  files:
202
+ - ".circleci/config.yml"
188
203
  - ".gitignore"
189
204
  - ".rspec"
190
205
  - ".rubocop.yml"
@@ -196,13 +211,13 @@ files:
196
211
  - Guardfile
197
212
  - LICENSE.txt
198
213
  - README.md
199
- - circle.yml
200
214
  - creditsafe.gemspec
201
215
  - data/creditsafe-live.xml
202
216
  - data/creditsafe-test.xml
203
217
  - lib/creditsafe.rb
204
218
  - lib/creditsafe/client.rb
205
219
  - lib/creditsafe/errors.rb
220
+ - lib/creditsafe/match_type.rb
206
221
  - lib/creditsafe/messages.rb
207
222
  - lib/creditsafe/namespace.rb
208
223
  - lib/creditsafe/request/company_report.rb
@@ -241,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
256
  version: '0'
242
257
  requirements: []
243
258
  rubyforge_project:
244
- rubygems_version: 2.6.8
259
+ rubygems_version: 2.5.1
245
260
  signing_key:
246
261
  specification_version: 4
247
262
  summary: Ruby client for the Creditsafe SOAP API
data/circle.yml DELETED
@@ -1,8 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.3.1
4
- test:
5
- pre:
6
- - bundle exec rubocop
7
- post:
8
- - bundle exec rspec