creditsafe 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +31 -29
- data/README.md +41 -4
- data/lib/creditsafe/constants.rb +49 -0
- data/lib/creditsafe/request/find_company.rb +28 -6
- data/lib/creditsafe/version.rb +1 -1
- data/spec/creditsafe/client_spec.rb +56 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7e9dc737539af843ce3a9b181fdb7d08bdcd7c1
|
4
|
+
data.tar.gz: b05479c1bd360574152a8d2e2d73f975248da52e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcee6d9fb09ce4ece19f833031437f6ccd721f13456cdb0278a434f1f05ed86dc9ba364fd79924c74f4e08b975c620d0919998165ddc35416962635fc45dde01
|
7
|
+
data.tar.gz: 14da6df79c7baf7de5ca7989311a5deafee3efd36b060cad04d9ec3fc5b4cb9bb626f2a17574c2a9e0197ffbdec1a5ae583ac83aa8129312f0aa680caba54bf1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
creditsafe (0.
|
4
|
+
creditsafe (0.6.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.
|
12
|
+
activesupport (5.2.0)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 0.7, < 2)
|
15
15
|
minitest (~> 5.1)
|
@@ -22,16 +22,16 @@ GEM
|
|
22
22
|
ast (2.4.0)
|
23
23
|
builder (3.2.3)
|
24
24
|
coderay (1.1.2)
|
25
|
-
compare-xml (0.
|
25
|
+
compare-xml (0.66)
|
26
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
30
|
diff-lcs (1.3)
|
31
31
|
excon (0.62.0)
|
32
|
-
gc_ruboconfig (2.3.
|
33
|
-
rubocop (
|
34
|
-
rubocop-rspec (~> 1.
|
32
|
+
gc_ruboconfig (2.3.11)
|
33
|
+
rubocop (>= 0.57, < 0.59)
|
34
|
+
rubocop-rspec (~> 1.25)
|
35
35
|
gyoku (1.3.1)
|
36
36
|
builder (>= 2.1.2)
|
37
37
|
hashdiff (0.3.7)
|
@@ -40,50 +40,52 @@ GEM
|
|
40
40
|
socksify
|
41
41
|
i18n (1.0.0)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
+
jaro_winkler (1.5.1)
|
43
44
|
method_source (0.9.0)
|
44
45
|
mini_portile2 (2.3.0)
|
45
46
|
minitest (5.11.3)
|
46
|
-
nokogiri (1.8.
|
47
|
+
nokogiri (1.8.4)
|
47
48
|
mini_portile2 (~> 2.3.0)
|
48
49
|
nori (2.6.0)
|
49
50
|
parallel (1.12.1)
|
50
|
-
parser (2.5.
|
51
|
+
parser (2.5.1.2)
|
51
52
|
ast (~> 2.4.0)
|
52
|
-
powerpack (0.1.
|
53
|
+
powerpack (0.1.2)
|
53
54
|
pry (0.11.3)
|
54
55
|
coderay (~> 1.1.0)
|
55
56
|
method_source (~> 0.9.0)
|
56
57
|
public_suffix (3.0.2)
|
57
58
|
rack (2.0.4)
|
58
59
|
rainbow (3.0.0)
|
59
|
-
rspec (3.
|
60
|
-
rspec-core (~> 3.
|
61
|
-
rspec-expectations (~> 3.
|
62
|
-
rspec-mocks (~> 3.
|
63
|
-
rspec-core (3.
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-expectations (3.
|
60
|
+
rspec (3.8.0)
|
61
|
+
rspec-core (~> 3.8.0)
|
62
|
+
rspec-expectations (~> 3.8.0)
|
63
|
+
rspec-mocks (~> 3.8.0)
|
64
|
+
rspec-core (3.8.0)
|
65
|
+
rspec-support (~> 3.8.0)
|
66
|
+
rspec-expectations (3.8.0)
|
66
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
+
rspec-support (~> 3.8.0)
|
68
69
|
rspec-its (1.2.0)
|
69
70
|
rspec-core (>= 3.0.0)
|
70
71
|
rspec-expectations (>= 3.0.0)
|
71
|
-
rspec-mocks (3.
|
72
|
+
rspec-mocks (3.8.0)
|
72
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
-
rspec-support (~> 3.
|
74
|
-
rspec-support (3.
|
75
|
-
rspec_junit_formatter (0.
|
74
|
+
rspec-support (~> 3.8.0)
|
75
|
+
rspec-support (3.8.0)
|
76
|
+
rspec_junit_formatter (0.4.1)
|
76
77
|
rspec-core (>= 2, < 4, != 2.12.0)
|
77
|
-
rubocop (0.
|
78
|
+
rubocop (0.58.2)
|
79
|
+
jaro_winkler (~> 1.5.1)
|
78
80
|
parallel (~> 1.10)
|
79
|
-
parser (>= 2.5)
|
81
|
+
parser (>= 2.5, != 2.5.1.1)
|
80
82
|
powerpack (~> 0.1)
|
81
83
|
rainbow (>= 2.2.2, < 4.0)
|
82
84
|
ruby-progressbar (~> 1.7)
|
83
85
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
84
|
-
rubocop-rspec (1.
|
85
|
-
rubocop (>= 0.
|
86
|
-
ruby-progressbar (1.
|
86
|
+
rubocop-rspec (1.27.0)
|
87
|
+
rubocop (>= 0.56.0)
|
88
|
+
ruby-progressbar (1.10.0)
|
87
89
|
safe_yaml (1.0.4)
|
88
90
|
savon (2.12.0)
|
89
91
|
akami (~> 1.2)
|
@@ -98,11 +100,11 @@ GEM
|
|
98
100
|
timecop (0.9.1)
|
99
101
|
tzinfo (1.2.5)
|
100
102
|
thread_safe (~> 0.1)
|
101
|
-
unicode-display_width (1.
|
103
|
+
unicode-display_width (1.4.0)
|
102
104
|
wasabi (3.5.0)
|
103
105
|
httpi (~> 2.0)
|
104
106
|
nokogiri (>= 1.4.2)
|
105
|
-
webmock (3.
|
107
|
+
webmock (3.4.2)
|
106
108
|
addressable (>= 2.3.6)
|
107
109
|
crack (>= 0.3.2)
|
108
110
|
hashdiff
|
@@ -124,4 +126,4 @@ DEPENDENCIES
|
|
124
126
|
webmock (~> 3.3)
|
125
127
|
|
126
128
|
BUNDLED WITH
|
127
|
-
1.16.
|
129
|
+
1.16.5
|
data/README.md
CHANGED
@@ -31,10 +31,11 @@ client = Creditsafe::Client.new(username: "foo", password: "bar", environment: :
|
|
31
31
|
|
32
32
|
### Company Search
|
33
33
|
|
34
|
-
To perform a search for a company, you need to provide a
|
34
|
+
To perform a search for a company, you need to provide a valid search criteria, including
|
35
|
+
the country code and a company registration number or company name:
|
35
36
|
|
36
37
|
```ruby
|
37
|
-
client.find_company(country_code: "GB", registration_number: "07495895")
|
38
|
+
client.find_company({ country_code: "GB", registration_number: "07495895" })
|
38
39
|
=> {
|
39
40
|
name: "GOCARDLESS LTD",
|
40
41
|
type: "Ltd",
|
@@ -55,11 +56,11 @@ client.find_company(country_code: "GB", registration_number: "07495895")
|
|
55
56
|
```
|
56
57
|
|
57
58
|
In Germany you can also perform a name search. For this you need to provide a country code
|
58
|
-
and a company name, and can optionally
|
59
|
+
and a company name, and can optionally provide a postal code or city to filter the results
|
59
60
|
further:
|
60
61
|
|
61
62
|
```ruby
|
62
|
-
client.find_company(country_code: "DE", company_name: "zalando", postal_code: "10243")
|
63
|
+
client.find_company({ country_code: "DE", company_name: "zalando", postal_code: "10243" })
|
63
64
|
=> [
|
64
65
|
{
|
65
66
|
"name": "Zalando Logistics Süd SE & Co. KG",
|
@@ -119,6 +120,42 @@ client.find_company(country_code: "DE", company_name: "zalando", postal_code: "1
|
|
119
120
|
]
|
120
121
|
```
|
121
122
|
|
123
|
+
In some countries you can also perform a VAT number search. For this, you need to provide
|
124
|
+
a country code and a VAT number:
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
client.find_company({ country_code: "US", vat_number: "201665019" })
|
128
|
+
=> [
|
129
|
+
{
|
130
|
+
"name": "FACEBOOK, INCORPORATED",
|
131
|
+
"officeType": "HeadOffice",
|
132
|
+
"status": "Active",
|
133
|
+
"registration_number": "0883875",
|
134
|
+
"vat_number": "201665019",
|
135
|
+
"address": {
|
136
|
+
"simple_value": "1601 WILLOW ROAD , MENLO PARK, CA, 94025",
|
137
|
+
"street": "1601 WILLOW ROAD ",
|
138
|
+
"city": "MENLO PARK",
|
139
|
+
"postal_code": "94025",
|
140
|
+
"province": "CA"
|
141
|
+
},
|
142
|
+
"phone_number": "6505434800",
|
143
|
+
"available_report_types": {
|
144
|
+
"available_report_type": "Full"
|
145
|
+
},
|
146
|
+
"available_languages": {
|
147
|
+
"available_language": "EN"
|
148
|
+
},
|
149
|
+
"@online_reports": "true",
|
150
|
+
"@monitoring": "false",
|
151
|
+
"@country": "US",
|
152
|
+
"@id": "US023/X/US22964593",
|
153
|
+
"@safe_number": "US22964593"
|
154
|
+
},
|
155
|
+
...
|
156
|
+
]
|
157
|
+
```
|
158
|
+
|
122
159
|
### Company Report
|
123
160
|
|
124
161
|
To download all the information available in an online company report, you will
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Constants
|
4
|
+
module Country
|
5
|
+
AUSTRALIA = "AU"
|
6
|
+
AUSTRIA = "AT"
|
7
|
+
BELGIUM = "BE"
|
8
|
+
BULGARIA = "BG"
|
9
|
+
CANADA = "CA"
|
10
|
+
CROATIA = "HR"
|
11
|
+
CZECH_REPUBLIC = "CZ"
|
12
|
+
DENMARK = "DK"
|
13
|
+
ESTONIA = "EE"
|
14
|
+
FINLAND = "FI"
|
15
|
+
FRANCE = "FR"
|
16
|
+
GERMANY = "DE"
|
17
|
+
GREAT_BRITAIN = "GB"
|
18
|
+
GREECE = "GR"
|
19
|
+
HUNGARY = "HU"
|
20
|
+
ICELAND = "IS"
|
21
|
+
IRELAND = "IE"
|
22
|
+
ITALY = "IT"
|
23
|
+
LATVIA = "LV"
|
24
|
+
LIECHTENSTEIN = "LI"
|
25
|
+
LITHUANIA = "LT"
|
26
|
+
LUXEMBOURG = "LU"
|
27
|
+
MALTA = "MT"
|
28
|
+
MOLDOVA = "MD"
|
29
|
+
NETHERLANDS = "NL"
|
30
|
+
NEW_ZEALAND = "NZ"
|
31
|
+
NORWAY = "NO"
|
32
|
+
POLAND = "PL"
|
33
|
+
PORTUGAL = "PT"
|
34
|
+
ROMANIA = "RO"
|
35
|
+
SLOVAKIA = "SK"
|
36
|
+
SLOVENIA = "SI"
|
37
|
+
SPAIN = "ES"
|
38
|
+
SWEDEN = "SE"
|
39
|
+
SWITZERLAND = "CH"
|
40
|
+
UK = "GB"
|
41
|
+
UNITED_STATES = "US"
|
42
|
+
|
43
|
+
VAT_NUMBER_SUPPORTED = [
|
44
|
+
GERMANY, FRANCE, CZECH_REPUBLIC, SLOVAKIA, BELGIUM, POLAND, PORTUGAL, SPAIN,
|
45
|
+
UNITED_STATES, SLOVENIA, CROATIA, BULGARIA, ROMANIA, LATVIA, ESTONIA, MOLDOVA,
|
46
|
+
AUSTRIA, ITALY, HUNGARY, FINLAND, DENMARK, AUSTRALIA, GREECE
|
47
|
+
].freeze
|
48
|
+
end
|
49
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "creditsafe/match_type"
|
4
4
|
require "creditsafe/namespace"
|
5
|
+
require "creditsafe/constants"
|
5
6
|
|
6
7
|
module Creditsafe
|
7
8
|
module Request
|
@@ -11,6 +12,7 @@ module Creditsafe
|
|
11
12
|
@country_code = search_criteria[:country_code]
|
12
13
|
@registration_number = search_criteria[:registration_number]
|
13
14
|
@company_name = search_criteria[:company_name]
|
15
|
+
@vat_number = search_criteria[:vat_number]
|
14
16
|
@city = search_criteria[:city]
|
15
17
|
@postal_code = search_criteria[:postal_code]
|
16
18
|
end
|
@@ -32,6 +34,11 @@ module Creditsafe
|
|
32
34
|
registration_number
|
33
35
|
end
|
34
36
|
|
37
|
+
unless vat_number.nil?
|
38
|
+
search_criteria["#{Creditsafe::Namespace::DAT}:VatNumber"] =
|
39
|
+
vat_number
|
40
|
+
end
|
41
|
+
|
35
42
|
unless city.nil?
|
36
43
|
search_criteria["#{Creditsafe::Namespace::DAT}:Address"] = {
|
37
44
|
"#{Creditsafe::Namespace::DAT}:City" => city,
|
@@ -51,7 +58,8 @@ module Creditsafe
|
|
51
58
|
|
52
59
|
private
|
53
60
|
|
54
|
-
attr_reader :country_code, :registration_number, :city, :company_name, :postal_code
|
61
|
+
attr_reader :country_code, :registration_number, :city, :company_name, :postal_code,
|
62
|
+
:vat_number
|
55
63
|
|
56
64
|
def match_type
|
57
65
|
Creditsafe::MatchType::ALLOWED[country_code.upcase.to_sym]&.first ||
|
@@ -69,14 +77,16 @@ module Creditsafe
|
|
69
77
|
|
70
78
|
# rubocop:disable Metrics/CyclomaticComplexity
|
71
79
|
# rubocop:disable Metrics/MethodLength
|
80
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
81
|
+
# rubocop:disable Metrics/AbcSize
|
72
82
|
def check_search_criteria(search_criteria)
|
73
83
|
if search_criteria[:country_code].nil?
|
74
84
|
raise ArgumentError, "country_code is a required search criteria"
|
75
85
|
end
|
76
86
|
|
77
|
-
unless
|
78
|
-
raise ArgumentError, "
|
79
|
-
"required search criteria"
|
87
|
+
unless only_one_required_criteria?(search_criteria)
|
88
|
+
raise ArgumentError, "only one of registration_number, company_name or " \
|
89
|
+
"vat number is required search criteria"
|
80
90
|
end
|
81
91
|
|
82
92
|
if search_criteria[:city] && search_criteria[:country_code] != "DE"
|
@@ -86,12 +96,24 @@ module Creditsafe
|
|
86
96
|
if search_criteria[:postal_code] && search_criteria[:country_code] != "DE"
|
87
97
|
raise ArgumentError, "Postal code is only supported for German searches"
|
88
98
|
end
|
99
|
+
|
100
|
+
if search_criteria[:vat_number] && !Constants::Country::VAT_NUMBER_SUPPORTED.
|
101
|
+
include?(search_criteria[:country_code])
|
102
|
+
raise ArgumentError, "VAT number is not supported in this country"
|
103
|
+
end
|
89
104
|
end
|
105
|
+
# rubocop:enable Metrics/AbcSize
|
106
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
90
107
|
# rubocop:enable Metrics/MethodLength
|
91
108
|
# rubocop:enable Metrics/CyclomaticComplexity
|
92
109
|
|
93
|
-
def
|
94
|
-
|
110
|
+
def only_one_required_criteria?(search_criteria)
|
111
|
+
by_registration_number = !search_criteria[:registration_number].nil?
|
112
|
+
by_company_name = !search_criteria[:company_name].nil?
|
113
|
+
by_vat_number = !search_criteria[:vat_number].nil?
|
114
|
+
|
115
|
+
(by_registration_number ^ by_company_name ^ by_vat_number) &&
|
116
|
+
!(by_registration_number && by_company_name && by_vat_number)
|
95
117
|
end
|
96
118
|
end
|
97
119
|
end
|
data/lib/creditsafe/version.rb
CHANGED
@@ -136,10 +136,14 @@ RSpec.describe(Creditsafe::Client) do
|
|
136
136
|
let(:registration_number) { "RN123" }
|
137
137
|
let(:city) { nil }
|
138
138
|
let(:postal_code) { nil }
|
139
|
+
let(:company_name) { nil }
|
140
|
+
let(:vat_number) { nil }
|
139
141
|
let(:search_criteria) do
|
140
142
|
{
|
141
143
|
country_code: country_code,
|
142
144
|
registration_number: registration_number,
|
145
|
+
company_name: company_name,
|
146
|
+
vat_number: vat_number,
|
143
147
|
city: city,
|
144
148
|
postal_code: postal_code,
|
145
149
|
}.reject { |_, v| v.nil? }
|
@@ -194,7 +198,9 @@ RSpec.describe(Creditsafe::Client) do
|
|
194
198
|
end
|
195
199
|
|
196
200
|
context "with a company name" do
|
197
|
-
let(:
|
201
|
+
let(:country_code) { "FR" }
|
202
|
+
let(:registration_number) { nil }
|
203
|
+
let(:company_name) { "Mimes Inc" }
|
198
204
|
|
199
205
|
it { is_expected.to_not raise_error }
|
200
206
|
|
@@ -211,6 +217,54 @@ RSpec.describe(Creditsafe::Client) do
|
|
211
217
|
end
|
212
218
|
end
|
213
219
|
|
220
|
+
context "with a vat_number" do
|
221
|
+
let(:vat_number) { "942404110" }
|
222
|
+
let(:registration_number) { nil }
|
223
|
+
|
224
|
+
it { is_expected.to raise_error(ArgumentError) }
|
225
|
+
|
226
|
+
context "in US" do
|
227
|
+
let(:country_code) { "US" }
|
228
|
+
|
229
|
+
it { is_expected.to_not raise_error }
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context "with different invalid required criteria combinations used" do
|
234
|
+
context "with registration number and company name" do
|
235
|
+
let(:company_name) { "Mimes Inc" }
|
236
|
+
|
237
|
+
it { is_expected.to raise_error(ArgumentError) }
|
238
|
+
end
|
239
|
+
|
240
|
+
context "with registration number and vat_number" do
|
241
|
+
let(:vat_number) { "942404110" }
|
242
|
+
|
243
|
+
it { is_expected.to raise_error(ArgumentError) }
|
244
|
+
end
|
245
|
+
|
246
|
+
context "with company name and vat_number" do
|
247
|
+
let(:registration_number) { nil }
|
248
|
+
let(:company_name) { "Mimes Inc" }
|
249
|
+
let(:vat_number) { "942404110" }
|
250
|
+
|
251
|
+
it { is_expected.to raise_error(ArgumentError) }
|
252
|
+
end
|
253
|
+
|
254
|
+
context "with all three required criteria" do
|
255
|
+
let(:company_name) { "Mimes Inc" }
|
256
|
+
let(:vat_number) { "942404110" }
|
257
|
+
|
258
|
+
it { is_expected.to raise_error(ArgumentError) }
|
259
|
+
end
|
260
|
+
|
261
|
+
context "with no required criteria" do
|
262
|
+
let(:registration_number) { nil }
|
263
|
+
|
264
|
+
it { is_expected.to raise_error(ArgumentError) }
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
214
268
|
it "requests the company deatils" do
|
215
269
|
find_company
|
216
270
|
expect(a_request(:post, URL).with do |req|
|
@@ -218,7 +272,7 @@ RSpec.describe(Creditsafe::Client) do
|
|
218
272
|
Nokogiri::XML(req.body),
|
219
273
|
load_xml_fixture("find-companies-request.xml"),
|
220
274
|
verbose: true,
|
221
|
-
|
275
|
+
)).to eq([])
|
222
276
|
end).to have_been_made
|
223
277
|
end
|
224
278
|
|
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
|
+
version: 0.6.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: 2018-
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- data/creditsafe-test.xml
|
215
215
|
- lib/creditsafe.rb
|
216
216
|
- lib/creditsafe/client.rb
|
217
|
+
- lib/creditsafe/constants.rb
|
217
218
|
- lib/creditsafe/errors.rb
|
218
219
|
- lib/creditsafe/match_type.rb
|
219
220
|
- lib/creditsafe/messages.rb
|