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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d77ceb2c1c83fb36846aadde46eb92197cfe45a
4
+ data.tar.gz: 87a3e96b4a547d322fee113fedda5a71d481a669
5
+ SHA512:
6
+ metadata.gz: f098b5ca2330b8e981ddf15a8d09c339abe97d32b7f426b4058c03c4a7237e6b40f425f3ae714f60fd69cf9607c5e219f1af037fed81a5bfd1e7517fa799fb1a
7
+ data.tar.gz: 210c1bae2640b1de4b1cee91bd4145956d5832da6e208cfaddf38064ed1d1fe736e8005f4ea4f73844c4436339703f8ce79bf06e9e689cb72b22a2b353b7a408
@@ -0,0 +1,30 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ /log
4
+ /tmp
5
+ /db/*.sqlite3
6
+ /public/system
7
+ /coverage/
8
+ /spec/tmp
9
+ **.orig
10
+ rerun.txt
11
+ pickle-email-*.html
12
+
13
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
14
+ config/initializers/secret_token.rb
15
+ config/secrets.yml
16
+
17
+ ## Environment normalisation:
18
+ /.bundle
19
+ /vendor/bundle
20
+
21
+ # these should all be checked in to normalise the environment:
22
+ # Gemfile.lock, .ruby-version, .ruby-gemset
23
+
24
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
25
+ .rvmrc
26
+
27
+ # if using bower-rails ignore default bower_components path bower.json files
28
+ /vendor/assets/bower_components
29
+ *.bowerrc
30
+ bower.json
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,247 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/*.rake'
4
+ - '**/Gemfile'
5
+ Exclude:
6
+ - 'bin/*'
7
+ - 'db/schema.rb'
8
+ - 'spec/spec_helper.rb'
9
+
10
+ AccessorMethodName:
11
+ Enabled: false
12
+
13
+ Alias:
14
+ Enabled: false
15
+
16
+ ArrayJoin:
17
+ Enabled: false
18
+
19
+ AsciiComments:
20
+ Enabled: false
21
+
22
+ AsciiIdentifiers:
23
+ Enabled: false
24
+
25
+ Attr:
26
+ Enabled: true
27
+
28
+ BlockNesting:
29
+ Enabled: true
30
+
31
+ CaseEquality:
32
+ Enabled: true
33
+
34
+ CharacterLiteral:
35
+ Enabled: true
36
+
37
+ ClassLength:
38
+ Enabled: false
39
+
40
+ ClassVars:
41
+ Enabled: false
42
+
43
+ CollectionMethods:
44
+ PreferredMethods:
45
+ find: detect
46
+ reduce: inject
47
+ collect: map
48
+ find_all: select
49
+
50
+ ColonMethodCall:
51
+ Enabled: false
52
+
53
+ CommentAnnotation:
54
+ Enabled: false
55
+
56
+ CyclomaticComplexity:
57
+ Enabled: false
58
+
59
+ Delegate:
60
+ Enabled: true
61
+
62
+ DeprecatedHashMethods:
63
+ Enabled: false
64
+
65
+ Documentation:
66
+ Enabled: false
67
+
68
+ DotPosition:
69
+ EnforcedStyle: trailing
70
+
71
+ DoubleNegation:
72
+ Enabled: true
73
+
74
+ EmptyLiteral:
75
+ Enabled: true
76
+
77
+ Encoding:
78
+ Enabled: false
79
+
80
+ EvenOdd:
81
+ Enabled: false
82
+
83
+ FileName:
84
+ Enabled: false
85
+
86
+ FlipFlop:
87
+ Enabled: false
88
+
89
+ FormatString:
90
+ Enabled: false
91
+
92
+ GlobalVars:
93
+ Enabled: false
94
+
95
+ IfUnlessModifier:
96
+ Enabled: false
97
+
98
+ IfWithSemicolon:
99
+ Enabled: false
100
+
101
+ Lambda:
102
+ Enabled: false
103
+
104
+ LambdaCall:
105
+ Enabled: false
106
+
107
+ LineEndConcatenation:
108
+ Enabled: false
109
+
110
+ LineLength:
111
+ Max: 95
112
+
113
+ MethodLength:
114
+ Enabled: false
115
+
116
+ ModuleFunction:
117
+ Enabled: false
118
+
119
+ NegatedIf:
120
+ Enabled: false
121
+
122
+ NegatedWhile:
123
+ Enabled: false
124
+
125
+ NilComparison:
126
+ Enabled: true
127
+
128
+ Not:
129
+ Enabled: false
130
+
131
+ NumericLiterals:
132
+ Enabled: true
133
+
134
+ OneLineConditional:
135
+ Enabled: false
136
+
137
+ OpMethod:
138
+ Enabled: false
139
+
140
+ ParameterLists:
141
+ Enabled: false
142
+
143
+ PercentLiteralDelimiters:
144
+ PreferredDelimiters:
145
+ '%': '{}'
146
+
147
+ PerlBackrefs:
148
+ Enabled: false
149
+
150
+ PredicateName:
151
+ NamePrefixBlacklist:
152
+ - is_
153
+
154
+ Proc:
155
+ Enabled: false
156
+
157
+ RaiseArgs:
158
+ Enabled: false
159
+
160
+ RegexpLiteral:
161
+ Enabled: false
162
+
163
+ SelfAssignment:
164
+ Enabled: false
165
+
166
+ SingleLineBlockParams:
167
+ Enabled: false
168
+
169
+ SingleLineMethods:
170
+ Enabled: false
171
+
172
+ SignalException:
173
+ Enabled: false
174
+
175
+ SpecialGlobalVars:
176
+ Enabled: false
177
+
178
+ StringLiterals:
179
+ EnforcedStyle: single_quotes
180
+
181
+ VariableInterpolation:
182
+ Enabled: false
183
+
184
+ TrailingComma:
185
+ Enabled: true
186
+
187
+ TrivialAccessors:
188
+ Enabled: false
189
+
190
+ VariableInterpolation:
191
+ Enabled: false
192
+
193
+ WhenThen:
194
+ Enabled: false
195
+
196
+ WhileUntilModifier:
197
+ Enabled: false
198
+
199
+ WordArray:
200
+ Enabled: false
201
+
202
+ # Lint
203
+
204
+ AmbiguousOperator:
205
+ Enabled: true
206
+
207
+ AmbiguousRegexpLiteral:
208
+ Enabled: false
209
+
210
+ AssignmentInCondition:
211
+ Enabled: false
212
+
213
+ ConditionPosition:
214
+ Enabled: false
215
+
216
+ DeprecatedClassMethods:
217
+ Enabled: false
218
+
219
+ ElseLayout:
220
+ Enabled: false
221
+
222
+ HandleExceptions:
223
+ Enabled: true
224
+
225
+ InvalidCharacterLiteral:
226
+ Enabled: false
227
+
228
+ LiteralInCondition:
229
+ Enabled: false
230
+
231
+ LiteralInInterpolation:
232
+ Enabled: false
233
+
234
+ Loop:
235
+ Enabled: false
236
+
237
+ ParenthesesAsGroupedExpression:
238
+ Enabled: false
239
+
240
+ RequireParentheses:
241
+ Enabled: false
242
+
243
+ UnderscorePrefixedVariableName:
244
+ Enabled: false
245
+
246
+ Void:
247
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in postcode_anywhere.gemspec
4
+ gemspec
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ postcode-anywhere (1.0.1)
5
+ faraday (~> 0.9, >= 0.9.0)
6
+ memoizable (~> 0.4, >= 0.4.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ ast (2.0.0)
13
+ astrolabe (1.3.0)
14
+ parser (>= 2.2.0.pre.3, < 3.0)
15
+ crack (0.4.2)
16
+ safe_yaml (~> 1.0.0)
17
+ diff-lcs (1.2.5)
18
+ faraday (0.9.0)
19
+ multipart-post (>= 1.2, < 3)
20
+ memoizable (0.4.2)
21
+ thread_safe (~> 0.3, >= 0.3.1)
22
+ multipart-post (2.0.0)
23
+ parser (2.2.0.pre.4)
24
+ ast (>= 1.1, < 3.0)
25
+ slop (~> 3.4, >= 3.4.5)
26
+ pluginator (1.2.0)
27
+ powerpack (0.0.9)
28
+ pre-commit (0.19.0)
29
+ pluginator (~> 1.1)
30
+ rainbow (2.0.0)
31
+ rake (10.3.2)
32
+ rspec (3.1.0)
33
+ rspec-core (~> 3.1.0)
34
+ rspec-expectations (~> 3.1.0)
35
+ rspec-mocks (~> 3.1.0)
36
+ rspec-core (3.1.4)
37
+ rspec-support (~> 3.1.0)
38
+ rspec-expectations (3.1.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.1.0)
41
+ rspec-mocks (3.1.1)
42
+ rspec-support (~> 3.1.0)
43
+ rspec-support (3.1.0)
44
+ rubocop (0.26.1)
45
+ astrolabe (~> 1.3)
46
+ parser (>= 2.2.0.pre.4, < 3.0)
47
+ powerpack (~> 0.0.6)
48
+ rainbow (>= 1.99.1, < 3.0)
49
+ ruby-progressbar (~> 1.4)
50
+ ruby-progressbar (1.6.0)
51
+ safe_yaml (1.0.3)
52
+ slop (3.6.0)
53
+ spring (1.1.3)
54
+ spring-commands-rspec (1.0.2)
55
+ spring (>= 0.9.1)
56
+ thread_safe (0.3.4)
57
+ webmock (1.18.0)
58
+ addressable (>= 2.3.6)
59
+ crack (>= 0.3.2)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ bundler (~> 1.6)
66
+ postcode-anywhere!
67
+ pre-commit (~> 0.19, >= 0.19.0)
68
+ rake (~> 10.0)
69
+ rspec (~> 3.1, >= 3.1.0)
70
+ rubocop (~> 0.26, >= 0.26.1)
71
+ spring-commands-rspec (~> 1.0, >= 1.0.2)
72
+ webmock (~> 1.18, >= 1.18.0)
@@ -0,0 +1,21 @@
1
+ MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Simple Merchant
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,319 @@
1
+ # Postcode Anywhere
2
+
3
+ [ ![Codeship Status for simplemerchant/postcode_anywhere](https://codeship.io/projects/ade82b60-260e-0132-ce11-5220aac52c67/status)](https://codeship.io/projects/37329)
4
+
5
+ This is the Ruby gem for interacting with the [Postcode Anywhere API](http://www.postcodeanywhere.co.uk/support/webservices/) API
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'postcode_anywhere'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install postcode_anywhere
22
+
23
+ ## Usage
24
+
25
+ This Gem consists of a numer of available clients for each key service available from
26
+ Postcode Anywhere
27
+
28
+ ### [CapturePlus Address Validation](http://www.postcodeanywhere.co.uk/address-validation/api/)
29
+
30
+ Addresses can be searched upon by a number of different means. An array of results is always
31
+ returned:
32
+
33
+ #### General search
34
+
35
+ This searches everyhing:
36
+
37
+ ```ruby
38
+ client = PostcodeAnywhere::CapturePlus::Client.new(
39
+ api_key: 'YOUR_API_KEY',
40
+ )
41
+
42
+ results = client.query 'buckingham pal'
43
+ results.count
44
+ # => 7
45
+ results.first.text
46
+ # => "Buckingham Palace, London, SW1A..."
47
+ ```
48
+
49
+ #### By postcode
50
+
51
+ This searches by postcode:
52
+
53
+ ```ruby
54
+ client = PostcodeAnywhere::CapturePlus::Client.new(
55
+ api_key: 'YOUR_API_KEY',
56
+ )
57
+
58
+ results = client.query_postcodes 'SW1A'
59
+ # OR
60
+ results = client.query 'SW1A', search_for: PostcodeAnywhere::CapturePlus::POSTCODE
61
+
62
+ results.count
63
+ # => 10
64
+ results.first.text
65
+ # => "SW1A 0AA"
66
+ ```
67
+
68
+ #### By company
69
+
70
+ This searches by postcode:
71
+
72
+ ```ruby
73
+ client = PostcodeAnywhere::CapturePlus::Client.new(
74
+ api_key: 'YOUR_API_KEY',
75
+ )
76
+
77
+ results = client.query_companies 'Asda'
78
+ # OR
79
+ results = client.query 'Asda', search_for: PostcodeAnywhere::CapturePlus::COMPANY
80
+
81
+ results.count
82
+ # => 7
83
+ results.first.text
84
+ # => "Asda Stores Ltd, Ipswich, IP1..."
85
+ ```
86
+
87
+ #### By place
88
+
89
+ This searches by postcode:
90
+
91
+ ```ruby
92
+ client = PostcodeAnywhere::CapturePlus::Client.new(
93
+ api_key: 'YOUR_API_KEY',
94
+ )
95
+
96
+ results = client.query_places 'Hyde park, london'
97
+ # OR
98
+ results = client.query 'Hyde park, london', search_for: PostcodeAnywhere::CapturePlus::PLACE
99
+
100
+ results.count
101
+ # => 7
102
+ results.first.text
103
+ # => "Hyde Park, London, W2..."
104
+ ```
105
+
106
+ ### Sub query and refinement
107
+
108
+ Some search results have a 'next' value of 'Find'. These can be queried into by using
109
+ a sub query:
110
+
111
+ ```ruby
112
+ client = PostcodeAnywhere::CapturePlus::Client.new(
113
+ api_key: 'YOUR_API_KEY',
114
+ )
115
+
116
+ results = client.query_places 'Hyde park, london'
117
+ hyde_park_result = results.first
118
+
119
+ hyde_park_result.next
120
+ # => "Find"
121
+
122
+ hyde_park_sub_result = client.sub_query('park', hyde_park_result)
123
+
124
+ hyde_park_sub_result.first.text
125
+ # => => "Veranda Lodge, Metropolitan Police, The Royal Parks Operational Command Unit, The Old Police House, Hyde Park, London, W2..."
126
+ ```
127
+
128
+ ##### NOTE: Only search results which have the 'next' value of 'Find' will return a meaningful result. Results with a 'next' of 'Retrieve' should be retrieved (see below)
129
+
130
+ ### Retrieval
131
+
132
+ The full details of a search result can be retrieved as follows:
133
+
134
+ ##### IMPORTANT: Only search results which have the 'next' value of 'Retrieve' will return a result. Search results with 'next' of 'Find' need to be refined with a sub_query. (See above)
135
+
136
+ A retrieved result has a full set of available fields to it which are listed in the [postcode anywhere docs](http://www.postcodeanywhere.co.uk/support/webservice/captureplus/interactive/retrieve/2/)
137
+
138
+ ```ruby
139
+ client = PostcodeAnywhere::CapturePlus::Client.new(
140
+ api_key: 'YOUR_API_KEY',
141
+ )
142
+
143
+ results = client.query_places 'Hyde park, london'
144
+ hyde_park_result = results.first
145
+ hyde_park_sub_result = client.sub_query('park', hyde_park_result)
146
+
147
+ hyde_park_police_result = hyde_park_sub_result.first
148
+
149
+ hyde_park_police = client.retrieve(hyde_park_police_result)
150
+
151
+ hyde_park_police.department
152
+ # => "The Royal Parks Operational Command Unit"
153
+
154
+ hyde_park_police.postal_code
155
+ # => => "W2 2UH"
156
+ ```
157
+
158
+ ### [Data Cleansing](http://www.postcodeanywhere.co.uk/Support/WebService/CleansePlus/Interactive/Cleanse/1/)
159
+
160
+ An address can be cleansed by using the CleansePlus client, as follows:
161
+
162
+ ```ruby
163
+ client = PostcodeAnywhere::CleansePlus::Client.new(
164
+ api_key: 'YOUR_API_KEY',
165
+ )
166
+
167
+ addresses = client.address_candidates_for 'London, SW1A 1AA'
168
+
169
+ addresses.first.company
170
+ # =>"Buckingham Palace"
171
+ ```
172
+
173
+ The following fields are available on an address:
174
+
175
+ **udprn, company, department, line1, line2, line3, line4, line5, post_town, county,
176
+ postcode, mailsort, barcode, type, delivery_point_suffix, sub_building, building_name,
177
+ building_number, primary_street, secondary_street, double_dependent_locality,
178
+ dependent_locality, po_box**
179
+
180
+ ### [Payment Validation](http://www.postcodeanywhere.co.uk/bank-account-validation/api/)
181
+
182
+ #### [Retrieve by sort code](http://www.postcodeanywhere.co.uk/Support/WebService/BankAccountValidation/Interactive/RetrieveBySortcode/1/)
183
+
184
+ A bank branch can be retrieved from a sort code:
185
+
186
+ ```ruby
187
+ client = PostcodeAnywhere::BankAccountValidation::Client.new(
188
+ api_key: 'YOUR_API_KEY',
189
+ )
190
+
191
+ branch = client.retrieve_by_sortcode '40-17-53'
192
+
193
+ branch.contact_postcode
194
+ # => "GL53 7RA"
195
+ branch.bank
196
+ # => "HSBC BANK PLC"
197
+ branch.faster_payments_supported
198
+ # => true
199
+ ```
200
+
201
+ The following fields are available on a bank branch:
202
+
203
+ **bank, bank_bic, branch, branch_bic, contact_address_line1, contact_address_line2,
204
+ contact_post_town, contact_postcode, contact_phone, contact_fax,
205
+ faster_payments_supported, chaps_supported**
206
+
207
+ #### [Validate account](http://www.postcodeanywhere.co.uk/support/webservice/bankaccountvalidation/interactive/validate/2/)
208
+
209
+ A bank account number and sort code can be validated:
210
+
211
+ ```ruby
212
+ client = PostcodeAnywhere::BankAccountValidation::Client.new(
213
+ api_key: 'YOUR_API_KEY',
214
+ )
215
+
216
+ validation = client.validate_account('12345678','11-22-33')
217
+
218
+ validation.is_correct
219
+ # => true
220
+ ```
221
+
222
+ The following fields are available for a validation:
223
+
224
+ **is_correct, is_direct_debit_capable, status_information, corrected_sort_code,
225
+ corrected_account_number, iban, bank, bank_bic, branch, branch_bic,
226
+ contact_address_line1, contact_address_line2, contact_post_town, contact_postcode,
227
+ contact_phone, contact_fax, faster_payments_supported, chaps_supported**
228
+
229
+ ### [Email Validation](http://www.postcodeanywhere.co.uk/email-validation/api/)
230
+
231
+ #### [Validate email](http://www.postcodeanywhere.co.uk/Support/WebService/EmailValidation/Interactive/Validate/1.1/)
232
+
233
+ An email address can be validated:
234
+
235
+ ```ruby
236
+ client = PostcodeAnywhere::EmailValidation::Client.new(
237
+ api_key: 'YOUR_API_KEY',
238
+ )
239
+
240
+ validation = client.validate_email_address('some_email_address@email.com')
241
+
242
+ # Options then are
243
+
244
+ validation.valid_format
245
+ # => true
246
+ validation.found_dns_record
247
+ # => true
248
+ validation.mail_server
249
+ # => 'aspmx3.googlemail.com'
250
+ validation.email
251
+ # => 'some_email_address@email.com'
252
+ ```
253
+
254
+ ## Errors
255
+
256
+ If there is something critically wrong with the service, then the gem will throw a relevant
257
+ exception which may be one of:
258
+
259
+ ```ruby
260
+ PostcodeAnywhere::Error::BadRequest,
261
+ PostcodeAnywhere::Error::Unauthorized,
262
+ PostcodeAnywhere::Error::Forbidden,
263
+ PostcodeAnywhere::Error::NotFound,
264
+ PostcodeAnywhere::Error::NotAcceptable,
265
+ PostcodeAnywhere::Error::RequestTimeout,
266
+ PostcodeAnywhere::Error::UnprocessableEntity,
267
+ PostcodeAnywhere::Error::TooManyRequests,
268
+ PostcodeAnywhere::Error::InternalServerError,
269
+ PostcodeAnywhere::Error::BadGateway,
270
+ PostcodeAnywhere::Error::ServiceUnavailable,
271
+ PostcodeAnywhere::Error::GatewayTimeout
272
+ ```
273
+
274
+ However other errors, such as an invalid API key will throw an error where both a
275
+ **cause** and **resolution** should be available as such:
276
+
277
+ ```ruby
278
+ begin
279
+ rescue PostcodeAnywhere::Error => e
280
+ puts e.cause # => 'The key you are using to access the service was not found.'
281
+ puts e.resolution # => 'Please check that the key is correct. It should be in the form AA11-AA11-AA11-AA11.'
282
+ end
283
+ ```
284
+
285
+ Some Postcode Anywhere errors include:
286
+
287
+ | Error | Cause | Resolution |
288
+ |----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
289
+ | `PostcodeAnywhere::Error::UnknownError` | The cause of the error is unknown but details have been passed to our support staff who will investigate. | These problems are typically short lived and are often resolved by trying again in a few minutes. |
290
+ | `PostcodeAnywhere::Error::UnknownKey` | The key you are using to access the service was not found. | Please check that the key is correct. It should be in the form AA11-AA11-AA11-AA11. |
291
+ | `PostcodeAnywhere::Error::AccountOutOfCredit` | Your account is either out of credit or has insufficient credit to service this request. | Please check your account balance and top it up if necessary. |
292
+ | `PostcodeAnywhere::Error::IpDenied` | The request was disallowed from the IP address. | Check the security settings on the key first. If they look fine, please contact support as it may be from an IP address on our blacklist. |
293
+ | `PostcodeAnywhere::Error::UrlDenied` | The request was disallowed from the URL. | Check the security settings on the key first. If they look fine, please contact support as it may be from a URL on our blacklist. |
294
+ | `PostcodeAnywhere::Error::ServiceDeniedForKey` | The requested web service is disallowed on this key. | Check the security settings on the key first. You can limit a key to certain web services. |
295
+ | `PostcodeAnywhere::Error::ServiceDeniedForPlan` | The requested web service is not currently available on your payment plan. | Some services are only available in specific regions due to licensing restrictions. Please contact us for more information. |
296
+ | `PostcodeAnywhere::Error::KeyDailyLimitExceeded` | The daily limit on the key has been exceeded. | Alter the daily limit on the key. Check the usage details first to see if usage is normal. |
297
+ | `PostcodeAnywhere::Error::SurgeProtectorRunning` | The surge protector is currently enabled and has temporarily suspended access to the account. | You can disable the surge protector at any time, but this is only recommended if you are running through a batch of requests. |
298
+ | `PostcodeAnywhere::Error::SurgeProtectorTriggered` | An unusually large number of requests have been processed for your account so the surge protector has been enabled. | You can disable the surge protector at any time but this is only recommended if you are running through a batch of requests. |
299
+ | `PostcodeAnywhere::Error::NoValidLicense` | The request requires a valid license but none were found. | Please check your purchase history. You may be using a license that is no longer valid or of an incorrect type. |
300
+ | `PostcodeAnywhere::Error::ManagementKeyRequired` | To use this web service you require a management key. Management can be enabled on any key, but we advise you to use management keys with care. | Sign in to the website and create a new management key or change an existing key. |
301
+ | `PostcodeAnywhere::Error::DemoLimitExceeded` | The daily demonstration limit for this service or account has been exceeded. | The limit will be reset at midnight tonight. If you would like the limit increased, please contact us. |
302
+ | `PostcodeAnywhere::Error::FreeLimitExceeded` | You have used too many free web services. | Our web services are designed to operate in stages. The first is usually a Find service followed by a Retrieve. If you use too many Finds without the corresponding number of Retrieves you will receive this error. For more information, please contact us. |
303
+ | `PostcodeAnywhere::Error::IncorrectKeyType` | The type of key you're using isn't supported by this web service. | This usually happens if you're using a user or server license with a web service that only supports transactional keys. Please use another key and try again. |
304
+ | `PostcodeAnywhere::Error::KeyExpired` | The key you are trying to use has expired. | Please check that you are using the right key. A new one may have been issued if you recently renewed your key. Contact us if you have any questions. |
305
+
306
+ ## Small disclaimer
307
+
308
+ The general architecture of this Gem is taken from that of the
309
+ [Twitter API Gem](https://github.com/sferik/twitter) so credit to be directed that way.
310
+ This structure has been used mainly because this structure generally works well for us
311
+ at Simple Merchant and it's well tested.
312
+
313
+ ## Contributing
314
+
315
+ 1. Fork it ( https://github.com/simplemerchant/postcode_anywhere/fork )
316
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
317
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
318
+ 4. Push to the branch (`git push origin my-new-feature`)
319
+ 5. Create a new Pull Request