postcode-anywhere 1.0.1

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.
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,65 @@
1
+ describe PostcodeAnywhere::CleansePlus::Interactive do
2
+ before do
3
+ @client = PostcodeAnywhere::CleansePlus::Client.new(api_key: 'interactive_test_key')
4
+ end
5
+ describe '#address_candidates_for' do
6
+ before do
7
+ @endpoint = 'CleansePlus/Interactive/Cleanse/v1.00/json.ws'
8
+ @query_params = { 'Key' => 'interactive_test_key', 'Address' => 'A' }
9
+ end
10
+ context 'when a single result is returned' do
11
+ before do
12
+ stub_get(@endpoint).with(query: @query_params).to_return(
13
+ body: fixture('cleanse_address_single.json')
14
+ )
15
+ end
16
+ it 'requests the correct resource' do
17
+ @client.address_candidates_for('A')
18
+ expect(a_get(@endpoint).with(query: @query_params)).to have_been_made
19
+ end
20
+ it 'returns a Postcode Anywhere cleaned address' do
21
+ candidates = @client.address_candidates_for('A')
22
+ expect(candidates).to be_an Array
23
+ item = candidates.first
24
+ expect(item).to be_a PostcodeAnywhere::CleansePlus::CleansedAddress
25
+ expect(item.udprn).to eq 26_742_632
26
+ expect(item.company).to eq 'some company'
27
+ expect(item.department).to eq 'some department'
28
+ expect(item.line1).to eq 'Enigma House'
29
+ expect(item.line2).to eq 'Elgar Business Centre'
30
+ expect(item.line3).to eq 'Moseley Road'
31
+ expect(item.line4).to eq 'Hallow'
32
+ expect(item.line5).to eq 'where is this'
33
+ expect(item.post_town).to eq 'Worcester'
34
+ expect(item.county).to eq 'Worcestershire'
35
+ expect(item.postcode).to eq 'WR2 6NJ'
36
+ expect(item.mailsort).to eq 94_141
37
+ expect(item.barcode).to eq '(WR26NJ3UT)'
38
+ expect(item.type).to eq 'Residential'
39
+ expect(item.delivery_point_suffix).to eq '3U'
40
+ expect(item.sub_building).to eq 'Enigma House'
41
+ expect(item.building_name).to eq 'Elgar Business Centre'
42
+ expect(item.building_number).to eq '3'
43
+ expect(item.primary_street).to eq 'Moseley Road'
44
+ expect(item.secondary_street).to eq 'secondy'
45
+ expect(item.double_dependent_locality).to eq 'ddlocal'
46
+ expect(item.dependent_locality).to eq 'Hallow'
47
+ expect(item.po_box).to eq 'po123'
48
+ end
49
+ end
50
+ context 'when a multiple candidates returned' do
51
+ before do
52
+ stub_get(@endpoint).with(query: @query_params).to_return(
53
+ body: fixture('cleanse_address_multi.json')
54
+ )
55
+ end
56
+ it 'returns a set of candidates for a postcode anywhere address' do
57
+ candidates = @client.address_candidates_for('A')
58
+ expect(candidates).to be_an Array
59
+ expect(candidates.count).to be 2
60
+ expect(candidates.first.udprn).to eq 26_742_632
61
+ expect(candidates.last.udprn).to eq 2_222
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,124 @@
1
+ describe PostcodeAnywhere::Client do
2
+ before do
3
+ @keys = PostcodeAnywhere::Configuration::VALID_CONFIG_KEYS
4
+ end
5
+
6
+ describe 'with module configuration' do
7
+ before do
8
+ PostcodeAnywhere.configure do |config|
9
+ @keys.each do |key|
10
+ config.send("#{key}=", key)
11
+ end
12
+ end
13
+ end
14
+
15
+ after do
16
+ PostcodeAnywhere.reset
17
+ end
18
+
19
+ context 'when no credentials are provided' do
20
+ it 'does not raise an exception' do
21
+ expect { PostcodeAnywhere::Client.new }.not_to raise_error
22
+ end
23
+ end
24
+
25
+ it 'should inherit module configuration' do
26
+ api = PostcodeAnywhere::Client.new
27
+ @keys.each do |key|
28
+ expect(api.send(key)).to eq key
29
+ end
30
+ end
31
+
32
+ describe 'with class configuration' do
33
+ before do
34
+ @config = {
35
+ api_key: 'ak',
36
+ format: 'of',
37
+ endpoint: 'ep',
38
+ user_agent: 'ua',
39
+ method: 'hm'
40
+ }
41
+ end
42
+
43
+ it 'should override module configuration' do
44
+ api = PostcodeAnywhere::Client.new(@config)
45
+ @keys.each do |key|
46
+ expect(api.send(key)).to eq @config[key]
47
+ end
48
+ end
49
+
50
+ it 'should override module configuration after' do
51
+ api = PostcodeAnywhere::Client.new
52
+
53
+ @config.each do |key, value|
54
+ api.send("#{key}=", value)
55
+ end
56
+
57
+ @keys.each do |key|
58
+ expect(api.send("#{key}")).to eq @config[key]
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#connection_options' do
64
+ it 'returns the connection options hash with user_agent' do
65
+ client = PostcodeAnywhere::Client.new(user_agent: 'My Test Gem')
66
+ expect(client.connection_options[:headers][:user_agent]).to eql('My Test Gem')
67
+ end
68
+ end
69
+
70
+ describe '#connection' do
71
+ let(:connection_client) { PostcodeAnywhere::Client.new(endpoint: 'http://localhost') }
72
+ it 'looks like Faraday connection' do
73
+ expect(connection_client.send(:connection)).to respond_to(:run_request)
74
+ end
75
+ end
76
+
77
+ describe '#request' do
78
+ let(:connection_client) { PostcodeAnywhere::Client.new(endpoint: 'http://localhost') }
79
+ it 'catches and reraises Faraday timeout errors' do
80
+ allow(connection_client).to receive(:connection).and_raise(
81
+ Faraday::Error::TimeoutError.new('execution expired')
82
+ )
83
+ expect { connection_client.send(:request, :get, '/path') }.to raise_error(
84
+ PostcodeAnywhere::Error::RequestTimeout
85
+ )
86
+ end
87
+ it 'catches and reraises Timeout errors' do
88
+ allow(connection_client).to receive(:connection).and_raise(
89
+ Timeout::Error.new('execution expired')
90
+ )
91
+ expect { connection_client.send(:request, :get, '/path') }.to raise_error(
92
+ PostcodeAnywhere::Error::RequestTimeout
93
+ )
94
+ end
95
+ it 'catches and reraises Faraday client errors' do
96
+ allow(connection_client).to receive(:connection).and_raise(
97
+ Faraday::Error::ClientError.new('connection failed')
98
+ )
99
+ expect { connection_client.send(:request, :get, '/path') }.to raise_error(
100
+ PostcodeAnywhere::Error
101
+ )
102
+ end
103
+ it 'catches and reraises JSON::ParserError errors' do
104
+ allow(connection_client).to receive(:connection).and_raise(
105
+ JSON::ParserError.new('unexpected token')
106
+ )
107
+ expect { connection_client.send(:request, :get, '/path') }.to raise_error(
108
+ PostcodeAnywhere::Error
109
+ )
110
+ end
111
+ end
112
+
113
+ describe '#compile_body' do
114
+ let(:connection_client) { PostcodeAnywhere::Client.new(endpoint: 'http://localhost') }
115
+ it 'takes a hash of body params and returns them represented as a JSON string' do
116
+ sample_hash = { 'test_item_1' => 'this_is_a_test_item' }
117
+ expect(connection_client.send(:compile_body, sample_hash)).to eq(
118
+ '{"test_item_1":"this_is_a_test_item"}'
119
+ )
120
+ end
121
+ end
122
+
123
+ end
124
+ end
@@ -0,0 +1,62 @@
1
+ describe 'configuration' do
2
+
3
+ after do
4
+ PostcodeAnywhere.reset
5
+ end
6
+
7
+ describe '.configure' do
8
+ PostcodeAnywhere::Configuration::VALID_CONFIG_KEYS.each do |key|
9
+ it "should set the #{key}" do
10
+ PostcodeAnywhere.configure do |config|
11
+ config.send("#{key}=", key)
12
+ expect(PostcodeAnywhere.send(key)).to eq key
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '.api_key' do
19
+ subject { PostcodeAnywhere.api_key }
20
+ it 'should return default api key' do
21
+ expect(PostcodeAnywhere::Configuration::DEFAULT_API_KEY).to eq ''
22
+ is_expected.to eq PostcodeAnywhere::Configuration::DEFAULT_API_KEY
23
+ end
24
+ end
25
+
26
+ describe '.endpoint' do
27
+ subject { PostcodeAnywhere.endpoint }
28
+ it 'should return default api endpoint' do
29
+ expect(PostcodeAnywhere::Configuration::DEFAULT_ENDPOINT).to eq(
30
+ 'http://services.postcodeanywhere.co.uk/'
31
+ )
32
+ is_expected.to eq PostcodeAnywhere::Configuration::DEFAULT_ENDPOINT
33
+ end
34
+ end
35
+
36
+ describe '.format' do
37
+ subject { PostcodeAnywhere.format }
38
+ it 'should return default REST content format of json' do
39
+ expect(PostcodeAnywhere::Configuration::DEFAULT_FORMAT).to eq :json
40
+ is_expected.to eq PostcodeAnywhere::Configuration::DEFAULT_FORMAT
41
+ end
42
+ end
43
+
44
+ describe '.user_agent' do
45
+ subject { PostcodeAnywhere.user_agent }
46
+ it 'should return default user agent' do
47
+ expect(PostcodeAnywhere::Configuration::DEFAULT_USER_AGENT).to eq(
48
+ "Postcode Anywhere Ruby Gem/#{PostcodeAnywhere::VERSION}"
49
+ )
50
+ is_expected.to eq PostcodeAnywhere::Configuration::DEFAULT_USER_AGENT
51
+ end
52
+ end
53
+
54
+ describe '.method' do
55
+ subject { PostcodeAnywhere.method }
56
+ it 'should return default user agent' do
57
+ expect(PostcodeAnywhere::Configuration::DEFAULT_METHOD).to eq :post
58
+ is_expected.to eq PostcodeAnywhere::Configuration::DEFAULT_METHOD
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,30 @@
1
+ describe PostcodeAnywhere::EmailValidation::Interactive do
2
+ before do
3
+ @client = PostcodeAnywhere::EmailValidation::Client.new(api_key: 'interactive_test_key')
4
+ end
5
+ describe '#validate_email_address' do
6
+ before do
7
+ @endpoint = 'EmailValidation/Interactive/Validate/v1.10/json3.ws'
8
+ @query_params = { 'Key' => 'interactive_test_key', 'Email' => 'A', 'Timeout' => 4 }
9
+ end
10
+ context 'when a single result is returned' do
11
+ before do
12
+ stub_get(@endpoint).with(query: @query_params).to_return(
13
+ body: fixture('email_validation_validate_email.json')
14
+ )
15
+ end
16
+ it 'requests the correct resource' do
17
+ @client.validate_email_address('A', 4)
18
+ expect(a_get(@endpoint).with(query: @query_params)).to have_been_made
19
+ end
20
+ it 'returns a Postcode Anywhere email validation result' do
21
+ item = @client.validate_email_address('A', 4)
22
+ expect(item).to be_a PostcodeAnywhere::EmailValidation::ValidationResult
23
+ expect(item.email).to eq 'info@google.com'
24
+ expect(item.mail_server).to eq 'alt4.aspmx.l.google.com'
25
+ expect(item.valid_format).to eq true
26
+ expect(item.found_dns_record).to eq true
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,70 @@
1
+ describe PostcodeAnywhere::Error do
2
+ before do
3
+ @client = PostcodeAnywhere::CleansePlus::Client.new(api_key: 'error_test_key')
4
+ end
5
+
6
+ describe '#message' do
7
+ it 'returns the error message' do
8
+ error = PostcodeAnywhere::Error.new('execution expired')
9
+ expect(error.message).to eq('execution expired')
10
+ end
11
+ end
12
+
13
+ describe '#code' do
14
+ it 'returns the error code' do
15
+ error = PostcodeAnywhere::Error.new('execution expired', 123)
16
+ expect(error.code).to eq(123)
17
+ end
18
+ end
19
+
20
+ describe '#cause' do
21
+ it 'returns the error cause message' do
22
+ error = PostcodeAnywhere::Error.new('execution expired', 1, 'some cause')
23
+ expect(error.cause).to eq('some cause')
24
+ end
25
+ end
26
+
27
+ describe '#resolution' do
28
+ it 'returns the error resolution message' do
29
+ error = PostcodeAnywhere::Error.new('execution expired', 1, '', 'some resolution')
30
+ expect(error.resolution).to eq('some resolution')
31
+ end
32
+ end
33
+
34
+ context "when JSON body contains an 'Error:'" do
35
+ before do
36
+ body =
37
+ '[{"Error":"2","Description":"UK","Cause":"CS","Resolution":"RS"}]'
38
+
39
+ endpoint = PostcodeAnywhere::CleansePlus::Interactive::CLEANSE_ADDRESS_ENDPOINT
40
+ query_params = { 'Key' => 'error_test_key', 'Address' => 'A' }
41
+ stub_get(endpoint).with(query: query_params).to_return(
42
+ status: 200,
43
+ body: body,
44
+ headers: { content_type: 'application/json; charset=utf-8' }
45
+ )
46
+ end
47
+ it 'raises an exception with the proper message' do
48
+ expect { @client.address_candidates_for('A') }.to raise_error do |error|
49
+ expect(error).to be_a PostcodeAnywhere::Error::UnknownKey
50
+ expect(error.message).to eq 'UK'
51
+ expect(error.cause).to eq 'CS'
52
+ expect(error.resolution).to eq 'RS'
53
+ end
54
+ end
55
+ end
56
+
57
+ PostcodeAnywhere::Error.errors.each do |status, exception|
58
+ context "when HTTP status is #{status}" do
59
+ before do
60
+ endpoint = PostcodeAnywhere::CleansePlus::Interactive::CLEANSE_ADDRESS_ENDPOINT
61
+ query_params = { 'Key' => 'error_test_key', 'Address' => 'A' }
62
+ stub_get(endpoint).with(query: query_params).to_return(status: status)
63
+ end
64
+ it "raises #{exception}" do
65
+ expect { @client.address_candidates_for('A') }.to raise_error(exception)
66
+ end
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1 @@
1
+ [{"Bank":"HSBC BANK PLC","BankBIC":"MIDLGB21","Branch":"Cheltenham Bath Road","BranchBIC":"03N","ContactAddressLine1":"109 Bath Road","ContactAddressLine2":"l2","ContactPostTown":"Cheltenham","ContactPostcode":"GL53 7RA","ContactPhone":"01234567890","ContactFax":"111","FasterPaymentsSupported":"True","CHAPSSupported":"True"}]
@@ -0,0 +1 @@
1
+ [{"IsCorrect":"True","IsDirectDebitCapable":"True","StatusInformation":"OK","CorrectedSortCode":"012345","CorrectedAccountNumber":"12345678","IBAN":"1111111111111111111111","Bank":"NATIONAL WESTMINSTER BANK PLC","BankBIC":"BIKBIKBI","Branch":"A bank in town","BranchBIC":"01X","ContactAddressLine1":"Leicester Rcsc","ContactAddressLine2":"Bede House","ContactPostTown":"Leicester","ContactPostcode":"LE2 7EJ","ContactPhone":"0870 2403355","ContactFax":"222","FasterPaymentsSupported":"True","CHAPSSupported":"True"}]
@@ -0,0 +1 @@
1
+ [{"Id":"GBR|PR|11507281|0|0|0","DomesticId":"11507281","Language":"ENG","LanguageAlternatives":"ENG","Department":"dpmnt","Company":"Asda Stores Ltd","SubBuilding":"sub1","BuildingNumber":"building1","BuildingName":"buildingz","SecondaryStreet":"secondy","Street":"strt","Block":"blk2","Neighbourhood":"ngbrhd","District":"dstrkt","City":"Ipswich","Line1":"ln12","Line2":"ln22","Line3":"ln33","Line4":"ln44","Line5":"ln55","AdminAreaName":"Ipswich","AdminAreaCode":"42UD","Province":"Suffolk","ProvinceName":"Suffolk","ProvinceCode":"provcode","PostalCode":"IP1 5PD","CountryName":"United Kingdom","CountryIso2":"GB","CountryIso3":"GBR","CountryIsoNumber":"826","SortingNumber1":"56123","SortingNumber2":"srt2","Barcode":"(IP15PD1AL)","POBoxNumber":"pbx2","Label":"Asda Stores Ltd IPSWICH IP1 5PD UNITED KINGDOM","Type":"Commercial","DataLevel":"Premise"}]
@@ -0,0 +1 @@
1
+ [{"Id":"GBR|CN|QgB1AGMAawBpAG4AZwBoAGEAbQAgAFAAYQBsAGEAYwBlACwAIABMAG8AbgBkAG8AbgAsACAAUwBXADEAQQAuAC4ALgA*|2562-0-3","Text":"Buckingham Palace, London, SW1A...","Highlight":"1-3","Cursor":"0","Description":"3 Results","Next":"Find"}, {"Id":"GBR|CN|QgB1AGMAawBpAG4AZwBoAGEAbQAgAFAAYQBsAGEAYwBlACAAUgBvAGEAZAAsACAATABvAG4AZABvAG4ALAAgAFMAVwAxAFcALgAuAC4A|2567-0-4","Text":"Buckingham Palace Road, London, SW1W...","Highlight":"","Cursor":"0","Description":"80 Results","Next":"Find"}, {"Id":"GBR|PR|23768658|0|0|0","Text":"Buckingham Balti House, 42, Buckingham Palace Road, London, SW1W...","Highlight":"","Cursor":"67","Description":"","Next":"Retrieve"}, {"Id":"GBR|PR|23748336|0|0|0","Text":"Buckingham Coffee Lounge, 19-21, Palace Street, London, SW1E...","Highlight":"","Cursor":"63","Description":"","Next":"Retrieve"}, {"Id":"GBR|PR|52858007|0|0|0","Text":"Gardeners Lodge, Buckingham Palace Gardens, Lower Grosvenor Place, London, SW1W...","Highlight":"","Cursor":"82","Description":"","Next":"Retrieve"}, {"Id":"GBR|PR|52630298|0|0|0","Text":"Buckingham Palace Gift Shop, 7-9, Buckingham Palace Road, London, SW1W...","Highlight":"","Cursor":"73","Description":"","Next":"Retrieve"}]
@@ -0,0 +1 @@
1
+ {"Items":[{"Udprn":26742632,"Company":"some company","Department":"some department","Line1":"Enigma House","Line2":"Elgar Business Centre","Line3":"Moseley Road","Line4":"Hallow","Line5":"where is this","PostTown":"Worcester","County":"Worcestershire","Postcode":"WR2 6NJ","Mailsort":94141,"Barcode":"(WR26NJ3UT)","Type":"Residential","DeliveryPointSuffix":"3U","SubBuilding":"Enigma House","BuildingName":"Elgar Business Centre","BuildingNumber":"3","PrimaryStreet":"Moseley Road","SecondaryStreet":"secondy","DoubleDependentLocality":"ddlocal","DependentLocality":"Hallow","PoBox":"po123"},{"Udprn":2222,"Company":"some company","Department":"some department","Line1":"Enigma House","Line2":"Elgar Business Centre","Line3":"Moseley Road","Line4":"Hallow","Line5":"where is this","PostTown":"Worcester","County":"Worcestershire","Postcode":"WR2 6NJ","Mailsort":94141,"Barcode":"(WR26NJ3UT)","Type":"Residential","DeliveryPointSuffix":"3U","SubBuilding":"Enigma House","BuildingName":"Elgar Business Centre","BuildingNumber":"3","PrimaryStreet":"Moseley Road","SecondaryStreet":"secondy","DoubleDependentLocality":"ddlocal","DependentLocality":"Hallow","PoBox":"po123"}]}
@@ -0,0 +1 @@
1
+ [{"Udprn":26742632,"Company":"some company","Department":"some department","Line1":"Enigma House","Line2":"Elgar Business Centre","Line3":"Moseley Road","Line4":"Hallow","Line5":"where is this","PostTown":"Worcester","County":"Worcestershire","Postcode":"WR2 6NJ","Mailsort":94141,"Barcode":"(WR26NJ3UT)","Type":"Residential","DeliveryPointSuffix":"3U","SubBuilding":"Enigma House","BuildingName":"Elgar Business Centre","BuildingNumber":"3","PrimaryStreet":"Moseley Road","SecondaryStreet":"secondy","DoubleDependentLocality":"ddlocal","DependentLocality":"Hallow","PoBox":"po123"}]
@@ -0,0 +1 @@
1
+ [{"Email":"info@google.com","MailServer":"alt4.aspmx.l.google.com","ValidFormat":"True","FoundDnsRecord":"True"}]
@@ -0,0 +1,10 @@
1
+ describe PostcodeAnywhere::ModelBase do
2
+ before do
3
+ @base = PostcodeAnywhere::ModelBase.new(id: 1)
4
+ end
5
+ describe '#attrs' do
6
+ it 'returns a hash of attributes' do
7
+ expect(@base.attrs).to eq(id: 1)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'postcode_anywhere'
5
+
6
+ require 'webmock/rspec'
7
+
8
+ WebMock.disable_net_connect!()
9
+
10
+ RSpec.configure do |config|
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
15
+
16
+ def stub_get(path)
17
+ stub_request(:get, PostcodeAnywhere.endpoint + path)
18
+ end
19
+
20
+ def stub_post(path)
21
+ stub_request(:post, PostcodeAnywhere.endpoint + path)
22
+ end
23
+
24
+ def a_post(path)
25
+ a_request(:post, PostcodeAnywhere.endpoint + path)
26
+ end
27
+
28
+ def a_get(path)
29
+ a_request(:get, PostcodeAnywhere.endpoint + path)
30
+ end
31
+
32
+ def fixture_path
33
+ File.expand_path('../postcode_anywhere/fixtures', __FILE__)
34
+ end
35
+
36
+ def fixture(file)
37
+ File.new(fixture_path + '/' + file)
38
+ end
metadata ADDED
@@ -0,0 +1,281 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: postcode-anywhere
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Edward Woodcock
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: memoizable
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.4'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.4.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.4'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.4.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: pre-commit
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.19'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.19.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.19'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 0.19.0
73
+ - !ruby/object:Gem::Dependency
74
+ name: webmock
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '1.18'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.18.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.18'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.18.0
93
+ - !ruby/object:Gem::Dependency
94
+ name: rubocop
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.26'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.26.1
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.26'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.26.1
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.1'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 3.1.0
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.1'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 3.1.0
133
+ - !ruby/object:Gem::Dependency
134
+ name: spring-commands-rspec
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.0'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 1.0.2
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 1.0.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: bundler
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.6'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.6'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rake
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '10.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '10.0'
181
+ description: A number of fully-tested clients for interacting with all of the available
182
+ postcode anywhere services, including capture, cleansing, payment validation and
183
+ email validation
184
+ email:
185
+ - edward@simple-merchant.com
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".rubocop.yml"
193
+ - Gemfile
194
+ - Gemfile.lock
195
+ - LICENSE.txt
196
+ - README.md
197
+ - Rakefile
198
+ - config/pre_commit.yml
199
+ - lib/postcode_anywhere.rb
200
+ - lib/postcode_anywhere/bank_account_validation/bank_branch.rb
201
+ - lib/postcode_anywhere/bank_account_validation/client.rb
202
+ - lib/postcode_anywhere/bank_account_validation/interactive.rb
203
+ - lib/postcode_anywhere/bank_account_validation/validation_result.rb
204
+ - lib/postcode_anywhere/capture_plus/client.rb
205
+ - lib/postcode_anywhere/capture_plus/interactive.rb
206
+ - lib/postcode_anywhere/capture_plus/query_type.rb
207
+ - lib/postcode_anywhere/capture_plus/retrieve_result.rb
208
+ - lib/postcode_anywhere/capture_plus/search_result.rb
209
+ - lib/postcode_anywhere/cleanse_plus/cleansed_address.rb
210
+ - lib/postcode_anywhere/cleanse_plus/client.rb
211
+ - lib/postcode_anywhere/cleanse_plus/interactive.rb
212
+ - lib/postcode_anywhere/client.rb
213
+ - lib/postcode_anywhere/configuration.rb
214
+ - lib/postcode_anywhere/email_validation/client.rb
215
+ - lib/postcode_anywhere/email_validation/interactive.rb
216
+ - lib/postcode_anywhere/email_validation/validation_result.rb
217
+ - lib/postcode_anywhere/error.rb
218
+ - lib/postcode_anywhere/model_base.rb
219
+ - lib/postcode_anywhere/request.rb
220
+ - lib/postcode_anywhere/response/parse_json.rb
221
+ - lib/postcode_anywhere/response/raise_error.rb
222
+ - lib/postcode_anywhere/utils.rb
223
+ - lib/postcode_anywhere/version.rb
224
+ - postcode_anywhere.gemspec
225
+ - spec/postcode_anywhere/bank_account_validation/interactive_spec.rb
226
+ - spec/postcode_anywhere/capture_plus/interactive_spec.rb
227
+ - spec/postcode_anywhere/cleanse_plus/interactive_spec.rb
228
+ - spec/postcode_anywhere/client_spec.rb
229
+ - spec/postcode_anywhere/configuration_spec.rb
230
+ - spec/postcode_anywhere/email_validation/interactive_spec.rb
231
+ - spec/postcode_anywhere/error_spec.rb
232
+ - spec/postcode_anywhere/fixtures/bank_account_retrieve_by_sort.json
233
+ - spec/postcode_anywhere/fixtures/bank_account_validate_account.json
234
+ - spec/postcode_anywhere/fixtures/capture_plus_retrieve.json
235
+ - spec/postcode_anywhere/fixtures/capture_plus_search.json
236
+ - spec/postcode_anywhere/fixtures/cleanse_address_multi.json
237
+ - spec/postcode_anywhere/fixtures/cleanse_address_single.json
238
+ - spec/postcode_anywhere/fixtures/email_validation_validate_email.json
239
+ - spec/postcode_anywhere/model_base_spec.rb
240
+ - spec/spec_helper.rb
241
+ homepage: https://github.com/simplemerchant/postcode-anywhere
242
+ licenses:
243
+ - MIT
244
+ metadata: {}
245
+ post_install_message:
246
+ rdoc_options: []
247
+ require_paths:
248
+ - lib
249
+ required_ruby_version: !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - ">="
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ required_rubygems_version: !ruby/object:Gem::Requirement
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ version: '0'
259
+ requirements: []
260
+ rubyforge_project:
261
+ rubygems_version: 2.4.1
262
+ signing_key:
263
+ specification_version: 4
264
+ summary: Full set of Postcode Anywhere API clients - http://postcodeanywhere.co.uk
265
+ test_files:
266
+ - spec/postcode_anywhere/bank_account_validation/interactive_spec.rb
267
+ - spec/postcode_anywhere/capture_plus/interactive_spec.rb
268
+ - spec/postcode_anywhere/cleanse_plus/interactive_spec.rb
269
+ - spec/postcode_anywhere/client_spec.rb
270
+ - spec/postcode_anywhere/configuration_spec.rb
271
+ - spec/postcode_anywhere/email_validation/interactive_spec.rb
272
+ - spec/postcode_anywhere/error_spec.rb
273
+ - spec/postcode_anywhere/fixtures/bank_account_retrieve_by_sort.json
274
+ - spec/postcode_anywhere/fixtures/bank_account_validate_account.json
275
+ - spec/postcode_anywhere/fixtures/capture_plus_retrieve.json
276
+ - spec/postcode_anywhere/fixtures/capture_plus_search.json
277
+ - spec/postcode_anywhere/fixtures/cleanse_address_multi.json
278
+ - spec/postcode_anywhere/fixtures/cleanse_address_single.json
279
+ - spec/postcode_anywhere/fixtures/email_validation_validate_email.json
280
+ - spec/postcode_anywhere/model_base_spec.rb
281
+ - spec/spec_helper.rb