creditsafe 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 563fddd54824c02af29e53feb2363d7d727a56b5
4
- data.tar.gz: 91d896b3049f05021d46dd053958a4f13f0fdb1e
3
+ metadata.gz: ef933acd556b7da62f4479c61a255b488980db56
4
+ data.tar.gz: 0b429f01c58df701cdfab8f917031794c9aaad1c
5
5
  SHA512:
6
- metadata.gz: c25e9c9607708e08767a1c76a0df85af71dc00c059992c015639a7e4e11e41cb1019fe31cc0bd68e7ddd4c5ea4db65dc9e85227d3821760c4a70d46af9da5520
7
- data.tar.gz: cfa40a02a6f38fab8781ceed3d879afab0d27042686bc719c29e56c4d90937887c59d50d562d733965f5f075cd296eb23a1019d81f962db1fe6f5b105035dcf6
6
+ metadata.gz: e8f6379e8e4f0653a2694723512d8bf519aff20d27b272c7745915f39bfced01176bd6556312867a1709f25eaf75bce2618a80e00e08ef14062d9b5138db4202
7
+ data.tar.gz: 95d9f34ab1f1f8c0b85e69cfa903a7f377f4d7c27e9000c157fcc51707191f1ba15f70097839fe87206ae2d9e70e646208a5c27cb0a031ab6c1d1bb061da16f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.4.0, 3 April 2017
2
+
3
+ - Adds support for including a postal code when searching for German companies by name
4
+ (@manojapr)
5
+
1
6
  ## v0.3.2, 27 February 2017
2
7
 
3
8
  - Adds support for using Creditsafe's test environment, specified when instantiating the
data/README.md CHANGED
@@ -13,7 +13,7 @@ registration number (and name in Germany), and retrieving company online reports
13
13
  Install the gem from RubyGems.org by adding the following to your `Gemfile`:
14
14
 
15
15
  ```ruby
16
- gem 'creditsafe', '~> 0.3.2'
16
+ gem 'creditsafe', '~> 0.4.0'
17
17
  ```
18
18
 
19
19
  Just run `bundle install` to install the gem and its dependencies.
@@ -31,7 +31,7 @@ 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 country code and a company registration number.
34
+ To perform a search for a company, you need to provide a country code and a company registration number:
35
35
 
36
36
  ```ruby
37
37
  client.find_company(country_code: "GB", registration_number: "07495895")
@@ -54,10 +54,12 @@ client.find_company(country_code: "GB", registration_number: "07495895")
54
54
  }
55
55
  ```
56
56
 
57
- In Germany you can also perform a name search. For this you need to provide a country code and a company name.
57
+ 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 provided a postal code to filter the results
59
+ further:
58
60
 
59
61
  ```ruby
60
- client.find_company(country_code: "DE", company_name: "zalando")
62
+ client.find_company(country_code: "DE", company_name: "zalando", postal_code: "10243")
61
63
  => [
62
64
  {
63
65
  "name": "Zalando Logistics Süd SE & Co. KG",
@@ -120,8 +122,8 @@ client.find_company(country_code: "DE", company_name: "zalando")
120
122
  ### Company Report
121
123
 
122
124
  To download all the information available in an online company report, you will
123
- need the company's creditsafe identifier (obtainable using
124
- [find_company](#find_company) above.
125
+ need the company's Creditsafe identifier (obtainable using
126
+ [find_company](#find_company) above):
125
127
 
126
128
  ```ruby
127
129
  client.company_report("GB003/0/07495895")
@@ -11,6 +11,7 @@ module Creditsafe
11
11
  @registration_number = search_criteria[:registration_number]
12
12
  @company_name = search_criteria[:company_name]
13
13
  @city = search_criteria[:city]
14
+ @postal_code = search_criteria[:postal_code]
14
15
  end
15
16
 
16
17
  def message
@@ -30,12 +31,16 @@ module Creditsafe
30
31
  "#{Creditsafe::Namespace::DAT}:City" => city
31
32
  } unless city.nil?
32
33
 
34
+ search_criteria["#{Creditsafe::Namespace::DAT}:Address"] = {
35
+ "#{Creditsafe::Namespace::DAT}:PostalCode" => postal_code
36
+ } unless postal_code.nil?
37
+
33
38
  build_message(search_criteria)
34
39
  end
35
40
 
36
41
  private
37
42
 
38
- attr_reader :country_code, :registration_number, :city, :company_name
43
+ attr_reader :country_code, :registration_number, :city, :company_name, :postal_code
39
44
 
40
45
  def build_message(search_criteria)
41
46
  {
@@ -64,6 +69,10 @@ module Creditsafe
64
69
  if search_criteria[:city] && search_criteria[:country_code] != 'DE'
65
70
  raise ArgumentError, "city is only supported for German searches"
66
71
  end
72
+
73
+ if search_criteria[:postal_code] && search_criteria[:country_code] != 'DE'
74
+ raise ArgumentError, "Postal code is only supported for German searches"
75
+ end
67
76
  end
68
77
  # rubocop:enable Style/CyclomaticComplexity, Metrics/AbcSize
69
78
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Creditsafe
3
- VERSION = '0.3.2'
3
+ VERSION = '0.4.0'
4
4
  end
@@ -127,11 +127,13 @@ RSpec.describe(Creditsafe::Client) do
127
127
  let(:country_code) { "GB" }
128
128
  let(:registration_number) { "RN123" }
129
129
  let(:city) { nil }
130
+ let(:postal_code) { nil }
130
131
  let(:search_criteria) do
131
132
  {
132
133
  country_code: country_code,
133
134
  registration_number: registration_number,
134
- city: city
135
+ city: city,
136
+ postal_code: postal_code
135
137
  }.reject { |_, v| v.nil? }
136
138
  end
137
139
 
@@ -168,6 +170,16 @@ RSpec.describe(Creditsafe::Client) do
168
170
  end
169
171
  end
170
172
 
173
+ context "with a postal_code" do
174
+ let(:postal_code) { "41199" }
175
+ it { is_expected.to raise_error(ArgumentError) }
176
+
177
+ context "in Germany" do
178
+ let(:country_code) { "DE" }
179
+ it { is_expected.to_not raise_error }
180
+ end
181
+ end
182
+
171
183
  it 'requests the company deatils' do
172
184
  find_company
173
185
  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.3.2
4
+ version: 0.4.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-02-28 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon