postcode-anywhere 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +30 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +247 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +72 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +319 -0
  9. data/Rakefile +2 -0
  10. data/config/pre_commit.yml +7 -0
  11. data/lib/postcode_anywhere.rb +10 -0
  12. data/lib/postcode_anywhere/bank_account_validation/bank_branch.rb +45 -0
  13. data/lib/postcode_anywhere/bank_account_validation/client.rb +13 -0
  14. data/lib/postcode_anywhere/bank_account_validation/interactive.rb +39 -0
  15. data/lib/postcode_anywhere/bank_account_validation/validation_result.rb +80 -0
  16. data/lib/postcode_anywhere/capture_plus/client.rb +13 -0
  17. data/lib/postcode_anywhere/capture_plus/interactive.rb +84 -0
  18. data/lib/postcode_anywhere/capture_plus/query_type.rb +8 -0
  19. data/lib/postcode_anywhere/capture_plus/retrieve_result.rb +45 -0
  20. data/lib/postcode_anywhere/capture_plus/search_result.rb +39 -0
  21. data/lib/postcode_anywhere/cleanse_plus/cleansed_address.rb +98 -0
  22. data/lib/postcode_anywhere/cleanse_plus/client.rb +13 -0
  23. data/lib/postcode_anywhere/cleanse_plus/interactive.rb +24 -0
  24. data/lib/postcode_anywhere/client.rb +86 -0
  25. data/lib/postcode_anywhere/configuration.rb +47 -0
  26. data/lib/postcode_anywhere/email_validation/client.rb +13 -0
  27. data/lib/postcode_anywhere/email_validation/interactive.rb +25 -0
  28. data/lib/postcode_anywhere/email_validation/validation_result.rb +24 -0
  29. data/lib/postcode_anywhere/error.rb +118 -0
  30. data/lib/postcode_anywhere/model_base.rb +72 -0
  31. data/lib/postcode_anywhere/request.rb +33 -0
  32. data/lib/postcode_anywhere/response/parse_json.rb +100 -0
  33. data/lib/postcode_anywhere/response/raise_error.rb +19 -0
  34. data/lib/postcode_anywhere/utils.rb +15 -0
  35. data/lib/postcode_anywhere/version.rb +3 -0
  36. data/postcode_anywhere.gemspec +31 -0
  37. data/spec/postcode_anywhere/bank_account_validation/interactive_spec.rb +82 -0
  38. data/spec/postcode_anywhere/capture_plus/interactive_spec.rb +240 -0
  39. data/spec/postcode_anywhere/cleanse_plus/interactive_spec.rb +65 -0
  40. data/spec/postcode_anywhere/client_spec.rb +124 -0
  41. data/spec/postcode_anywhere/configuration_spec.rb +62 -0
  42. data/spec/postcode_anywhere/email_validation/interactive_spec.rb +30 -0
  43. data/spec/postcode_anywhere/error_spec.rb +70 -0
  44. data/spec/postcode_anywhere/fixtures/bank_account_retrieve_by_sort.json +1 -0
  45. data/spec/postcode_anywhere/fixtures/bank_account_validate_account.json +1 -0
  46. data/spec/postcode_anywhere/fixtures/capture_plus_retrieve.json +1 -0
  47. data/spec/postcode_anywhere/fixtures/capture_plus_search.json +1 -0
  48. data/spec/postcode_anywhere/fixtures/cleanse_address_multi.json +1 -0
  49. data/spec/postcode_anywhere/fixtures/cleanse_address_single.json +1 -0
  50. data/spec/postcode_anywhere/fixtures/email_validation_validate_email.json +1 -0
  51. data/spec/postcode_anywhere/model_base_spec.rb +10 -0
  52. data/spec/spec_helper.rb +38 -0
  53. metadata +281 -0
@@ -0,0 +1,100 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module PostcodeAnywhere
5
+ module Response
6
+ class ParseJson < Faraday::Response::Middleware
7
+ WHITESPACE_REGEX = /\A^\s*$\z/
8
+ def parse(body)
9
+ case body
10
+ when WHITESPACE_REGEX, nil
11
+ nil
12
+ else
13
+ convert_hash_keys JSON.parse(body)
14
+ end
15
+ end
16
+
17
+ def to_snake_case(string)
18
+ string.gsub(/::/, '/').
19
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
20
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
21
+ tr('-', '_').
22
+ downcase
23
+ end
24
+
25
+ def underscore_key(k)
26
+ to_snake_case(k.to_s).to_sym
27
+ end
28
+
29
+ def convert_hash_keys(value)
30
+ case value
31
+ when Array
32
+ value.map { |v| convert_hash_keys(v) }
33
+ when Hash
34
+ Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }]
35
+ else
36
+ convert_boolean value
37
+ end
38
+ end
39
+
40
+ def convert_boolean(value)
41
+ return nil unless value
42
+ return value unless value.class == String
43
+ return true if (value.downcase == 'true')
44
+ return false if (value.downcase == 'false')
45
+ value
46
+ end
47
+
48
+ def on_complete(response)
49
+ response.body =
50
+ parse(response.body) if
51
+ respond_to?(:parse) && !unparsable_status_codes.include?(response.status)
52
+ raise_errors_in response.body
53
+ response.body = breakout_items response.body
54
+ end
55
+
56
+ def breakout_items(response_body)
57
+ if response_body.class == Hash && response_body.keys.include?(:items)
58
+ return response_body[:items]
59
+ end
60
+ response_body
61
+ end
62
+
63
+ def raise_errors_in(response_body)
64
+ (
65
+ first_response = response_body
66
+ if response_body.class == Array
67
+ first_response = response_body.first
68
+ end
69
+ if first_response.class == Hash
70
+ if first_response.keys.include? :error
71
+ code = first_response[:error].to_i
72
+ klass = error_klass_for code
73
+ fail(klass.from_response(first_response))
74
+ end
75
+ end
76
+ ) if response_body
77
+ end
78
+
79
+ def error_klass_for(code)
80
+ klass = PostcodeAnywhere::Error.postcode_anywhere_errors[code]
81
+ if !klass
82
+ if code > 1000
83
+ klass = PostcodeAnywhere::Error::ServiceSpecificError
84
+ else
85
+ PostcodeAnywhere::Error::UnknownError
86
+ end
87
+ end
88
+ klass
89
+ end
90
+
91
+ def unparsable_status_codes
92
+ [204, 301, 302, 304, 400]
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ Faraday::Response.register_middleware(
99
+ postcode_anywhere_parse_json: PostcodeAnywhere::Response::ParseJson
100
+ )
@@ -0,0 +1,19 @@
1
+ require 'faraday'
2
+ require 'postcode_anywhere/error'
3
+
4
+ module PostcodeAnywhere
5
+ module Response
6
+ class RaiseError < Faraday::Response::Middleware
7
+ def on_complete(response)
8
+ status_code = response.status.to_i
9
+ klass = PostcodeAnywhere::Error.errors[status_code]
10
+ return unless klass
11
+ fail(klass.from_response(response))
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ Faraday::Response.register_middleware(
18
+ postcode_anywhere_raise_error: PostcodeAnywhere::Response::RaiseError
19
+ )
@@ -0,0 +1,15 @@
1
+ require 'postcode_anywhere/request'
2
+
3
+ module PostcodeAnywhere
4
+ module Utils
5
+ def perform_with_object(request_method, path, options, klass, body_hash = {})
6
+ request = PostcodeAnywhere::Request.new(self, request_method, path, body_hash, options)
7
+ request.perform_with_object(klass)
8
+ end
9
+
10
+ def perform_with_objects(request_method, path, options, klass, body_hash = {})
11
+ request = PostcodeAnywhere::Request.new(self, request_method, path, body_hash, options)
12
+ request.perform_with_objects(klass)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module PostcodeAnywhere
2
+ VERSION = '1.0.1'
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'postcode_anywhere/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "postcode-anywhere"
8
+ spec.version = PostcodeAnywhere::VERSION
9
+ spec.authors = ["Edward Woodcock"]
10
+ spec.email = ["edward@simple-merchant.com"]
11
+ spec.summary = %q{Full set of Postcode Anywhere API clients - http://postcodeanywhere.co.uk}
12
+ spec.description = %q{A number of fully-tested clients for interacting with all of the available postcode anywhere services, including capture, cleansing, payment validation and email validation}
13
+ spec.homepage = "https://github.com/simplemerchant/postcode-anywhere"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.0'
22
+ spec.add_runtime_dependency 'memoizable', '~> 0.4', '>= 0.4.2'
23
+
24
+ spec.add_development_dependency 'pre-commit', '~> 0.19', '>= 0.19.0'
25
+ spec.add_development_dependency 'webmock', '~> 1.18', '>= 1.18.0'
26
+ spec.add_development_dependency 'rubocop', '~> 0.26', '>= 0.26.1'
27
+ spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
28
+ spec.add_development_dependency 'spring-commands-rspec', '~> 1.0', '>= 1.0.2'
29
+ spec.add_development_dependency "bundler", "~> 1.6"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
@@ -0,0 +1,82 @@
1
+ describe PostcodeAnywhere::BankAccountValidation::Interactive do
2
+ before do
3
+ @client = PostcodeAnywhere::BankAccountValidation::Client.new(
4
+ api_key: 'interactive_test_key'
5
+ )
6
+ end
7
+ describe '#address_candidates_for' do
8
+ before do
9
+ @endpoint = 'BankAccountValidation/Interactive/RetrieveBySortcode/v1.00/json.ws'
10
+ @query_params = { 'Key' => 'interactive_test_key', 'SortCode' => 'A' }
11
+ end
12
+ context 'when a single result is returned' do
13
+ before do
14
+ stub_get(@endpoint).with(query: @query_params).to_return(
15
+ body: fixture('bank_account_retrieve_by_sort.json')
16
+ )
17
+ end
18
+ it 'requests the correct resource' do
19
+ @client.retrieve_by_sortcode('A')
20
+ expect(a_get(@endpoint).with(query: @query_params)).to have_been_made
21
+ end
22
+ it 'returns a Postcode Anywhere bank branch details' do
23
+ item = @client.retrieve_by_sortcode('A')
24
+ expect(item).to be_a PostcodeAnywhere::BankAccountValidation::BankBranch
25
+ expect(item.bank).to eq 'HSBC BANK PLC'
26
+ expect(item.bank_bic).to eq 'MIDLGB21'
27
+ expect(item.branch).to eq 'Cheltenham Bath Road'
28
+ expect(item.contact_address_line1).to eq '109 Bath Road'
29
+ expect(item.contact_address_line2).to eq 'l2'
30
+ expect(item.contact_post_town).to eq 'Cheltenham'
31
+ expect(item.contact_postcode).to eq 'GL53 7RA'
32
+ expect(item.contact_phone).to eq '01234567890'
33
+ expect(item.contact_fax).to eq '111'
34
+ expect(item.faster_payments_supported).to eq true
35
+ expect(item.chaps_supported).to eq true
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '#validate_account' do
41
+ before do
42
+ @endpoint = 'BankAccountValidation/Interactive/Validate/v1.00/json.ws'
43
+ @query_params = {
44
+ 'Key' => 'interactive_test_key',
45
+ 'AccountNumber' => 'A',
46
+ 'SortCode' => 'B'
47
+ }
48
+ end
49
+ context 'when a single result is returned' do
50
+ before do
51
+ stub_get(@endpoint).with(query: @query_params).to_return(
52
+ body: fixture('bank_account_validate_account.json')
53
+ )
54
+ end
55
+ it 'requests the correct resource' do
56
+ @client.validate_account('A', 'B')
57
+ expect(a_get(@endpoint).with(query: @query_params)).to have_been_made
58
+ end
59
+ it 'returns a Postcode Anywhere bank validation result' do
60
+ item = @client.validate_account('A', 'B')
61
+ expect(item).to be_a PostcodeAnywhere::BankAccountValidation::ValidationResult
62
+ expect(item.is_correct).to eq true
63
+ expect(item.is_direct_debit_capable).to eq true
64
+ expect(item.status_information).to eq 'OK'
65
+ expect(item.corrected_sort_code).to eq '012345'
66
+ expect(item.corrected_account_number).to eq '12345678'
67
+ expect(item.iban).to eq '1111111111111111111111'
68
+ expect(item.bank).to eq 'NATIONAL WESTMINSTER BANK PLC'
69
+ expect(item.bank_bic).to eq 'BIKBIKBI'
70
+ expect(item.branch).to eq 'A bank in town'
71
+ expect(item.contact_address_line1).to eq 'Leicester Rcsc'
72
+ expect(item.contact_address_line2).to eq 'Bede House'
73
+ expect(item.contact_post_town).to eq 'Leicester'
74
+ expect(item.contact_postcode).to eq 'LE2 7EJ'
75
+ expect(item.contact_phone).to eq '0870 2403355'
76
+ expect(item.contact_fax).to eq '222'
77
+ expect(item.faster_payments_supported).to eq true
78
+ expect(item.chaps_supported).to eq true
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,240 @@
1
+ describe PostcodeAnywhere::CapturePlus::Interactive do
2
+ before do
3
+ @client = PostcodeAnywhere::CapturePlus::Client.new(api_key: 'interactive_test_key')
4
+ end
5
+
6
+ describe 'Searching' do
7
+ before do
8
+ @endpoint = 'CapturePlus/Interactive/Find/v2.00/json.ws'
9
+ @query_params = {
10
+ 'Key' => 'interactive_test_key',
11
+ 'SearchTerm' => 'A',
12
+ 'SearchFor' => 'Everything',
13
+ 'LastId' => '',
14
+ 'Country' => 'GBR',
15
+ 'LanguagePreference' => 'EN'
16
+ }
17
+ end
18
+ describe '#query' do
19
+ before do
20
+ stub_get(@endpoint).with(query: @query_params).to_return(
21
+ body: fixture('capture_plus_search.json')
22
+ )
23
+ end
24
+ it 'requests the correct resource' do
25
+ @client.query('A')
26
+ expect(a_get(@endpoint).with(query: @query_params)).to have_been_made
27
+ end
28
+ it 'returns a set of Postcode Anywhere search results' do
29
+ results = @client.query('A')
30
+ expect(results).to be_an Array
31
+ expect(results.count).to eq 6
32
+ item = results.first
33
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
34
+ expect(item.id).to eq(
35
+ 'GBR|CN|QgB1AGMAawBpAG4AZwBoAGEAbQAgAFAAYQBsAGEAYwBlACwAIABMAG8AbgBkAG8Ab' \
36
+ 'gAsACAAUwBXADEAQQAuAC4ALgA*|2562-0-3'
37
+ )
38
+ expect(item.text).to eq 'Buckingham Palace, London, SW1A...'
39
+ expect(item.highlight).to eq '1-3'
40
+ expect(item.cursor).to eq '0'
41
+ expect(item.description).to eq '3 Results'
42
+ expect(item.next).to eq 'Find'
43
+
44
+ expect(results[1].text).to eq 'Buckingham Palace Road, London, SW1W...'
45
+ expect(results[2].text).to eq(
46
+ 'Buckingham Balti House, 42, Buckingham Palace Road, London, SW1W...'
47
+ )
48
+ expect(results[3].text).to eq(
49
+ 'Buckingham Coffee Lounge, 19-21, Palace Street, London, SW1E...'
50
+ )
51
+ expect(results[4].text).to eq(
52
+ 'Gardeners Lodge, Buckingham Palace Gardens, Lower Grosvenor Place, London, SW1W...'
53
+ )
54
+ expect(results[5].text).to eq(
55
+ 'Buckingham Palace Gift Shop, 7-9, Buckingham Palace Road, London, SW1W...'
56
+ )
57
+ end
58
+ end
59
+ describe '#query_postcodes' do
60
+ before do
61
+ @postcode_params = @query_params.merge('SearchFor' => 'PostalCodes')
62
+ stub_get(@endpoint).with(query: @postcode_params).to_return(
63
+ body: fixture('capture_plus_search.json')
64
+ )
65
+ end
66
+ it 'requests the correct resource' do
67
+ @client.query_postcodes('A')
68
+ expect(a_get(@endpoint).with(query: @postcode_params)).to have_been_made
69
+ end
70
+ it 'returns a set of Postcode Anywhere search results' do
71
+ results = @client.query_postcodes('A')
72
+ expect(results).to be_an Array
73
+ expect(results.count).to eq 6
74
+ item = results.first
75
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
76
+ end
77
+ end
78
+ describe '#query_companies' do
79
+ before do
80
+ @companies_params = @query_params.merge('SearchFor' => 'Companies')
81
+ stub_get(@endpoint).with(query: @companies_params).to_return(
82
+ body: fixture('capture_plus_search.json')
83
+ )
84
+ end
85
+ it 'requests the correct resource' do
86
+ @client.query_companies('A')
87
+ expect(a_get(@endpoint).with(query: @companies_params)).to have_been_made
88
+ end
89
+ it 'returns a set of Postcode Anywhere search results' do
90
+ results = @client.query_companies('A')
91
+ expect(results).to be_an Array
92
+ expect(results.count).to eq 6
93
+ item = results.first
94
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
95
+ end
96
+ end
97
+ describe '#query_places' do
98
+ before do
99
+ @place_params = @query_params.merge('SearchFor' => 'Places')
100
+ stub_get(@endpoint).with(query: @place_params).to_return(
101
+ body: fixture('capture_plus_search.json')
102
+ )
103
+ end
104
+ it 'requests the correct resource' do
105
+ @client.query_places('A')
106
+ expect(a_get(@endpoint).with(query: @place_params)).to have_been_made
107
+ end
108
+ it 'returns a set of Postcode Anywhere search results' do
109
+ results = @client.query_places('A')
110
+ expect(results).to be_an Array
111
+ expect(results.count).to eq 6
112
+ item = results.first
113
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
114
+ end
115
+ end
116
+ describe 'custom options' do
117
+ before do
118
+ @custom_params = @query_params.merge(
119
+ 'Country' => 'FR',
120
+ 'LanguagePreference' => 'PP',
121
+ 'LastId' => '999'
122
+ )
123
+ stub_get(@endpoint).with(query: @custom_params).to_return(
124
+ body: fixture('capture_plus_search.json')
125
+ )
126
+ end
127
+ it 'requests the correct resource' do
128
+ @client.query('A', country: 'FR', language: 'PP', parent_query: '999')
129
+ expect(a_get(@endpoint).with(query: @custom_params)).to have_been_made
130
+ end
131
+ it 'returns a set of Postcode Anywhere search results' do
132
+ results = @client.query('A', country: 'FR', language: 'PP', parent_query: '999')
133
+ expect(results).to be_an Array
134
+ expect(results.count).to eq 6
135
+ item = results.first
136
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
137
+ end
138
+ end
139
+ describe '#sub_query' do
140
+ before do
141
+ @custom_params = @query_params.merge('LastId' => '123456')
142
+ stub_get(@endpoint).with(query: @custom_params).to_return(
143
+ body: fixture('capture_plus_search.json')
144
+ )
145
+ end
146
+ context 'when the parent query is a string' do
147
+ it 'requests the correct resource' do
148
+ @client.sub_query('A', '123456')
149
+ expect(a_get(@endpoint).with(query: @custom_params)).to have_been_made
150
+ end
151
+ it 'returns a set of Postcode Anywhere search results' do
152
+ results = @client.sub_query('A', '123456')
153
+ expect(results).to be_an Array
154
+ expect(results.count).to eq 6
155
+ item = results.first
156
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
157
+ end
158
+ end
159
+ context 'when the parent query is a SearchResult object' do
160
+ before do
161
+ @search_result = PostcodeAnywhere::CapturePlus::SearchResult.new(id: '123456')
162
+ end
163
+ it 'requests the correct resource' do
164
+ @client.sub_query('A', @search_result)
165
+ expect(a_get(@endpoint).with(query: @custom_params)).to have_been_made
166
+ end
167
+ it 'returns a set of Postcode Anywhere search results' do
168
+ results = @client.sub_query('A', @search_result)
169
+ expect(results).to be_an Array
170
+ expect(results.count).to eq 6
171
+ item = results.first
172
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::SearchResult
173
+ end
174
+ end
175
+ end
176
+ end
177
+
178
+ describe 'Retrieval' do
179
+ before do
180
+ @endpoint = 'CapturePlus/Interactive/Retrieve/v2.00/json.ws'
181
+ @retrieve_params = {
182
+ 'Key' => 'interactive_test_key',
183
+ 'Id' => '888'
184
+ }
185
+ @search_result = PostcodeAnywhere::CapturePlus::SearchResult.new(id: '888')
186
+ end
187
+ describe '#retrieve' do
188
+ before do
189
+ stub_get(@endpoint).with(query: @retrieve_params).to_return(
190
+ body: fixture('capture_plus_retrieve.json')
191
+ )
192
+ end
193
+ it 'requests the correct resource' do
194
+ @client.retrieve(@search_result)
195
+ expect(a_get(@endpoint).with(query: @retrieve_params)).to have_been_made
196
+ end
197
+ it 'returns a set of Postcode Anywhere search results' do
198
+ item = @client.retrieve(@search_result)
199
+ expect(item).to be_a PostcodeAnywhere::CapturePlus::RetrieveResult
200
+ expect(item.id).to eq('GBR|PR|11507281|0|0|0')
201
+ expect(item.domestic_id).to eq '11507281'
202
+ expect(item.language).to eq 'ENG'
203
+ expect(item.language_alternatives).to eq 'ENG'
204
+ expect(item.department).to eq 'dpmnt'
205
+ expect(item.company).to eq 'Asda Stores Ltd'
206
+ expect(item.sub_building).to eq 'sub1'
207
+ expect(item.building_number).to eq 'building1'
208
+ expect(item.building_name).to eq 'buildingz'
209
+ expect(item.secondary_street).to eq 'secondy'
210
+ expect(item.street).to eq 'strt'
211
+ expect(item.block).to eq 'blk2'
212
+ expect(item.neighbourhood).to eq 'ngbrhd'
213
+ expect(item.district).to eq 'dstrkt'
214
+ expect(item.city).to eq 'Ipswich'
215
+ expect(item.line1).to eq 'ln12'
216
+ expect(item.line2).to eq 'ln22'
217
+ expect(item.line3).to eq 'ln33'
218
+ expect(item.line4).to eq 'ln44'
219
+ expect(item.line5).to eq 'ln55'
220
+ expect(item.admin_area_name).to eq 'Ipswich'
221
+ expect(item.admin_area_code).to eq '42UD'
222
+ expect(item.province).to eq 'Suffolk'
223
+ expect(item.province_name).to eq 'Suffolk'
224
+ expect(item.province_code).to eq 'provcode'
225
+ expect(item.postal_code).to eq 'IP1 5PD'
226
+ expect(item.country_name).to eq 'United Kingdom'
227
+ expect(item.country_iso2).to eq 'GB'
228
+ expect(item.country_iso3).to eq 'GBR'
229
+ expect(item.country_iso_number).to eq '826'
230
+ expect(item.sorting_number1).to eq '56123'
231
+ expect(item.sorting_number2).to eq 'srt2'
232
+ expect(item.barcode).to eq '(IP15PD1AL)'
233
+ expect(item.po_box_number).to eq 'pbx2'
234
+ expect(item.label).to eq 'Asda Stores Ltd IPSWICH IP1 5PD UNITED KINGDOM'
235
+ expect(item.type).to eq 'Commercial'
236
+ expect(item.data_level).to eq 'Premise'
237
+ end
238
+ end
239
+ end
240
+ end