loqate 0.5.0 → 0.6.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 +4 -4
- data/.yardstick.yml +143 -64
- data/CHANGELOG.md +6 -1
- data/README.md +45 -0
- data/lib/loqate/bank/account_validation.rb +124 -0
- data/lib/loqate/bank/batch_account_validation.rb +124 -0
- data/lib/loqate/bank/branch.rb +79 -0
- data/lib/loqate/bank/card_validation.rb +18 -0
- data/lib/loqate/bank/gateway.rb +261 -0
- data/lib/loqate/bank/international_account_validation.rb +13 -0
- data/lib/loqate/gateway.rb +9 -0
- data/lib/loqate/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 655d046a38008004a6326183b2a283c7fe4d274d30c8ef483b31db174fc444c4
|
|
4
|
+
data.tar.gz: 3b1903221bc7c8dec2e66d4576e58a07e8951a58e78d263b466ac7eed06845f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6cb4834aab155f2d07512c40eabae69da60147027dfba6a3c14a66066a4ab8f9436dbdb2e8acb35e581826276d40768cada4274f1244457be9b869a9fa31d1e8
|
|
7
|
+
data.tar.gz: 51fe28520b336371baee222145ecaab28cd108495f196d23771ba3ecf476b3770c184d21d57d79b3da3697bb2872d9f539131094453a0c5c7befe20c6b927145
|
data/.yardstick.yml
CHANGED
|
@@ -17,143 +17,222 @@ rules:
|
|
|
17
17
|
exclude:
|
|
18
18
|
- Loqate::Address#==
|
|
19
19
|
- Loqate::Address#attributes
|
|
20
|
+
- Loqate::Address#description
|
|
21
|
+
- Loqate::Address#highlight
|
|
20
22
|
- Loqate::Address#id
|
|
21
23
|
- Loqate::Address#initialize
|
|
22
|
-
- Loqate::Address#type
|
|
23
24
|
- Loqate::Address#text
|
|
24
|
-
- Loqate::Address#
|
|
25
|
-
- Loqate::Address#description
|
|
25
|
+
- Loqate::Address#type
|
|
26
26
|
- Loqate::AddressGateway#initialize
|
|
27
27
|
- Loqate::APIResult#errors?
|
|
28
|
-
- Loqate::APIResult#items
|
|
29
28
|
- Loqate::APIResult#initialize
|
|
30
|
-
- Loqate::
|
|
31
|
-
- Loqate::
|
|
29
|
+
- Loqate::APIResult#items
|
|
30
|
+
- Loqate::Bank::AccountValidation#bank
|
|
31
|
+
- Loqate::Bank::AccountValidation#bank_bic
|
|
32
|
+
- Loqate::Bank::AccountValidation#branch
|
|
33
|
+
- Loqate::Bank::AccountValidation#branch_bic
|
|
34
|
+
- Loqate::Bank::AccountValidation#chaps_supported
|
|
35
|
+
- Loqate::Bank::AccountValidation#contact_address_line1
|
|
36
|
+
- Loqate::Bank::AccountValidation#contact_address_line2
|
|
37
|
+
- Loqate::Bank::AccountValidation#contact_fax
|
|
38
|
+
- Loqate::Bank::AccountValidation#contact_phone
|
|
39
|
+
- Loqate::Bank::AccountValidation#contact_post_town
|
|
40
|
+
- Loqate::Bank::AccountValidation#contact_postcode
|
|
41
|
+
- Loqate::Bank::AccountValidation#correct?
|
|
42
|
+
- Loqate::Bank::AccountValidation#corrected_account_number
|
|
43
|
+
- Loqate::Bank::AccountValidation#corrected_sort_code
|
|
44
|
+
- Loqate::Bank::AccountValidation#faster_payments_supported
|
|
45
|
+
- Loqate::Bank::AccountValidation#iban
|
|
46
|
+
- Loqate::Bank::AccountValidation#is_correct
|
|
47
|
+
- Loqate::Bank::AccountValidation#is_direct_debit_capable
|
|
48
|
+
- Loqate::Bank::AccountValidation#status_information
|
|
49
|
+
- Loqate::Bank::BatchAccountValidation#bank
|
|
50
|
+
- Loqate::Bank::BatchAccountValidation#bank_bic
|
|
51
|
+
- Loqate::Bank::BatchAccountValidation#branch
|
|
52
|
+
- Loqate::Bank::BatchAccountValidation#branch_bic
|
|
53
|
+
- Loqate::Bank::BatchAccountValidation#contact_address_line1
|
|
54
|
+
- Loqate::Bank::BatchAccountValidation#contact_address_line2
|
|
55
|
+
- Loqate::Bank::BatchAccountValidation#contact_fax
|
|
56
|
+
- Loqate::Bank::BatchAccountValidation#contact_phone
|
|
57
|
+
- Loqate::Bank::BatchAccountValidation#contact_post_town
|
|
58
|
+
- Loqate::Bank::BatchAccountValidation#contact_postcode
|
|
59
|
+
- Loqate::Bank::BatchAccountValidation#correct?
|
|
60
|
+
- Loqate::Bank::BatchAccountValidation#corrected_account_number
|
|
61
|
+
- Loqate::Bank::BatchAccountValidation#corrected_sort_code
|
|
62
|
+
- Loqate::Bank::BatchAccountValidation#iban
|
|
63
|
+
- Loqate::Bank::BatchAccountValidation#is_correct
|
|
64
|
+
- Loqate::Bank::BatchAccountValidation#is_direct_debit_capable
|
|
65
|
+
- Loqate::Bank::BatchAccountValidation#original_account_number
|
|
66
|
+
- Loqate::Bank::BatchAccountValidation#original_sort_code
|
|
67
|
+
- Loqate::Bank::BatchAccountValidation#status_information
|
|
68
|
+
- Loqate::Bank::Branch#bank
|
|
69
|
+
- Loqate::Bank::Branch#bank_bic
|
|
70
|
+
- Loqate::Bank::Branch#branch
|
|
71
|
+
- Loqate::Bank::Branch#branch_bic
|
|
72
|
+
- Loqate::Bank::Branch#chaps_supported
|
|
73
|
+
- Loqate::Bank::Branch#contact_address_line1
|
|
74
|
+
- Loqate::Bank::Branch#contact_address_line2
|
|
75
|
+
- Loqate::Bank::Branch#contact_fax
|
|
76
|
+
- Loqate::Bank::Branch#contact_phone
|
|
77
|
+
- Loqate::Bank::Branch#contact_post_town
|
|
78
|
+
- Loqate::Bank::Branch#contact_postcode
|
|
79
|
+
- Loqate::Bank::Branch#faster_payments_supported
|
|
80
|
+
- Loqate::Bank::CardValidation#card_number
|
|
81
|
+
- Loqate::Bank::CardValidation#card_type
|
|
82
|
+
- Loqate::Bank::Gateway#build_branch_from
|
|
83
|
+
- Loqate::Bank::Gateway#initialize
|
|
84
|
+
- Loqate::Bank::InternationalAccountValidation#correct?
|
|
85
|
+
- Loqate::Bank::InternationalAccountValidation#is_correct
|
|
32
86
|
- Loqate::BatchEmailValidation#account
|
|
33
87
|
- Loqate::BatchEmailValidation#domain
|
|
88
|
+
- Loqate::BatchEmailValidation#email_address
|
|
89
|
+
- Loqate::BatchEmailValidation#invalid?
|
|
34
90
|
- Loqate::BatchEmailValidation#is_disposible
|
|
35
91
|
- Loqate::BatchEmailValidation#is_system_mailbox
|
|
92
|
+
- Loqate::BatchEmailValidation#status
|
|
93
|
+
- Loqate::BatchEmailValidation#unknown?
|
|
94
|
+
- Loqate::BatchEmailValidation#unverified?
|
|
95
|
+
- Loqate::BatchEmailValidation#valid?
|
|
36
96
|
- Loqate::Configuration#api_key
|
|
37
97
|
- Loqate::Configuration#host
|
|
38
|
-
- Loqate::Configuration#language
|
|
39
98
|
- Loqate::Configuration#initialize
|
|
40
|
-
- Loqate::
|
|
99
|
+
- Loqate::Configuration#language
|
|
41
100
|
- Loqate::DetailedAddress#==
|
|
101
|
+
- Loqate::DetailedAddress#initialize
|
|
42
102
|
- Loqate::EmailGateway#initialize
|
|
103
|
+
- Loqate::EmailValidation#domain
|
|
104
|
+
- Loqate::EmailValidation#duration
|
|
105
|
+
- Loqate::EmailValidation#email_address
|
|
106
|
+
- Loqate::EmailValidation#invalid?
|
|
107
|
+
- Loqate::EmailValidation#is_complainer_or_fraud_risk
|
|
108
|
+
- Loqate::EmailValidation#is_disposable_or_temporary
|
|
43
109
|
- Loqate::EmailValidation#response_code
|
|
44
110
|
- Loqate::EmailValidation#response_message
|
|
45
|
-
- Loqate::EmailValidation#
|
|
111
|
+
- Loqate::EmailValidation#timeout?
|
|
46
112
|
- Loqate::EmailValidation#user_account
|
|
47
|
-
- Loqate::EmailValidation#domain
|
|
48
|
-
- Loqate::EmailValidation#is_disposable_or_temporary
|
|
49
|
-
- Loqate::EmailValidation#is_complainer_or_fraud_risk
|
|
50
|
-
- Loqate::EmailValidation#duration
|
|
51
113
|
- Loqate::EmailValidation#valid?
|
|
52
114
|
- Loqate::EmailValidation#valid_domain?
|
|
53
|
-
- Loqate::EmailValidation#invalid?
|
|
54
|
-
- Loqate::EmailValidation#timeout?
|
|
55
|
-
- Loqate::Error#id
|
|
56
|
-
- Loqate::Error#description
|
|
57
115
|
- Loqate::Error#cause
|
|
58
|
-
- Loqate::Error#
|
|
116
|
+
- Loqate::Error#description
|
|
117
|
+
- Loqate::Error#id
|
|
59
118
|
- Loqate::Error#initialize
|
|
60
|
-
- Loqate::
|
|
61
|
-
- Loqate::Gateway#initialize
|
|
119
|
+
- Loqate::Error#resolution
|
|
62
120
|
- Loqate::Gateway#address
|
|
121
|
+
- Loqate::Gateway#bank
|
|
122
|
+
- Loqate::Gateway#config
|
|
63
123
|
- Loqate::Gateway#email
|
|
124
|
+
- Loqate::Gateway#initialize
|
|
64
125
|
- Loqate::Gateway#phone
|
|
65
126
|
- Loqate::PhoneGateway#initialize
|
|
66
|
-
- Loqate::PhoneNumberValidation#
|
|
67
|
-
- Loqate::PhoneNumberValidation#request_processed
|
|
127
|
+
- Loqate::PhoneNumberValidation#country_prefix
|
|
68
128
|
- Loqate::PhoneNumberValidation#is_valid
|
|
129
|
+
- Loqate::PhoneNumberValidation#national_format
|
|
69
130
|
- Loqate::PhoneNumberValidation#network_code
|
|
70
|
-
- Loqate::PhoneNumberValidation#network_name
|
|
71
131
|
- Loqate::PhoneNumberValidation#network_country
|
|
72
|
-
- Loqate::PhoneNumberValidation#
|
|
73
|
-
- Loqate::PhoneNumberValidation#country_prefix
|
|
132
|
+
- Loqate::PhoneNumberValidation#network_name
|
|
74
133
|
- Loqate::PhoneNumberValidation#number_type
|
|
134
|
+
- Loqate::PhoneNumberValidation#phone_number
|
|
135
|
+
- Loqate::PhoneNumberValidation#request_processed
|
|
75
136
|
- Loqate::PhoneNumberValidation#valid?
|
|
76
|
-
- Loqate::Result::Success#success?
|
|
77
|
-
- Loqate::Result::Success#failure?
|
|
78
|
-
- Loqate::Result::Failure#success?
|
|
79
|
-
- Loqate::Result::Failure#failure?
|
|
80
137
|
- Loqate::Result#code
|
|
81
138
|
- Loqate::Result#value
|
|
82
139
|
- Loqate::Result::Failure#error
|
|
140
|
+
- Loqate::Result::Failure#failure?
|
|
141
|
+
- Loqate::Result::Failure#success?
|
|
142
|
+
- Loqate::Result::Success#failure?
|
|
143
|
+
- Loqate::Result::Success#success?
|
|
83
144
|
ReturnTag:
|
|
84
145
|
enabled: true
|
|
85
146
|
exclude:
|
|
86
147
|
- Loqate::Address#==
|
|
87
148
|
- Loqate::Address#attributes
|
|
149
|
+
- Loqate::Address#description
|
|
150
|
+
- Loqate::Address#highlight
|
|
88
151
|
- Loqate::Address#id
|
|
89
|
-
- Loqate::Address#type
|
|
90
152
|
- Loqate::Address#text
|
|
91
|
-
- Loqate::Address#
|
|
92
|
-
- Loqate::Address#description
|
|
93
|
-
- Loqate::AddressGateway#client
|
|
94
|
-
- Loqate::AddressGateway#mapper
|
|
95
|
-
- Loqate::AddressGateway#error_mapper
|
|
96
|
-
- Loqate::AddressGateway#build_error_from
|
|
153
|
+
- Loqate::Address#type
|
|
97
154
|
- Loqate::AddressGateway#build_addresses_from
|
|
98
155
|
- Loqate::AddressGateway#build_detailed_address_from
|
|
99
|
-
- Loqate::
|
|
156
|
+
- Loqate::AddressGateway#build_error_from
|
|
157
|
+
- Loqate::AddressGateway#client
|
|
158
|
+
- Loqate::AddressGateway#error_mapper
|
|
159
|
+
- Loqate::AddressGateway#mapper
|
|
160
|
+
- Loqate::Bank::Gateway#build_account_validation_from
|
|
161
|
+
- Loqate::Bank::Gateway#build_account_validations_from
|
|
162
|
+
- Loqate::Bank::Gateway#build_branch_from
|
|
163
|
+
- Loqate::Bank::Gateway#build_card_validation_from
|
|
164
|
+
- Loqate::Bank::Gateway#build_error_from
|
|
165
|
+
- Loqate::Bank::Gateway#build_int_acc_validation_from
|
|
166
|
+
- Loqate::Bank::Gateway#client
|
|
167
|
+
- Loqate::Bank::Gateway#error_mapper
|
|
168
|
+
- Loqate::Bank::Gateway#mapper
|
|
100
169
|
- Loqate::Client#authenticate_params
|
|
170
|
+
- Loqate::Client#configuration
|
|
101
171
|
- Loqate::Client#format_params
|
|
102
172
|
- Loqate::Client#headers
|
|
103
173
|
- Loqate::DetailedAddress#==
|
|
104
|
-
- Loqate::EmailGateway#error_mapper
|
|
105
|
-
- Loqate::EmailGateway#client
|
|
106
|
-
- Loqate::EmailGateway#mapper
|
|
107
|
-
- Loqate::EmailGateway#build_error_from
|
|
108
174
|
- Loqate::EmailGateway#build_email_validation_from
|
|
109
175
|
- Loqate::EmailGateway#build_email_validations_from
|
|
110
|
-
- Loqate::
|
|
111
|
-
- Loqate::
|
|
112
|
-
- Loqate::
|
|
113
|
-
- Loqate::
|
|
176
|
+
- Loqate::EmailGateway#build_error_from
|
|
177
|
+
- Loqate::EmailGateway#client
|
|
178
|
+
- Loqate::EmailGateway#error_mapper
|
|
179
|
+
- Loqate::EmailGateway#mapper
|
|
114
180
|
- Loqate::Error#attributes
|
|
115
181
|
- Loqate::Gateway#client
|
|
116
|
-
- Loqate::PhoneGateway#mapper
|
|
117
|
-
- Loqate::PhoneGateway#error_mapper
|
|
118
|
-
- Loqate::PhoneGateway#client
|
|
119
182
|
- Loqate::PhoneGateway#build_error_from
|
|
120
183
|
- Loqate::PhoneGateway#build_phone_validation_from
|
|
184
|
+
- Loqate::PhoneGateway#client
|
|
185
|
+
- Loqate::PhoneGateway#error_mapper
|
|
186
|
+
- Loqate::PhoneGateway#mapper
|
|
121
187
|
- Loqate::Result::Failure#error
|
|
188
|
+
- Loqate::Util#camelize
|
|
189
|
+
- Loqate::Util#underscore
|
|
190
|
+
- Loqate::Util.camelize
|
|
191
|
+
- Loqate::Util.underscore
|
|
122
192
|
Summary::Presence:
|
|
123
193
|
enabled: true
|
|
124
194
|
exclude:
|
|
125
195
|
- Loqate::Address#==
|
|
126
196
|
- Loqate::Address#attributes
|
|
197
|
+
- Loqate::Address#description
|
|
198
|
+
- Loqate::Address#highlight
|
|
127
199
|
- Loqate::Address#id
|
|
128
|
-
- Loqate::Address#type
|
|
129
200
|
- Loqate::Address#text
|
|
130
|
-
- Loqate::Address#
|
|
131
|
-
- Loqate::Address#description
|
|
132
|
-
- Loqate::AddressGateway#client
|
|
133
|
-
- Loqate::AddressGateway#mapper
|
|
134
|
-
- Loqate::AddressGateway#error_mapper
|
|
135
|
-
- Loqate::AddressGateway#build_error_from
|
|
201
|
+
- Loqate::Address#type
|
|
136
202
|
- Loqate::AddressGateway#build_addresses_from
|
|
137
203
|
- Loqate::AddressGateway#build_detailed_address_from
|
|
138
|
-
- Loqate::
|
|
204
|
+
- Loqate::AddressGateway#build_error_from
|
|
205
|
+
- Loqate::AddressGateway#client
|
|
206
|
+
- Loqate::AddressGateway#error_mapper
|
|
207
|
+
- Loqate::AddressGateway#mapper
|
|
208
|
+
- Loqate::Bank::Gateway#build_account_validation_from
|
|
209
|
+
- Loqate::Bank::Gateway#build_account_validations_from
|
|
210
|
+
- Loqate::Bank::Gateway#build_branch_from
|
|
211
|
+
- Loqate::Bank::Gateway#build_card_validation_from
|
|
212
|
+
- Loqate::Bank::Gateway#build_error_from
|
|
213
|
+
- Loqate::Bank::Gateway#build_int_acc_validation_from
|
|
214
|
+
- Loqate::Bank::Gateway#client
|
|
215
|
+
- Loqate::Bank::Gateway#error_mapper
|
|
216
|
+
- Loqate::Bank::Gateway#mapper
|
|
139
217
|
- Loqate::Client#authenticate_params
|
|
218
|
+
- Loqate::Client#configuration
|
|
140
219
|
- Loqate::Client#format_params
|
|
141
220
|
- Loqate::Client#headers
|
|
142
|
-
- Loqate::DetailedAddress#initialize
|
|
143
221
|
- Loqate::DetailedAddress#==
|
|
144
|
-
- Loqate::
|
|
145
|
-
- Loqate::EmailGateway#client
|
|
146
|
-
- Loqate::EmailGateway#mapper
|
|
147
|
-
- Loqate::EmailGateway#build_error_from
|
|
222
|
+
- Loqate::DetailedAddress#initialize
|
|
148
223
|
- Loqate::EmailGateway#build_email_validation_from
|
|
149
224
|
- Loqate::EmailGateway#build_email_validations_from
|
|
225
|
+
- Loqate::EmailGateway#build_error_from
|
|
226
|
+
- Loqate::EmailGateway#client
|
|
227
|
+
- Loqate::EmailGateway#error_mapper
|
|
228
|
+
- Loqate::EmailGateway#mapper
|
|
150
229
|
- Loqate::Error#attributes
|
|
151
230
|
- Loqate::Gateway#client
|
|
152
|
-
- Loqate::PhoneGateway#mapper
|
|
153
|
-
- Loqate::PhoneGateway#error_mapper
|
|
154
|
-
- Loqate::PhoneGateway#client
|
|
155
231
|
- Loqate::PhoneGateway#build_error_from
|
|
156
232
|
- Loqate::PhoneGateway#build_phone_validation_from
|
|
233
|
+
- Loqate::PhoneGateway#client
|
|
234
|
+
- Loqate::PhoneGateway#error_mapper
|
|
235
|
+
- Loqate::PhoneGateway#mapper
|
|
157
236
|
- Loqate::Result::Failure#error
|
|
158
237
|
Summary::Length:
|
|
159
238
|
enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.0] - 2018-12-03
|
|
8
|
+
### Added
|
|
9
|
+
- Bank API
|
|
10
|
+
|
|
7
11
|
## [0.5.0] - 2018-11-20
|
|
8
12
|
### Added
|
|
9
13
|
- Email API
|
|
@@ -49,7 +53,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
49
53
|
- Initial core functionality
|
|
50
54
|
- Codebase maintenance tools
|
|
51
55
|
|
|
52
|
-
[0.
|
|
56
|
+
[0.6.0]: https://github.com/wilsonsilva/loqate/compare/v0.5.0...v0.6.0
|
|
57
|
+
[0.5.0]: https://github.com/wilsonsilva/loqate/compare/v0.4.0...v0.5.0
|
|
53
58
|
[0.4.0]: https://github.com/wilsonsilva/loqate/compare/v0.3.0...v0.4.0
|
|
54
59
|
[0.3.0]: https://github.com/wilsonsilva/loqate/compare/v0.2.0...v0.3.0
|
|
55
60
|
[0.2.0]: https://github.com/wilsonsilva/loqate/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
|
@@ -24,6 +24,12 @@ Client to address verification, postcode lookup, & data quality services from Lo
|
|
|
24
24
|
- [Email API](#phone-api)
|
|
25
25
|
- [Validating an email address](#validating-an-email-address)
|
|
26
26
|
- [Validating multiple email addresses](#validating-multiple-email-addresses)
|
|
27
|
+
- [Bank API](#bank-api)
|
|
28
|
+
- [Retrieving the details of a bank branch](#retrieving-the-details-of-a-bank-branch)
|
|
29
|
+
- [Validating a bank account](#validating-a-bank-account)
|
|
30
|
+
- [Validating an international bank account](#validating-an-international-bank-account)
|
|
31
|
+
- [Validating multiple bank accounts](#validating-multiple-bank-accounts)
|
|
32
|
+
- [Validating a card](#validating-a-card)
|
|
27
33
|
- [Development](#development)
|
|
28
34
|
- [Contributing](#contributing)
|
|
29
35
|
- [License](#license)
|
|
@@ -188,6 +194,45 @@ email_validation.invalid? # => false
|
|
|
188
194
|
email_validation.unknown? # => false
|
|
189
195
|
email_validation.unverified? # => false
|
|
190
196
|
```
|
|
197
|
+
|
|
198
|
+
### Bank API
|
|
199
|
+
|
|
200
|
+
The Bank API exposes endpoints to validate bank accounts, cards and finding bank branches by sort code.
|
|
201
|
+
|
|
202
|
+
#### Retrieving the details of a bank branch
|
|
203
|
+
```ruby
|
|
204
|
+
bank_branch = gateway.bank.retrieve_by_sortcode!(sort_code: '404131')
|
|
205
|
+
bank_branch.bank # => HSBC UK BANK PLC
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Validating a bank account
|
|
209
|
+
```ruby
|
|
210
|
+
account_validation = gateway.bank.validate_account(account_number: '51065718', sort_code: '404131')
|
|
211
|
+
account_validation.correct? # => true
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Validating an international bank account
|
|
215
|
+
|
|
216
|
+
```ruby
|
|
217
|
+
account_validation = gateway.bank.validate_international_account!(iban: 'GB03 BARC 201147 8397 7692')
|
|
218
|
+
account_validation.correct? # => true
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### Validating multiple bank accounts
|
|
222
|
+
```ruby
|
|
223
|
+
accounts_validations = gateway.bank.batch_validate_accounts!(
|
|
224
|
+
account_numbers: %w[51065718 00000000],
|
|
225
|
+
sort_codes: %w[40-41-31 000000]
|
|
226
|
+
)
|
|
227
|
+
accounts_validations.first.correct? # => true
|
|
228
|
+
accounts_validations.second.correct? # => false
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Validating a card
|
|
232
|
+
```ruby
|
|
233
|
+
card_validation = gateway.bank.validate_card!(card_number: '4024007171239865')
|
|
234
|
+
card_validation.card_type # => VISA
|
|
235
|
+
```
|
|
191
236
|
|
|
192
237
|
## Development
|
|
193
238
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Bank
|
|
3
|
+
# Result of a bank account validation.
|
|
4
|
+
class AccountValidation < Dry::Struct::Value
|
|
5
|
+
StatusInformation = Types::Strict::String.enum('DetailsChanged', 'CautiousOK')
|
|
6
|
+
|
|
7
|
+
# Indicates whether the account number and sortcode are valid.
|
|
8
|
+
#
|
|
9
|
+
# @return [Boolean]
|
|
10
|
+
#
|
|
11
|
+
attribute :is_correct, Types::Strict::Bool
|
|
12
|
+
alias correct? is_correct
|
|
13
|
+
|
|
14
|
+
# Indicates whether the account can accept direct debits. Certain accounts (e.g. savings) will
|
|
15
|
+
# not accept direct debits.
|
|
16
|
+
#
|
|
17
|
+
# @return [Boolean]
|
|
18
|
+
#
|
|
19
|
+
attribute :is_direct_debit_capable, Types::Strict::Bool
|
|
20
|
+
|
|
21
|
+
# More detail about the outcome of the validation process. Describes reasons validation failed or changes
|
|
22
|
+
# made to pass validation. DetailsChanged indicates that the account and sortcode should be changed for
|
|
23
|
+
# BACs submission (check CorrectedAccountNumber and CorrectedSortCode). CautiousOK is set where the sortcode
|
|
24
|
+
# exists but no validation rules are set for the bank (very rare).
|
|
25
|
+
#
|
|
26
|
+
# @return [String]
|
|
27
|
+
#
|
|
28
|
+
attribute :status_information, Types::Strict::String
|
|
29
|
+
|
|
30
|
+
# The correct version of the SortCode. This will be 6 digits long with no hyphens. It may differ from
|
|
31
|
+
# the original sortcode.
|
|
32
|
+
#
|
|
33
|
+
# @return [String]
|
|
34
|
+
#
|
|
35
|
+
attribute :corrected_sort_code, Types::Strict::String
|
|
36
|
+
|
|
37
|
+
# The correct version of the AccountNumber. This will be 8 digits long and in the form expected
|
|
38
|
+
# for BACs submission.
|
|
39
|
+
#
|
|
40
|
+
# @return [String]
|
|
41
|
+
#
|
|
42
|
+
attribute :corrected_account_number, Types::Strict::String
|
|
43
|
+
|
|
44
|
+
# The correctly formatted IBAN for the account.
|
|
45
|
+
#
|
|
46
|
+
# @return [String]
|
|
47
|
+
#
|
|
48
|
+
attribute :iban, Types::Strict::String
|
|
49
|
+
|
|
50
|
+
# The name of the banking institution.
|
|
51
|
+
#
|
|
52
|
+
# @return [String]
|
|
53
|
+
#
|
|
54
|
+
attribute :bank, Types::Strict::String
|
|
55
|
+
|
|
56
|
+
# The banking institution's BIC, also know as the SWIFT BIC.
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
#
|
|
60
|
+
attribute :bank_bic, Types::Strict::String
|
|
61
|
+
|
|
62
|
+
# The name of the account holding branch.
|
|
63
|
+
#
|
|
64
|
+
# @return [String]
|
|
65
|
+
#
|
|
66
|
+
attribute :branch, Types::Strict::String
|
|
67
|
+
|
|
68
|
+
# The branch's BIC.
|
|
69
|
+
#
|
|
70
|
+
# @return [String]
|
|
71
|
+
#
|
|
72
|
+
attribute :branch_bic, Types::Strict::String
|
|
73
|
+
|
|
74
|
+
# Line 1 of the branch's contact address. NB: This is the address to be used for BACs enquiries and may
|
|
75
|
+
# be a contact centre rather than the branch's address.
|
|
76
|
+
#
|
|
77
|
+
# @return [String]
|
|
78
|
+
#
|
|
79
|
+
attribute :contact_address_line1, Types::Strict::String
|
|
80
|
+
|
|
81
|
+
# Line 2 of the branch's contact address.
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
#
|
|
85
|
+
attribute :contact_address_line2, Types::Strict::String
|
|
86
|
+
|
|
87
|
+
# The branch's contact post town.
|
|
88
|
+
#
|
|
89
|
+
# @return [String]
|
|
90
|
+
#
|
|
91
|
+
attribute :contact_post_town, Types::Strict::String
|
|
92
|
+
|
|
93
|
+
# The branch's contact postcode.
|
|
94
|
+
#
|
|
95
|
+
# @return [String]
|
|
96
|
+
#
|
|
97
|
+
attribute :contact_postcode, Types::Strict::String
|
|
98
|
+
|
|
99
|
+
# The branch's contact phone number.
|
|
100
|
+
#
|
|
101
|
+
# @return [String]
|
|
102
|
+
#
|
|
103
|
+
attribute :contact_phone, Types::Strict::String
|
|
104
|
+
|
|
105
|
+
# The branch's contact fax number.
|
|
106
|
+
#
|
|
107
|
+
# @return [String]
|
|
108
|
+
#
|
|
109
|
+
attribute :contact_fax, Types::Strict::String
|
|
110
|
+
|
|
111
|
+
# Indicates that the account supports the faster payments service.
|
|
112
|
+
#
|
|
113
|
+
# @return [Boolean]
|
|
114
|
+
#
|
|
115
|
+
attribute :faster_payments_supported, Types::Strict::Bool
|
|
116
|
+
|
|
117
|
+
# Indicates that the account supports the CHAPS service.
|
|
118
|
+
#
|
|
119
|
+
# @return [Boolean]
|
|
120
|
+
#
|
|
121
|
+
attribute :chaps_supported, Types::Strict::Bool
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Bank
|
|
3
|
+
# Result of a batch bank account validation.
|
|
4
|
+
class BatchAccountValidation < Dry::Struct::Value
|
|
5
|
+
StatusInformation = Types::Strict::String.enum('CautiousOK', 'DetailsChanged', 'OK')
|
|
6
|
+
|
|
7
|
+
# The original AccountNumber passed to validate, excluding any non numeric characters.
|
|
8
|
+
#
|
|
9
|
+
# @return [String]
|
|
10
|
+
#
|
|
11
|
+
attribute :original_account_number, Types::Strict::String
|
|
12
|
+
|
|
13
|
+
# The original SortCode passed to validate, excluding any non numeric characters.
|
|
14
|
+
#
|
|
15
|
+
# @return [String]
|
|
16
|
+
#
|
|
17
|
+
attribute :original_sort_code, Types::Strict::String
|
|
18
|
+
|
|
19
|
+
# Indicates whether the account number and sortcode are valid.
|
|
20
|
+
#
|
|
21
|
+
# @return [Boolean]
|
|
22
|
+
#
|
|
23
|
+
attribute :is_correct, Types::Strict::Bool
|
|
24
|
+
alias correct? is_correct
|
|
25
|
+
|
|
26
|
+
# Indicates whether the account can accept direct debits. Certain accounts (e.g. savings) will
|
|
27
|
+
# not accept direct debits.
|
|
28
|
+
#
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
#
|
|
31
|
+
attribute :is_direct_debit_capable, Types::Strict::Bool
|
|
32
|
+
|
|
33
|
+
# More detail about the outcome of the validation process. Describes reasons validation failed or changes
|
|
34
|
+
# made to pass validation. DetailsChanged indicates that the account and sortcode should be changed for
|
|
35
|
+
# BACs submission (check CorrectedAccountNumber and CorrectedSortCode). CautiousOK is set where the sortcode
|
|
36
|
+
# exists but no validation rules are set for the bank (very rare).
|
|
37
|
+
#
|
|
38
|
+
# @return [String]
|
|
39
|
+
#
|
|
40
|
+
attribute :status_information, StatusInformation
|
|
41
|
+
|
|
42
|
+
# The correct version of the SortCode. This will be 6 digits long with no hyphens. It may differ from
|
|
43
|
+
# the original sortcode.
|
|
44
|
+
#
|
|
45
|
+
# @return [String]
|
|
46
|
+
#
|
|
47
|
+
attribute :corrected_sort_code, Types::Strict::String
|
|
48
|
+
|
|
49
|
+
# he correct version of the AccountNumber. This will be 8 digits long and in the form expected
|
|
50
|
+
# for BACs submission.
|
|
51
|
+
#
|
|
52
|
+
# @return [String]
|
|
53
|
+
#
|
|
54
|
+
attribute :corrected_account_number, Types::Strict::String
|
|
55
|
+
|
|
56
|
+
# The correctly formatted IBAN for the account.
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
#
|
|
60
|
+
attribute :iban, Types::Strict::String
|
|
61
|
+
|
|
62
|
+
# The name of the banking institution.
|
|
63
|
+
#
|
|
64
|
+
# @return [String]
|
|
65
|
+
#
|
|
66
|
+
attribute :bank, Types::Strict::String
|
|
67
|
+
|
|
68
|
+
# The banking institution's BIC, also know as the SWIFT BIC.
|
|
69
|
+
#
|
|
70
|
+
# @return [String]
|
|
71
|
+
#
|
|
72
|
+
attribute :bank_bic, Types::Strict::String
|
|
73
|
+
|
|
74
|
+
# The name of the account holding branch.
|
|
75
|
+
#
|
|
76
|
+
# @return [String]
|
|
77
|
+
#
|
|
78
|
+
attribute :branch, Types::Strict::String
|
|
79
|
+
|
|
80
|
+
# The branch's BIC.
|
|
81
|
+
#
|
|
82
|
+
# @return [String]
|
|
83
|
+
#
|
|
84
|
+
attribute :branch_bic, Types::Strict::String
|
|
85
|
+
|
|
86
|
+
# Line 1 of the branch's contact address. NB: This is the address to be used for BACs enquiries and may
|
|
87
|
+
# be a contact centre rather than the branch's address.
|
|
88
|
+
#
|
|
89
|
+
# @return [String]
|
|
90
|
+
#
|
|
91
|
+
attribute :contact_address_line1, Types::Strict::String
|
|
92
|
+
|
|
93
|
+
# Line 2 of the branch's contact address.
|
|
94
|
+
#
|
|
95
|
+
# @return [String]
|
|
96
|
+
#
|
|
97
|
+
attribute :contact_address_line2, Types::Strict::String
|
|
98
|
+
|
|
99
|
+
# The branch's contact post town.
|
|
100
|
+
#
|
|
101
|
+
# @return [String]
|
|
102
|
+
#
|
|
103
|
+
attribute :contact_post_town, Types::Strict::String
|
|
104
|
+
|
|
105
|
+
# The branch's contact postcode.
|
|
106
|
+
#
|
|
107
|
+
# @return [String]
|
|
108
|
+
#
|
|
109
|
+
attribute :contact_postcode, Types::Strict::String
|
|
110
|
+
|
|
111
|
+
# The branch's contact phone number.
|
|
112
|
+
#
|
|
113
|
+
# @return [String]
|
|
114
|
+
#
|
|
115
|
+
attribute :contact_phone, Types::Strict::String
|
|
116
|
+
|
|
117
|
+
# The branch's contact fax number.
|
|
118
|
+
#
|
|
119
|
+
# @return [String]
|
|
120
|
+
#
|
|
121
|
+
attribute :contact_fax, Types::Strict::String
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Bank
|
|
3
|
+
# Result of a bank branch retrieval.
|
|
4
|
+
class Branch < Dry::Struct::Value
|
|
5
|
+
# The name of the banking institution.
|
|
6
|
+
#
|
|
7
|
+
# @return [String]
|
|
8
|
+
#
|
|
9
|
+
attribute :bank, Types::Strict::String
|
|
10
|
+
|
|
11
|
+
# The banking institution's BIC, also know as the SWIFT BIC.
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
#
|
|
15
|
+
attribute :bank_bic, Types::Strict::String
|
|
16
|
+
|
|
17
|
+
# The name of the account holding branch.
|
|
18
|
+
#
|
|
19
|
+
# @return [String]
|
|
20
|
+
#
|
|
21
|
+
attribute :branch, Types::Strict::String
|
|
22
|
+
|
|
23
|
+
# The branch's BIC.
|
|
24
|
+
#
|
|
25
|
+
# @return [String]
|
|
26
|
+
#
|
|
27
|
+
attribute :branch_bic, Types::Strict::String
|
|
28
|
+
|
|
29
|
+
# Line 1 of the branch's contact address. NB: This is the address to be used for BACs enquiries and may
|
|
30
|
+
# be a contact centre rather than the branch's address.
|
|
31
|
+
#
|
|
32
|
+
# @return [String]
|
|
33
|
+
#
|
|
34
|
+
attribute :contact_address_line1, Types::Strict::String
|
|
35
|
+
|
|
36
|
+
# Line 2 of the branch's contact address.
|
|
37
|
+
#
|
|
38
|
+
# @return [String]
|
|
39
|
+
#
|
|
40
|
+
attribute :contact_address_line2, Types::Strict::String
|
|
41
|
+
|
|
42
|
+
# The branch's contact post town.
|
|
43
|
+
#
|
|
44
|
+
# @return [String]
|
|
45
|
+
#
|
|
46
|
+
attribute :contact_post_town, Types::Strict::String
|
|
47
|
+
|
|
48
|
+
# The branch's contact postcode.
|
|
49
|
+
#
|
|
50
|
+
# @return [String]
|
|
51
|
+
#
|
|
52
|
+
attribute :contact_postcode, Types::Strict::String
|
|
53
|
+
|
|
54
|
+
# The branch's contact phone number.
|
|
55
|
+
#
|
|
56
|
+
# @return [String]
|
|
57
|
+
#
|
|
58
|
+
attribute :contact_phone, Types::Strict::String
|
|
59
|
+
|
|
60
|
+
# The branch's contact fax number.
|
|
61
|
+
#
|
|
62
|
+
# @return [String]
|
|
63
|
+
#
|
|
64
|
+
attribute :contact_fax, Types::Strict::String
|
|
65
|
+
|
|
66
|
+
# Indicates that the account supports the faster payments service.
|
|
67
|
+
#
|
|
68
|
+
# @return [Boolean]
|
|
69
|
+
#
|
|
70
|
+
attribute :faster_payments_supported, Types::Strict::Bool
|
|
71
|
+
|
|
72
|
+
# Indicates that the account supports the CHAPS service.
|
|
73
|
+
#
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
#
|
|
76
|
+
attribute :chaps_supported, Types::Strict::Bool
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Bank
|
|
3
|
+
# Result of a card validation.
|
|
4
|
+
class CardValidation < Dry::Struct::Value
|
|
5
|
+
# The cleaned card number.
|
|
6
|
+
#
|
|
7
|
+
# @return [String]
|
|
8
|
+
#
|
|
9
|
+
attribute :card_number, Types::Strict::String
|
|
10
|
+
|
|
11
|
+
# The card type (e.g. Visa, Mastercard etc).
|
|
12
|
+
#
|
|
13
|
+
# @return [String]
|
|
14
|
+
#
|
|
15
|
+
attribute :card_type, Types::Strict::String
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
require 'loqate/client'
|
|
2
|
+
require 'loqate/result'
|
|
3
|
+
require 'loqate/mappers/error_mapper'
|
|
4
|
+
require 'loqate/mappers/generic_mapper'
|
|
5
|
+
require 'loqate/bank/account_validation'
|
|
6
|
+
require 'loqate/bank/batch_account_validation'
|
|
7
|
+
require 'loqate/bank/card_validation'
|
|
8
|
+
require 'loqate/bank/branch'
|
|
9
|
+
require 'loqate/bank/international_account_validation'
|
|
10
|
+
require 'loqate/bank/card_validation'
|
|
11
|
+
|
|
12
|
+
module Loqate
|
|
13
|
+
module Bank
|
|
14
|
+
# Validates bank accounts, branches and cards.
|
|
15
|
+
#
|
|
16
|
+
class Gateway
|
|
17
|
+
RETRIEVE_BY_SORTCODE_ENDPOINT = '/BankAccountValidation/Interactive/RetrieveBySortcode/v1.00/json3.ws'.freeze
|
|
18
|
+
VALIDATE_CARD_ENDPOINT = '/CardValidation/Interactive/Validate/v1/json3.ws'.freeze
|
|
19
|
+
VALIDATE_ACCOUNT_ENDPOINT = '/BankAccountValidation/Interactive/Validate/v2/json3.ws'.freeze
|
|
20
|
+
VALIDATE_ACCOUNTS_ENDPOINT = '/BankAccountValidation/Batch/Validate/v1/json3.ws'.freeze
|
|
21
|
+
VALIDATE_INT_ACCOUNT_ENDPOINT = '/InternationalBankValidation/Interactive/Validate/v1/json3.ws'.freeze
|
|
22
|
+
|
|
23
|
+
include Result::Mixin
|
|
24
|
+
|
|
25
|
+
# Creates a bank gateway
|
|
26
|
+
#
|
|
27
|
+
# @param [Client] client The client responsible for the HTTP interactions
|
|
28
|
+
#
|
|
29
|
+
def initialize(client)
|
|
30
|
+
@client = client
|
|
31
|
+
@mapper = Mappers::GenericMapper.new
|
|
32
|
+
@error_mapper = Mappers::ErrorMapper.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Batch validates the bank account and sort code for an UK bank account are correct.
|
|
36
|
+
# Returns details of the holding branch, IBAN and correct BACS account details.
|
|
37
|
+
#
|
|
38
|
+
# @param [Hash] options The options to batch validate bank accounts.
|
|
39
|
+
# @option options [String] :account_numbers The bank account numbers to validate.
|
|
40
|
+
# @option options [String] :sort_codes The branch sort codes for the account number.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# account_numbers = [123456789, 987654321]
|
|
44
|
+
# sort_codes = ['12-34-56', '65-43-21']
|
|
45
|
+
#
|
|
46
|
+
# result = bank_gateway.batch_validate_accounts(
|
|
47
|
+
# account_numbers: account_numbers,
|
|
48
|
+
# sort_codes: sort_codes
|
|
49
|
+
# )
|
|
50
|
+
#
|
|
51
|
+
# @return [Result] A result wrapping multiple account validations
|
|
52
|
+
#
|
|
53
|
+
def batch_validate_accounts(options)
|
|
54
|
+
response = client.get(VALIDATE_ACCOUNTS_ENDPOINT, options)
|
|
55
|
+
|
|
56
|
+
response.errors? && build_error_from(response.items.first) || build_account_validations_from(response.items)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Validates the bank account and sort code for an UK bank account are correct. Returns details of
|
|
60
|
+
# the holding branch, IBAN and correct BACS account details.
|
|
61
|
+
#
|
|
62
|
+
# @param [Hash] options The options to validate a bank account.
|
|
63
|
+
# @option options [String] :account_number The bank account number to validate.
|
|
64
|
+
# @option options [String] :sort_code The branch sort code for the account number.
|
|
65
|
+
#
|
|
66
|
+
# @example
|
|
67
|
+
# result = bank_gateway.validate_account(account_number: '123456', sort_code: '12-34-56')
|
|
68
|
+
#
|
|
69
|
+
# @return [Result] A result wrapping a bank account validation
|
|
70
|
+
#
|
|
71
|
+
def validate_account(options)
|
|
72
|
+
response = client.get(VALIDATE_ACCOUNT_ENDPOINT, options)
|
|
73
|
+
|
|
74
|
+
first_result = response.items.first
|
|
75
|
+
response.errors? && build_error_from(first_result) || build_account_validation_from(first_result)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Validates if the international bank account number for an international bank account is correct.
|
|
79
|
+
#
|
|
80
|
+
# @param [Hash] options The options to validate an international bank account.
|
|
81
|
+
# @option options [String] :iban The international bank account number to validate.
|
|
82
|
+
#
|
|
83
|
+
# @example
|
|
84
|
+
# result = bank_gateway.validate_international_account(iban: 'GB67HBUK40413151065718')
|
|
85
|
+
#
|
|
86
|
+
# @return [Result] A result wrapping a bank account validation
|
|
87
|
+
#
|
|
88
|
+
def validate_international_account(options)
|
|
89
|
+
response = client.get(VALIDATE_INT_ACCOUNT_ENDPOINT, options)
|
|
90
|
+
|
|
91
|
+
first_result = response.items.first
|
|
92
|
+
response.errors? && build_error_from(first_result) || build_int_acc_validation_from(first_result)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Returns details of the holding branch.
|
|
96
|
+
#
|
|
97
|
+
# @param [Hash] options The options to retrieve the details of the holding branch.
|
|
98
|
+
# @option options [String] :sort_code The branch sortcode.
|
|
99
|
+
#
|
|
100
|
+
# @example
|
|
101
|
+
# result = bank_gateway.retrieve_by_postcode(sort_code: 'S1 2HD')
|
|
102
|
+
#
|
|
103
|
+
# @return [Result] A result wrapping a bank branch
|
|
104
|
+
#
|
|
105
|
+
def retrieve_by_sortcode(options)
|
|
106
|
+
response = client.get(RETRIEVE_BY_SORTCODE_ENDPOINT, options)
|
|
107
|
+
|
|
108
|
+
response.errors? && build_error_from(response.items.first) || build_branch_from(response.items)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Validates the credit card number follows the correct format for the card type.
|
|
112
|
+
#
|
|
113
|
+
# @param [Hash] options The options to validate an card.
|
|
114
|
+
# @option options [String] :card_number The full card number. Any spaces or non numeric
|
|
115
|
+
# characters will be ignored.
|
|
116
|
+
#
|
|
117
|
+
# @example
|
|
118
|
+
# result = bank_gateway.validate_card(card_number: '4024 0071 7123 9865')
|
|
119
|
+
#
|
|
120
|
+
# @return [Result] A result wrapping a card validation
|
|
121
|
+
#
|
|
122
|
+
def validate_card(options)
|
|
123
|
+
response = client.get(VALIDATE_CARD_ENDPOINT, options)
|
|
124
|
+
|
|
125
|
+
response.errors? && build_error_from(response.items.first) || build_card_validation_from(response.items.first)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Batch validates the bank account and sort code for an UK bank account are correct.
|
|
129
|
+
# Returns details of the holding branch, IBAN and correct BACS account details.
|
|
130
|
+
#
|
|
131
|
+
# @param [Hash] options The options to batch validate bank accounts.
|
|
132
|
+
# @option options [String] :account_numbers The bank account numbers to validate.
|
|
133
|
+
# @option options [String] :sort_codes The branch sort codes for the account number.
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# account_numbers = [123456789, 987654321]
|
|
137
|
+
# sort_codes = ['12-34-56', '65-43-21']
|
|
138
|
+
#
|
|
139
|
+
# account_validations = bank_gateway.batch_validate_accounts!(
|
|
140
|
+
# account_numbers: account_numbers,
|
|
141
|
+
# sort_codes: sort_codes
|
|
142
|
+
# )
|
|
143
|
+
#
|
|
144
|
+
# @raise [Error] If the result is not a success
|
|
145
|
+
#
|
|
146
|
+
# @return [Array<BatchAccountValidation>] A list of account validations
|
|
147
|
+
#
|
|
148
|
+
def batch_validate_accounts!(options)
|
|
149
|
+
unwrap_result_or_raise { batch_validate_accounts(options) }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Validates the bank account and sort code for an UK bank account are correct. Returns details of
|
|
153
|
+
# the holding branch, IBAN and correct BACS account details.
|
|
154
|
+
#
|
|
155
|
+
# @param [Hash] options The options to validate a bank account.
|
|
156
|
+
# @option options [String] :account_number The bank account number to validate.
|
|
157
|
+
# @option options [String] :sort_code The branch sort code for the account number.
|
|
158
|
+
#
|
|
159
|
+
# @example
|
|
160
|
+
# bank_validation = bank_gateway.validate_account!(account_number: '123456', sort_code: '12-34-56')
|
|
161
|
+
#
|
|
162
|
+
# @raise [Error] If the result is not a success
|
|
163
|
+
#
|
|
164
|
+
# @return [AccountValidation] A bank account validation
|
|
165
|
+
#
|
|
166
|
+
def validate_account!(options)
|
|
167
|
+
unwrap_result_or_raise { validate_account(options) }
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Validates if the international bank account number for an international bank account is correct.
|
|
171
|
+
#
|
|
172
|
+
# @param [Hash] options The options to validate an international bank account.
|
|
173
|
+
# @option options [String] :iban The international bank account number to validate.
|
|
174
|
+
#
|
|
175
|
+
# @example
|
|
176
|
+
# bank_validation = bank_gateway.validate_international_account!(iban: 'GB67HBUK40413151065718')
|
|
177
|
+
#
|
|
178
|
+
# @raise [Error] If the result is not a success
|
|
179
|
+
#
|
|
180
|
+
# @return [InternationalAccountValidation] An international bank account validation
|
|
181
|
+
#
|
|
182
|
+
def validate_international_account!(options)
|
|
183
|
+
unwrap_result_or_raise { validate_international_account(options) }
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Returns details of the holding branch.
|
|
187
|
+
#
|
|
188
|
+
# @param [Hash] options The options to retrieve the details of the holding branch.
|
|
189
|
+
# @option options [String] :sort_code The branch sortcode.
|
|
190
|
+
#
|
|
191
|
+
# @example
|
|
192
|
+
# branch = bank_gateway.retrieve_by_postcode!(sort_code: 'S1 2HD')
|
|
193
|
+
#
|
|
194
|
+
# @raise [Error] If the result is not a success
|
|
195
|
+
#
|
|
196
|
+
# @return [Branch] A bank branch
|
|
197
|
+
#
|
|
198
|
+
def retrieve_by_sortcode!(options)
|
|
199
|
+
unwrap_result_or_raise { retrieve_by_sortcode(options) }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Validates the credit card number follows the correct format for the card type.
|
|
203
|
+
#
|
|
204
|
+
# @param [Hash] options The options to validate an card.
|
|
205
|
+
# @option options [String] :card_number The full card number. Any spaces or non numeric
|
|
206
|
+
# characters will be ignored.
|
|
207
|
+
#
|
|
208
|
+
# @example
|
|
209
|
+
# card_validation = bank_gateway.validate_card!(card_number: '4024 0071 7123 9865')
|
|
210
|
+
#
|
|
211
|
+
# @raise [Error] If the result is not a success
|
|
212
|
+
#
|
|
213
|
+
# @return [CardValidation] A card validation
|
|
214
|
+
#
|
|
215
|
+
def validate_card!(options)
|
|
216
|
+
unwrap_result_or_raise { validate_card(options) }
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
private
|
|
220
|
+
|
|
221
|
+
# @api private
|
|
222
|
+
attr_reader :client, :mapper, :error_mapper
|
|
223
|
+
|
|
224
|
+
# @api private
|
|
225
|
+
def build_error_from(item)
|
|
226
|
+
error = error_mapper.map_one(item)
|
|
227
|
+
Failure(error)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# @api private
|
|
231
|
+
def build_account_validation_from(item)
|
|
232
|
+
account_validation = mapper.map_one(item, AccountValidation)
|
|
233
|
+
Success(account_validation)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# @api private
|
|
237
|
+
def build_account_validations_from(items)
|
|
238
|
+
batch_account_validation = mapper.map(items, BatchAccountValidation)
|
|
239
|
+
Success(batch_account_validation)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# @api private
|
|
243
|
+
def build_int_acc_validation_from(item)
|
|
244
|
+
account_validation = mapper.map_one(item, InternationalAccountValidation)
|
|
245
|
+
Success(account_validation)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# @api private
|
|
249
|
+
def build_card_validation_from(item)
|
|
250
|
+
card_validation = mapper.map_one(item, CardValidation)
|
|
251
|
+
Success(card_validation)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# @api private
|
|
255
|
+
def build_branch_from(items)
|
|
256
|
+
bank_branch = mapper.map(items, Branch).first
|
|
257
|
+
Success(bank_branch)
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Bank
|
|
3
|
+
# Result of an international bank account validation.
|
|
4
|
+
class InternationalAccountValidation < Dry::Struct::Value
|
|
5
|
+
# Indicates whether the account number and sortcode are valid.
|
|
6
|
+
#
|
|
7
|
+
# @return [Boolean]
|
|
8
|
+
#
|
|
9
|
+
attribute :is_correct, Types::Strict::Bool
|
|
10
|
+
alias correct? is_correct
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/loqate/gateway.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'loqate/address_gateway'
|
|
2
|
+
require 'loqate/bank/gateway'
|
|
2
3
|
require 'loqate/email_gateway'
|
|
3
4
|
require 'loqate/phone_gateway'
|
|
4
5
|
|
|
@@ -49,6 +50,14 @@ module Loqate
|
|
|
49
50
|
@email ||= EmailGateway.new(client)
|
|
50
51
|
end
|
|
51
52
|
|
|
53
|
+
# Gateway to the Bank verification APIs.
|
|
54
|
+
#
|
|
55
|
+
# @return [BankGateway] An instance of a bank gateway.
|
|
56
|
+
#
|
|
57
|
+
def bank
|
|
58
|
+
@bank ||= Bank::Gateway.new(client)
|
|
59
|
+
end
|
|
60
|
+
|
|
52
61
|
private
|
|
53
62
|
|
|
54
63
|
# @api private
|
data/lib/loqate/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loqate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wilson Silva
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-struct
|
|
@@ -347,6 +347,12 @@ files:
|
|
|
347
347
|
- lib/loqate/address.rb
|
|
348
348
|
- lib/loqate/address_gateway.rb
|
|
349
349
|
- lib/loqate/api_result.rb
|
|
350
|
+
- lib/loqate/bank/account_validation.rb
|
|
351
|
+
- lib/loqate/bank/batch_account_validation.rb
|
|
352
|
+
- lib/loqate/bank/branch.rb
|
|
353
|
+
- lib/loqate/bank/card_validation.rb
|
|
354
|
+
- lib/loqate/bank/gateway.rb
|
|
355
|
+
- lib/loqate/bank/international_account_validation.rb
|
|
350
356
|
- lib/loqate/batch_email_validation.rb
|
|
351
357
|
- lib/loqate/client.rb
|
|
352
358
|
- lib/loqate/configuration.rb
|